[pkg-nvidia-devel] r419 - in /packages/nvidia-xconfig/trunk: ./ XF86Config-parser/ debian/

rdonald at users.alioth.debian.org rdonald at users.alioth.debian.org
Tue Jun 24 17:53:26 UTC 2008


Author: rdonald
Date: Tue Jun 24 17:53:25 2008
New Revision: 419

URL: http://svn.debian.org/wsvn/pkg-nvidia/?sc=1&rev=419
Log:
new upstream

Added:
    packages/nvidia-xconfig/trunk/COPYING
      - copied unchanged from r418, packages/nvidia-xconfig/branches/upstream/current/COPYING
    packages/nvidia-xconfig/trunk/XF86Config-parser/Merge.c
      - copied unchanged from r418, packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Merge.c
    packages/nvidia-xconfig/trunk/extract_edids.c
      - copied unchanged from r418, packages/nvidia-xconfig/branches/upstream/current/extract_edids.c
    packages/nvidia-xconfig/trunk/query_gpu_info.c
      - copied unchanged from r418, packages/nvidia-xconfig/branches/upstream/current/query_gpu_info.c
Modified:
    packages/nvidia-xconfig/trunk/Makefile
    packages/nvidia-xconfig/trunk/XF86Config-parser/DRI.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Device.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Files.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Flags.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Generate.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Input.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Keyboard.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Layout.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Makefile
    packages/nvidia-xconfig/trunk/XF86Config-parser/Module.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Monitor.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Pointer.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Read.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Scan.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Screen.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Vendor.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Video.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/Write.c
    packages/nvidia-xconfig/trunk/XF86Config-parser/configProcs.h
    packages/nvidia-xconfig/trunk/XF86Config-parser/xf86Parser.h
    packages/nvidia-xconfig/trunk/debian/changelog
    packages/nvidia-xconfig/trunk/gen-manpage-opts.c
    packages/nvidia-xconfig/trunk/lscf.c
    packages/nvidia-xconfig/trunk/make_usable.c
    packages/nvidia-xconfig/trunk/multiple_screens.c
    packages/nvidia-xconfig/trunk/nvgetopt.c
    packages/nvidia-xconfig/trunk/nvgetopt.h
    packages/nvidia-xconfig/trunk/nvidia-cfg.h
    packages/nvidia-xconfig/trunk/nvidia-xconfig.1.m4
    packages/nvidia-xconfig/trunk/nvidia-xconfig.c
    packages/nvidia-xconfig/trunk/nvidia-xconfig.h
    packages/nvidia-xconfig/trunk/option_table.h
    packages/nvidia-xconfig/trunk/options.c
    packages/nvidia-xconfig/trunk/tree.c
    packages/nvidia-xconfig/trunk/util.c

Modified: packages/nvidia-xconfig/trunk/Makefile
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/Makefile?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/Makefile (original)
+++ packages/nvidia-xconfig/trunk/Makefile Tue Jun 24 17:53:25 2008
@@ -100,6 +100,7 @@
 NVIDIA_XCONFIG_DISTDIR = $(NVIDIA_XCONFIG)-$(NVIDIA_XCONFIG_VERSION)
 
 EXTRA_DIST = \
+	COPYING \
 	nvgetopt.h \
 	nvidia-xconfig.h \
 	nvidia-cfg.h \
@@ -122,7 +123,9 @@
 	tree.c			\
 	nvgetopt.c		\
 	options.c		\
-        lscf.c
+	lscf.c			\
+	query_gpu_info.c        \
+	extract_edids.c
 
 ALL_SRC = $(SRC) $(STAMP_C)
 

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/DRI.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/DRI.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/DRI.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/DRI.c Tue Jun 24 17:53:25 2008
@@ -65,10 +65,6 @@
         xconfigUnGetToken(token);
     }
 
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Buffers parsed\n");
-#endif
-
     return ptr;
 }
 
@@ -115,11 +111,7 @@
         break;
         }
     }
-    
-#ifdef DEBUG
-    ErrorF("DRI section parsed\n");
-#endif
-    
+
     return ptr;
 }
 

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Device.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Device.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Device.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Device.c Tue Jun 24 17:53:25 2008
@@ -254,10 +254,6 @@
 
     if (!has_ident)
         Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Device section parsed\n");
-#endif
 
     return ptr;
 }

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Files.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Files.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Files.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Files.c Tue Jun 24 17:53:25 2008
@@ -54,6 +54,8 @@
 
 
 /* View/edit this file with tab stops set to 4 */
+
+#include <strings.h>
 
 #include "xf86Parser.h"
 #include "xf86tokens.h"
@@ -196,10 +198,6 @@
         }
     }
 
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "File section parsed\n");
-#endif
-
     return ptr;
 }
 

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Flags.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Flags.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Flags.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Flags.c Tue Jun 24 17:53:25 2008
@@ -123,30 +123,26 @@
                 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++;
                 }
@@ -165,10 +161,6 @@
         }
     }
 
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Flags section parsed\n");
-#endif
-
     return ptr;
 }
 
@@ -189,8 +181,8 @@
     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;
 
@@ -200,12 +192,11 @@
         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,
@@ -214,12 +205,6 @@
         return head;
 }
 
-XConfigOptionPtr
-xconfigAddNewOption (XConfigOptionPtr head, char *name, char *val)
-{
-    return addNewOption2(head, name, val, 0);
-}
-
 void
 xconfigFreeFlags (XConfigFlagsPtr flags)
 {
@@ -237,11 +222,8 @@
 
     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;
@@ -280,7 +262,7 @@
 }
 
 XConfigOptionPtr
-xconfigNewOption(char *name, char *value)
+xconfigNewOption(const char *name, const char *value)
 {
     XConfigOptionPtr opt;
 
@@ -288,10 +270,9 @@
     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;
 }
@@ -368,37 +349,28 @@
     return (NULL);
 }
 
-XConfigOptionPtr
-xconfigOptionListCreate( const char **options, int count, int used )
-{
-    XConfigOptionPtr p = NULL;
-    char *t1, *t2;
-    int i;
-
-    if (count == -1)
+/*
+ * this function searches the given option list for the named option. If
+ * found and the the value of the option is set to "1", "ON", "YES" or
+ * "TRUE", 1 is returned.  Otherwise, 0 is returned.
+ */
+
+int
+xconfigFindOptionBoolean (XConfigOptionPtr list, const char *name)
+{
+    XConfigOptionPtr p = xconfigFindOption (list, name);
+
+    if (p && p->val)
     {
-        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);
+        if ( strcasecmp(p->val, "1")    == 0 ||
+             strcasecmp(p->val, "ON")   == 0 ||
+             strcasecmp(p->val, "YES")  == 0 ||
+             strcasecmp(p->val, "TRUE") == 0 )
+        {
+            return 1;
+        }
+    }
+    return 0;
 }
 
 /* the 2 given lists are merged. If an option with the same name is present in
@@ -465,16 +437,6 @@
     return s;
 }
 
-void
-xconfigDebugListOptions(XConfigOptionPtr Options)
-{
-    while (Options) {
-        xconfigErrorMsg(DebugMsg, "Option: %s Value: %s\n",
-                     Options->name, Options->val);
-        Options = Options->next;
-    }
-}
-
 XConfigOptionPtr
 xconfigParseOption(XConfigOptionPtr head)
 {

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Generate.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Generate.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Generate.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Generate.c Tue Jun 24 17:53:25 2008
@@ -52,20 +52,13 @@
 static void add_font_path(GenerateOptions *gop, XConfigPtr config);
 static void add_modules(GenerateOptions *gop, XConfigPtr config);
 
-static XConfigMonitorPtr
-add_monitor(XConfigPtr config, int count);
-
 static XConfigDevicePtr
 add_device(XConfigPtr config, int bus, int slot, char *boardname, int count);
 
-static XConfigDisplayPtr add_display(int depth);
 static void add_layout(GenerateOptions *gop, XConfigPtr config);
 
 static void add_inputref(XConfigPtr config, XConfigLayoutPtr layout,
                          char *name, char *coreKeyword);
-
-static int add_keyboard(GenerateOptions *gop, XConfigPtr config);
-static int add_mouse(GenerateOptions *gop, XConfigPtr config);
 
 /*
  * xconfigGenerate() - generate a new XConfig from scratch
@@ -85,8 +78,8 @@
 
     /* add the keyboard and mouse */
 
-    add_keyboard(gop, config);
-    add_mouse(gop, config);
+    xconfigAddKeyboard(gop, config);
+    xconfigAddMouse(gop, config);
 
     /* add the layout */
 
@@ -114,7 +107,7 @@
     XConfigDevicePtr device;
     XConfigMonitorPtr monitor;
     
-    monitor = add_monitor(config, count);
+    monitor = xconfigAddMonitor(config, count);
     device = add_device(config, bus, slot, boardname, count);
     
     screen = xconfigAlloc(sizeof(XConfigScreenRec));
@@ -130,7 +123,8 @@
         
     screen->defaultdepth = 24;
     
-    screen->displays = add_display(screen->defaultdepth);
+    screen->displays = xconfigAddDisplay(screen->displays,
+                                         screen->defaultdepth);
 
     /* append to the end of the screen list */
     
@@ -199,6 +193,66 @@
 } /* is_file() */
 
 
+/*
+ * find_libdir() - attempt to find the X server library path; this is
+ * either
+ *
+ *     `pkg-config --variable=libdir xorg-server`
+ *
+ * or
+ *
+ *     [X PROJECT ROOT]/lib
+ */
+
+static char *find_libdir(GenerateOptions *gop)
+{
+    struct stat stat_buf;
+    FILE *stream = NULL;
+    char *s, *libdir = NULL;
+    
+    /*
+     * run the pkg-config command and read the output; if the output
+     * is a directory, then return that as the libdir
+     */
+    
+    stream = popen("pkg-config --variable=libdir xorg-server", "r");
+    
+    if (stream) {
+        char buf[256];
+
+        buf[0] = '\0';
+
+        while (1) {
+            if (fgets(buf, 255, stream) == NULL) break;
+            
+            if (buf[0] != '\0') {
+
+                /* truncate any newline */
+                
+                s = strchr(buf, '\n');
+                if (s) *s = '\0';
+
+                if ((stat(buf, &stat_buf) == 0) &&
+                    (S_ISDIR(stat_buf.st_mode))) {
+                
+                    libdir = xconfigStrdup(buf);
+                    break;
+                }
+            }
+        }
+        
+        pclose(stream);
+
+        if (libdir) return libdir;
+    }
+
+    /* otherwise, just fallback to [X PROJECT ROOT]/lib */
+
+    return xconfigStrcat(gop->x_project_root, "/lib", NULL);
+    
+} /* find_libdir() */
+
+
 
 /*
  * add_files() - 
@@ -206,9 +260,13 @@
 
 static void add_files(GenerateOptions *gop, XConfigPtr config)
 {
+    char *libdir = find_libdir(gop);
+
     config->files = xconfigAlloc(sizeof(XConfigFilesRec));
-    config->files->rgbpath = xconfigStrcat(gop->x_project_root,
-                                      "/lib/X11/rgb", NULL);
+    config->files->rgbpath = xconfigStrcat(libdir, "/X11/rgb", NULL);
+    
+    free(libdir);
+
 } /* add_files() */
 
 
@@ -222,7 +280,7 @@
 static void add_font_path(GenerateOptions *gop, XConfigPtr config)
 {
     int i, ret;
-    char *path, *p, *orig, *fonts_dir;
+    char *path, *p, *orig, *fonts_dir, *libdir;
     
     /*
      * The below font path has been constructed from various examples
@@ -230,19 +288,22 @@
      */
     
     static const char *__font_paths[] = {
-        "ROOT/lib/X11/fonts/local/",
-        "ROOT/lib/X11/fonts/misc/:unscaled",
-        "ROOT/lib/X11/fonts/100dpi/:unscaled",
-        "ROOT/lib/X11/fonts/75dpi/:unscaled",
-        "ROOT/lib/X11/fonts/misc/",
-        "ROOT/lib/X11/fonts/Type1/",
-        "ROOT/lib/X11/fonts/CID/",
-        "ROOT/lib/X11/fonts/Speedo/",
-        "ROOT/lib/X11/fonts/100dpi/",
-        "ROOT/lib/X11/fonts/75dpi/",
-        "ROOT/lib/X11/fonts/cyrillic/",
-        "ROOT/lib/X11/fonts/TTF/",
-        "ROOT/lib/X11/fonts/truetype/",
+        "LIBDIR/X11/fonts/local/",
+        "LIBDIR/X11/fonts/misc/:unscaled",
+        "LIBDIR/X11/fonts/100dpi/:unscaled",
+        "LIBDIR/X11/fonts/75dpi/:unscaled",
+        "LIBDIR/X11/fonts/misc/",
+        "LIBDIR/X11/fonts/Type1/",
+        "LIBDIR/X11/fonts/CID/",
+        "LIBDIR/X11/fonts/Speedo/",
+        "LIBDIR/X11/fonts/100dpi/",
+        "LIBDIR/X11/fonts/75dpi/",
+        "LIBDIR/X11/fonts/cyrillic/",
+        "LIBDIR/X11/fonts/TTF/",
+        "LIBDIR/X11/fonts/truetype/",
+        "LIBDIR/X11/fonts/TrueType/",
+        "LIBDIR/X11/fonts/Type1/sun/",
+        "LIBDIR/X11/fonts/F3bitmaps/",
         "/usr/local/share/fonts/ttfonts",
         "/usr/share/fonts/default/Type1",
         "/usr/lib/openoffice/share/fonts/truetype",
@@ -262,15 +323,20 @@
     ret = system("ps -C xfs 2>&1 > /dev/null");
 #endif
     if (WEXITSTATUS(ret) == 0) {
-        config->files->fontpath = "unix/:7100";
+        config->files->fontpath = xconfigStrdup("unix/:7100");
     } else {
+
+        /* get the X server libdir */
+
+        libdir = find_libdir(gop);
+        
         for (i = 0; __font_paths[i]; i++) {
             path = xconfigStrdup(__font_paths[i]);
 
-            /* replace ROOT with the project root */
-
-            if (strncmp(path, "ROOT", 4) == 0) {
-                p = xconfigStrcat(gop->x_project_root, path + 4, NULL);
+            /* replace LIBDIR with libdir */
+
+            if (strncmp(path, "LIBDIR", 6) == 0) {
+                p = xconfigStrcat(libdir, path + 6, NULL);
                 free(path);
                 path = p;
             }
@@ -309,6 +375,10 @@
                 config->files->fontpath = path;
             }
         }
+
+        /* free the libdir string */
+
+        free(libdir);
     }
 } /* add_font_path() */
 
@@ -324,25 +394,25 @@
 
     config->modules = xconfigAlloc(sizeof(XConfigModuleRec));
     
-    l = xconfigAddNewLoadDirective(l, "dbe", XCONFIG_LOAD_MODULE,
-                                   NULL, FALSE);
-    l = xconfigAddNewLoadDirective(l, "extmod", XCONFIG_LOAD_MODULE,
-                                   NULL, FALSE);
-    l = xconfigAddNewLoadDirective(l, "type1", XCONFIG_LOAD_MODULE,
-                                   NULL, FALSE);
+    l = xconfigAddNewLoadDirective(l, xconfigStrdup("dbe"),
+                                   XCONFIG_LOAD_MODULE, NULL, FALSE);
+    l = xconfigAddNewLoadDirective(l, xconfigStrdup("extmod"),
+                                   XCONFIG_LOAD_MODULE, NULL, FALSE);
+    l = xconfigAddNewLoadDirective(l, xconfigStrdup("type1"),
+                                   XCONFIG_LOAD_MODULE, NULL, FALSE);
 #if defined(NV_SUNOS)
-    l = xconfigAddNewLoadDirective(l, "IA", XCONFIG_LOAD_MODULE,
-                                   NULL, FALSE);
-    l = xconfigAddNewLoadDirective(l, "Xst", XCONFIG_LOAD_MODULE,
-                                   NULL, FALSE);
-    l = xconfigAddNewLoadDirective(l, "bitstream", XCONFIG_LOAD_MODULE,
-                                   NULL, FALSE);
+    l = xconfigAddNewLoadDirective(l, xconfigStrdup("IA"),
+                                   XCONFIG_LOAD_MODULE, NULL, FALSE);
+    l = xconfigAddNewLoadDirective(l, xconfigStrdup("bitstream"),
+                                   XCONFIG_LOAD_MODULE, NULL, FALSE);
+    l = xconfigAddNewLoadDirective(l, xconfigStrdup("xtsol"),
+                                   XCONFIG_LOAD_MODULE, NULL, FALSE);
 #else
-    l = xconfigAddNewLoadDirective(l, "freetype", XCONFIG_LOAD_MODULE,
-                                   NULL, FALSE);
+    l = xconfigAddNewLoadDirective(l, xconfigStrdup("freetype"),
+                                   XCONFIG_LOAD_MODULE, NULL, FALSE);
 #endif
-    l = xconfigAddNewLoadDirective(l, "glx", XCONFIG_LOAD_MODULE,
-                                   NULL, FALSE);
+    l = xconfigAddNewLoadDirective(l, xconfigStrdup("glx"),
+                                   XCONFIG_LOAD_MODULE, NULL, FALSE);
     
     config->modules->loads = l;
     
@@ -351,13 +421,12 @@
 
 
 /*
- * add_monitor() -
+ * xconfigAddMonitor() -
  *
  * XXX pass EDID values into this...
  */
 
-static XConfigMonitorPtr
-add_monitor(XConfigPtr config, int count)
+XConfigMonitorPtr xconfigAddMonitor(XConfigPtr config, int count)
 {
     XConfigMonitorPtr monitor, m;
     XConfigOptionPtr opt = NULL;
@@ -368,8 +437,8 @@
     
     monitor->identifier = xconfigAlloc(32);
     snprintf(monitor->identifier, 32, MONITOR_IDENTIFIER, count);
-    monitor->vendor = "Unknown";  /* XXX */
-    monitor->modelname = "Unknown"; /* XXX */
+    monitor->vendor = xconfigStrdup("Unknown");  /* XXX */
+    monitor->modelname = xconfigStrdup("Unknown"); /* XXX */
     
     /* XXX check EDID for freq ranges */
 
@@ -381,7 +450,7 @@
     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;
 
@@ -396,7 +465,7 @@
     
     return monitor;
    
-} /* add_monitor() */
+} /* xconfigAddMonitor() */
 
 
 
@@ -443,24 +512,19 @@
 
 
 
-static XConfigDisplayPtr add_display(int depth)
+XConfigDisplayPtr xconfigAddDisplay(XConfigDisplayPtr head, const int depth)
 {
     XConfigDisplayPtr display;
-    XConfigModePtr mode = NULL;
-    
-    mode = xconfigAddMode(mode, "640x480");
-    mode = xconfigAddMode(mode, "800x600");
-    mode = xconfigAddMode(mode, "1024x768");
-    mode = xconfigAddMode(mode, "1280x1024");
-    mode = xconfigAddMode(mode, "1600x1200");
-    
+
     display = xconfigAlloc(sizeof(XConfigDisplayRec));
     display->depth = depth;
-    display->modes = mode;
+    display->modes = NULL;
     display->frameX0 = -1;
     display->frameY0 = -1;
     display->black.red = -1;
     display->white.red = -1;
+
+    display->next = head;
     
     return display;
 }
@@ -485,7 +549,7 @@
 
     layout = xconfigAlloc(sizeof(XConfigLayoutRec));
     
-    layout->identifier = "Layout0";
+    layout->identifier = xconfigStrdup("Layout0");
     
     adj = xconfigAlloc(sizeof(XConfigAdjacencyRec));
 
@@ -517,10 +581,10 @@
     XConfigInputrefPtr inputRef;
 
     inputRef = xconfigAlloc(sizeof(XConfigInputrefRec));
-    inputRef->input_name = name;
+    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;
 
@@ -744,6 +808,7 @@
     int fd = -1;
     char *data = NULL;
     char *value = NULL;
+    char *buf = NULL;
     char *tmp, *start, *c, *end;
     struct stat stat_buf;
     size_t len;
@@ -755,9 +820,21 @@
     if ((data = mmap(0, stat_buf.st_size, PROT_READ, MAP_SHARED,
                      fd, 0)) == (void *) -1) goto done;
     
+    /*
+     * create a sysmem copy of the buffer, so that we can explicitly
+     * NULL terminate it
+     */
+
+    buf = malloc(stat_buf.st_size + 1);
+
+    if (!buf) goto done;
+
+    memcpy(buf, data, stat_buf.st_size);
+    buf[stat_buf.st_size] = '\0';
+    
     /* search for the keyword */
     
-    start = data;
+    start = buf;
 
     while (TRUE) {
         tmp = strstr(start, keyword);
@@ -808,6 +885,7 @@
     
  done:
 
+    if (buf) free(buf);
     if (data) munmap(data, stat_buf.st_size);
     if (fd != -1) close(fd);
 
@@ -838,7 +916,7 @@
 
 
 /*
- * add_mouse() - determine the mouse type, and then add an
+ * xconfigAddMouse() - determine the mouse type, and then add an
  * XConfigInputRec with the appropriate options.
  *
  * - if the user specified on the commandline, use that
@@ -853,7 +931,7 @@
  * - default to "auto" on /dev/mouse
  */
 
-static int add_mouse(GenerateOptions *gop, XConfigPtr config)
+int xconfigAddMouse(GenerateOptions *gop, XConfigPtr config)
 {
     const MouseEntry *entry = NULL;
     XConfigInputPtr input;
@@ -928,6 +1006,9 @@
         MouseEntry *e = xconfigAlloc(sizeof(MouseEntry));
         e->Xproto = "auto";
 
+#if defined(NV_BSD)
+        e->device = "sysmouse";
+#else
         if (access("/dev/psaux", F_OK) == 0) {
             e->device = "psaux";
         } else if (access("/dev/input/mice", F_OK) == 0) {
@@ -935,7 +1016,7 @@
         } else {
             e->device = "mouse";
         }
-        
+#endif
         e->emulate3 = FALSE;
         entry = e;
     }
@@ -946,16 +1027,17 @@
     
     input->comment = xconfigStrcat("    # generated from ",
                                    comment, "\n", NULL);
-    input->identifier = "Mouse0";
-    input->driver = "mouse";
+    input->identifier = xconfigStrdup("Mouse0");
+    input->driver = xconfigStrdup("mouse");
 
     device_path = xconfigStrcat("/dev/", entry->device, NULL);
 
-    opt = xconfigAddNewOption(opt, xconfigStrdup("Protocol"), 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
@@ -971,7 +1053,7 @@
     
     return TRUE;
     
-} /* add_mouse() */
+} /* xconfigAddMouse() */
 
 
 
@@ -1131,7 +1213,7 @@
 
 
 /*
- * add_keyboard() - determine the keyboard type, and then add an
+ * xconfigAddKeyboard() - determine the keyboard type, and then add an
  * XConfigInputRec with the appropriate options.
  *
  * How to detect the keyboard:
@@ -1142,7 +1224,7 @@
  *   KEYTABLE entry, use that
  */
 
-static int add_keyboard(GenerateOptions *gop, XConfigPtr config)
+int xconfigAddKeyboard(GenerateOptions *gop, XConfigPtr config)
 {
     char *value, *comment = "default";
     const KeyboardEntry *entry = NULL;
@@ -1153,7 +1235,7 @@
     /*
      * if the user specified on the command line, use that
      */
-
+    
     if (gop->keyboard) {
         entry = find_keyboard_entry(gop->keyboard);
         if (entry) {
@@ -1186,7 +1268,7 @@
     
     input->comment = xconfigStrcat("    # generated from ",
                                    comment, "\n", NULL);
-    input->identifier = "Keyboard0";
+    input->identifier = xconfigStrdup("Keyboard0");
 
     /*
      * determine which keyboard driver should be used (either "kbd" or
@@ -1200,12 +1282,12 @@
         input->driver = gop->keyboard_driver;
     } else {
 #if defined(NV_SUNOS) || defined(NV_BSD)
-        input->driver = "keyboard";
+        input->driver = xconfigStrdup("keyboard");
 #else
         if (gop->xserver == X_IS_XORG) {
-            input->driver = "kbd";
+            input->driver = xconfigStrdup("kbd");
         } else {
-            input->driver = "keyboard";
+            input->driver = xconfigStrdup("keyboard");
         }
 #endif
     }
@@ -1216,17 +1298,13 @@
      */
 
     if (entry && entry->layout)
-        opt = xconfigAddNewOption(opt,
-                                  xconfigStrdup("XkbLayout"), entry->layout);
+        opt = xconfigAddNewOption(opt, "XkbLayout", entry->layout);
     if (entry && entry->model)
-        opt = xconfigAddNewOption(opt,
-                                  xconfigStrdup("XkbModel"), entry->model);
+        opt = xconfigAddNewOption(opt, "XkbModel", entry->model);
     if (entry && entry->variant)
-        opt = xconfigAddNewOption(opt,
-                                  xconfigStrdup("XkbVariant"), entry->variant);
+        opt = xconfigAddNewOption(opt, "XkbVariant", entry->variant);
     if (entry && entry->options)
-        opt = xconfigAddNewOption(opt,
-                                  xconfigStrdup("XkbOptions"), entry->options);
+        opt = xconfigAddNewOption(opt, "XkbOptions", entry->options);
 
     input->options = opt;
     
@@ -1235,4 +1313,4 @@
 
     return TRUE;
     
-} /* add_keyboard() */
+} /* xconfigAddKeyboard() */

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Input.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Input.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Input.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Input.c Tue Jun 24 17:53:25 2008
@@ -115,10 +115,6 @@
     if (!has_ident)
         Error (NO_IDENT_MSG, NULL);
 
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "InputDevice section parsed\n");
-#endif
-
     return ptr;
 }
 
@@ -212,8 +208,10 @@
 
 
 
-static int getCoreInputDevice(XConfigPtr config,
+static int getCoreInputDevice(GenerateOptions *gop,
+                              XConfigPtr config,
                               XConfigLayoutPtr layout,
+                              const int mouse,
                               const char *coreKeyword,
                               const char *implicitDriverName,
                               const char *defaultDriver0,
@@ -223,7 +221,7 @@
 {
     XConfigInputPtr input, core = NULL;
     XConfigInputrefPtr inputRef;
-    int found;
+    int found, firstTry;
     const char *found_msg = NULL;
     
     /*
@@ -241,9 +239,9 @@
         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 =
@@ -267,13 +265,13 @@
      */
 
     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;
-	    }
-	}
+            }
+        }
     }
     
     /*
@@ -281,18 +279,44 @@
      * first input with the correct driver
      */
     
+    firstTry = TRUE;
+
+ tryAgain:
+    
     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(defaultDriver0, config->inputs);
-        }
-	if (input) {
-	    core = input;
-	    found_msg = foundMsg1;
-	}
+            input = xconfigFindInputByDriver(defaultDriver1, config->inputs);
+        }
+        if (input) {
+            core = input;
+            found_msg = foundMsg1;
+        }
+    }
+
+    /*
+     * if we didn't find a core input device above, then that means we
+     * don't have any input devices of this type; try to add a new
+     * input device of this type, and then try again to find a core
+     * input device
+     */
+
+    if (!core && firstTry) {
+        firstTry = FALSE;
+        
+        xconfigErrorMsg(WarnMsg, "Unable to find %s in X configuration; "
+                        "attempting to add new %s section.",
+                        coreKeyword, coreKeyword);
+        
+        if (mouse) {
+            xconfigAddMouse(gop, config);
+        } else {
+            xconfigAddKeyboard(gop, config);
+        }
+        goto tryAgain;
     }
     
     /*
@@ -344,8 +368,7 @@
 
             if (!opt1 && !opt2) {
                 inputRef->options = xconfigAddNewOption(inputRef->options,
-                                                     strdup(coreKeyword),
-                                                     NULL);
+                                                        coreKeyword, NULL);
             }
             break;
         }
@@ -367,13 +390,16 @@
  * be added from the current list of input devices.
  */
 
-int xconfigCheckCoreInputDevices(XConfigPtr config,
+int xconfigCheckCoreInputDevices(GenerateOptions *gop,
+                                 XConfigPtr config,
                                  XConfigLayoutPtr layout)
 {
     int ret;
 
-    ret = getCoreInputDevice(config,
+    ret = getCoreInputDevice(gop,
+                             config,
                              layout,
+                             TRUE,
                              "CorePointer",
                              CONF_IMPLICIT_POINTER,
                              "mouse", NULL,
@@ -382,8 +408,10 @@
     
     if (!ret) return FALSE;
 
-    ret = getCoreInputDevice(config,
+    ret = getCoreInputDevice(gop,
+                             config,
                              layout,
+                             FALSE,
                              "CoreKeyboard",
                              CONF_IMPLICIT_KEYBOARD,
                              "keyboard", "kbd",

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Keyboard.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Keyboard.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Keyboard.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Keyboard.c Tue Jun 24 17:53:25 2008
@@ -299,10 +299,6 @@
     ptr->options = xconfigAddNewOption(ptr->options,
                                        xconfigStrdup("CoreKeyboard"), NULL);
     
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Keyboard section parsed\n");
-#endif
-    
     return ptr;
 }
 

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Layout.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Layout.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Layout.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Layout.c Tue Jun 24 17:53:25 2008
@@ -281,10 +281,6 @@
     if (!has_ident)
         Error (NO_IDENT_MSG, NULL);
 
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Layout section parsed\n");
-#endif
-
     return ptr;
 }
 
@@ -431,19 +427,22 @@
 }
 
 int
-xconfigValidateLayout (XConfigPtr p, const char *screenName)
+xconfigValidateLayout (XConfigPtr p)
 {
     XConfigLayoutPtr layout = p->layouts;
     XConfigAdjacencyPtr adj;
     XConfigInactivePtr iptr;
-    XConfigInputrefPtr inptr;
+    XConfigInputrefPtr inputRef;
     XConfigScreenPtr screen;
     XConfigDevicePtr device;
     XConfigInputPtr input;
 
-    if (!layout) {
-        if (!addImpliedLayout(p, screenName)) return FALSE;
-    }
+    /*
+     * if we do not have a layout, just return TRUE; we'll add a
+     * layout later during the Sanitize step
+     */
+
+    if (!layout) return TRUE;
 
     while (layout)
     {
@@ -470,6 +469,9 @@
 
             adj = adj->next;
         }
+
+        /* I not believe the "inactives" list is used for anything */
+        
         iptr = layout->inactives;
         while (iptr)
         {
@@ -485,25 +487,58 @@
                 iptr->device = device;
             iptr = iptr->next;
         }
-        inptr = layout->inputs;
-        while (inptr)
+
+        /*
+         * the layout->inputs list is also updated in
+         * getCoreInputDevice() when no core input device is found in
+         * the layout's input list
+         */
+
+        inputRef = layout->inputs;
+        while (inputRef)
         {
-            input = xconfigFindInput (inptr->input_name,
+            input = xconfigFindInput (inputRef->input_name,
                                    p->inputs);
             if (!input)
             {
                 xconfigErrorMsg(ValidationErrorMsg, UNDEFINED_INPUT_MSG,
-                             inptr->input_name, layout->identifier);
+                             inputRef->input_name, layout->identifier);
                 return (FALSE);
             }
             else {
-                inptr->input = input;
-            }
-            inptr = inptr->next;
+                inputRef->input = input;
+            }
+            inputRef = inputRef->next;
         }
         layout = layout->next;
     }
     return (TRUE);
+}
+
+int
+xconfigSanitizeLayout(XConfigPtr p,
+                      const char *screenName,
+                      GenerateOptions *gop)
+{
+    XConfigLayoutPtr layout = p->layouts;
+    
+    /* add an implicit layout if none exist */
+
+    if (!p->layouts) {
+        if (!addImpliedLayout(p, screenName)) {
+            return FALSE;
+        }
+    }
+
+    /* check that input devices are assigned for each layout */
+    
+    for (layout = p->layouts; layout; layout = layout->next) {
+        if (!xconfigCheckCoreInputDevices(gop, p, layout)) {
+            return FALSE;
+        }
+    }
+
+    return TRUE;
 }
 
 XConfigLayoutPtr
@@ -535,12 +570,12 @@
      */
     
     if (screenName) {
-	screen = xconfigFindScreen(screenName, config->screens);
+        screen = xconfigFindScreen(screenName, config->screens);
         if (!screen) {
             xconfigErrorMsg(ErrorMsg, "No Screen section called \"%s\"\n",
                             screenName);
-	    return FALSE;
-	}
+            return FALSE;
+        }
     } else {
         screen = config->screens;
     }
@@ -553,28 +588,20 @@
     
     layout = calloc(1, sizeof(XConfigLayoutRec));
     
-    layout->identifier = "Default Layout";
+    layout->identifier = xconfigStrdup("Default Layout");
     
     adj = calloc(1, sizeof(XConfigAdjacencyRec));
     adj->scrnum = -1;
     adj->screen = screen;
-    adj->screen_name = strdup(screen->identifier);
+    adj->screen_name = xconfigStrdup(screen->identifier);
     
     layout->adjacencies = adj;
 
     config->layouts = layout;
-
-    /*
-     * xconfigCheckCoreInputDevices() will add a keyboard and mouse to
-     * the layout.
-     */
-
-    if (!xconfigCheckCoreInputDevices(config, layout)) {
-        free(adj);
-        free(layout);
-        config->layouts = NULL;
-        return FALSE;
-    }
-    
+    
+    /* validate the Layout here to setup all the pointers */
+
+    if (!xconfigValidateLayout(config)) return FALSE;
+
     return TRUE;
 }

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Makefile
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Makefile?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Makefile (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Makefile Tue Jun 24 17:53:25 2008
@@ -1,24 +1,31 @@
-SRC =	DRI.c 		\
-	Device.c 	\
-	Files.c		\
-	Flags.c		\
-	Input.c		\
-	Keyboard.c	\
-	Layout.c	\
-	Module.c	\
-	Monitor.c	\
-	Pointer.c	\
-	Screen.c	\
-	Vendor.c	\
-	Video.c		\
-	Read.c		\
-	Scan.c		\
-	Write.c		\
-	Util.c		\
-	Extensions.c	\
-	Generate.c
+SRC = \
+	DRI.c \
+	Device.c \
+	Files.c \
+	Flags.c \
+	Input.c \
+	Keyboard.c \
+	Layout.c \
+	Module.c \
+	Monitor.c \
+	Pointer.c \
+	Screen.c \
+	Vendor.c \
+	Video.c \
+	Read.c \
+	Scan.c \
+	Write.c \
+	Util.c \
+	Extensions.c \
+	Generate.c \
+	Merge.c
 
-OBJS = $(SRC:.c=.o)
+OBJS = $(SRC:%.c=%.o)
+DEPS = $(SRC:%.c=%.d)
+
+ifndef CC
+  CC = gcc
+endif
 
 CFLAGS = -Wall -g
 
@@ -26,13 +33,21 @@
   CFLAGS += $(NV_CFLAGS)
 endif
 
+ifndef RANLIB
+  RANLIB = ranlib
+endif
+
 LIB = libXF86Config-parser.a
-LIB_O = $(LIB:.a=.o)
+LIB_O = $(LIB:%.a=%.o)
+
+default all: $(LIB)
+
+.PHONY: clean clobber
 
 $(LIB): $(OBJS)
 	$(LD) -r -o $(LIB_O) $(OBJS)
 	$(AR) ruv $(LIB) $(LIB_O)
-	ranlib $(LIB)
+	$(RANLIB) $(LIB)
 
 %.o: %.c
 	$(CC) -c $(CFLAGS) $< -o $@
@@ -45,4 +60,4 @@
 clean clobber:
 	rm -rf *.o *~ *.d $(LIB) $(LIB_O)
 
--include $(SRC:.c=.d)
+-include $(DEPS)

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Module.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Module.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Module.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Module.c Tue Jun 24 17:53:25 2008
@@ -159,10 +159,6 @@
             break;
         }
     }
-
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Module section parsed\n");
-#endif
 
     return ptr;
 }

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Monitor.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Monitor.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Monitor.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Monitor.c Tue Jun 24 17:53:25 2008
@@ -132,9 +132,9 @@
     ptr->identifier = val.str;
 
     /* DotClock */
-    if (xconfigGetSubToken (&(ptr->comment)) != NUMBER)
+    if ((xconfigGetSubToken (&(ptr->comment)) != NUMBER) || !val.str)
         Error ("ModeLine dotclock expected", NULL);
-    ptr->clock = (int) (val.realnum * 1000.0 + 0.5);
+    ptr->clock = xconfigStrdup(val.str);
 
     /* HDisplay */
     if (xconfigGetSubToken (&(ptr->comment)) != NUMBER)
@@ -243,9 +243,6 @@
     }
     xconfigUnGetToken (token);
 
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "ModeLine parsed\n");
-#endif
     return (ptr);
 }
 
@@ -267,9 +264,9 @@
             ptr->comment = xconfigAddComment(ptr->comment, val.str);
             break;
         case DOTCLOCK:
-            if ((token = xconfigGetSubToken (&(ptr->comment))) != NUMBER)
+            if ((xconfigGetSubToken (&(ptr->comment)) != NUMBER) || !val.str)
                 Error (NUMBER_MSG, "DotClock");
-            ptr->clock = (int) (val.realnum * 1000.0 + 0.5);
+            ptr->clock = xconfigStrdup(val.str);
             had_dotclock = 1;
             break;
         case HTIMINGS:
@@ -392,9 +389,6 @@
     if (!had_vtimings)
         Error ("the vertical timings are missing", NULL);
 
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Verbose Mode parsed\n");
-#endif
     return (ptr);
 }
 
@@ -586,9 +580,6 @@
     if (!has_ident)
         Error (NO_IDENT_MSG, NULL);
 
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Monitor section parsed\n");
-#endif
     return ptr;
 }
 
@@ -637,9 +628,6 @@
     if (!has_ident)
         Error (NO_IDENT_MSG, NULL);
 
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Modes section parsed\n");
-#endif
     return ptr;
 }
 
@@ -680,9 +668,14 @@
         }
         for (i = 0; i < ptr->n_vrefresh; i++)
         {
-            fprintf (cf, "    VertRefresh     %2.1f - %2.1f\n",
-                     ptr->vrefresh[i].lo,
-                     ptr->vrefresh[i].hi);
+            if (ptr->vrefresh[i].lo == ptr->vrefresh[i].hi) {
+                fprintf (cf, "    VertRefresh     %2.1f\n",
+                         ptr->vrefresh[i].lo);
+            } else {
+                fprintf (cf, "    VertRefresh     %2.1f - %2.1f\n",
+                         ptr->vrefresh[i].lo,
+                         ptr->vrefresh[i].hi);
+            }
         }
         if (ptr->gamma_red) {
             if (ptr->gamma_red == ptr->gamma_green
@@ -699,8 +692,8 @@
         }
         for (mlptr = ptr->modelines; mlptr; mlptr = mlptr->next)
         {
-            fprintf (cf, "    ModeLine       \"%s\" %2.1f ",
-                     mlptr->identifier, mlptr->clock / 1000.0);
+            fprintf (cf, "    ModeLine       \"%s\" %s ",
+                     mlptr->identifier, mlptr->clock);
             fprintf (cf, "%d %d %d %d %d %d %d %d",
                      mlptr->hdisplay, mlptr->hsyncstart,
                      mlptr->hsyncend, mlptr->htotal,
@@ -750,8 +743,8 @@
             fprintf (cf, "    Identifier         \"%s\"\n", ptr->identifier);
         for (mlptr = ptr->modelines; mlptr; mlptr = mlptr->next)
         {
-            fprintf (cf, "    ModeLine     \"%s\" %2.1f ",
-                     mlptr->identifier, mlptr->clock / 1000.0);
+            fprintf (cf, "    ModeLine     \"%s\" %s ",
+                     mlptr->identifier, mlptr->clock);
             fprintf (cf, "%d %d %d %d %d %d %d %d",
                      mlptr->hdisplay, mlptr->hsyncstart,
                      mlptr->hsyncend, mlptr->htotal,
@@ -834,6 +827,21 @@
     {
         TEST_FREE (ptr->identifier);
         TEST_FREE (ptr->comment);
+        TEST_FREE (ptr->clock);
+        prev = ptr;
+        ptr = ptr->next;
+        free (prev);
+    }
+}
+
+void
+xconfigFreeModesLinkList (XConfigModesLinkPtr ptr)
+{
+    XConfigModesLinkPtr prev;
+
+    while (ptr)
+    {
+        TEST_FREE (ptr->modes_name);
         prev = ptr;
         ptr = ptr->next;
         free (prev);

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Pointer.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Pointer.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Pointer.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Pointer.c Tue Jun 24 17:53:25 2008
@@ -111,76 +111,68 @@
             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 @@
                 break;
             }
             ptr->options =
-                xconfigAddNewOption(ptr->options,
-                                    xconfigStrdup("ZAxisMapping"),
-                                    s);
+                xconfigAddNewOption(ptr->options, "ZAxisMapping", s);
+            TEST_FREE(s);
             break;
         case ALWAYSCORE:
             break;
@@ -226,12 +217,7 @@
 
     ptr->identifier = xconfigStrdup(CONF_IMPLICIT_POINTER);
     ptr->driver = xconfigStrdup("mouse");
-    ptr->options = xconfigAddNewOption(ptr->options,
-                                       xconfigStrdup("CorePointer"), NULL);
-
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Pointer section parsed\n");
-#endif
+    ptr->options = xconfigAddNewOption(ptr->options, "CorePointer", NULL);
 
     return ptr;
 }

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Read.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Read.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Read.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Read.c Tue Jun 24 17:53:25 2008
@@ -98,12 +98,10 @@
 
 /*
  * xconfigReadConfigFile() - read the open XConfig file, returning the
- * parsed data as XConfigPtr.  The screenName argument is used
- * during validation in the case that no layout was specified and we
- * have to build an implicit layout and need to choose a screen.
- */
-
-XConfigError xconfigReadConfigFile(const char *screenName, XConfigPtr *configPtr)
+ * parsed data as XConfigPtr.
+ */
+
+XConfigError xconfigReadConfigFile(XConfigPtr *configPtr)
 {
     int token;
     XConfigPtr ptr = NULL;
@@ -245,7 +243,7 @@
         }
     }
 
-    if (xconfigValidateConfig(ptr, screenName)) {
+    if (xconfigValidateConfig(ptr)) {
         ptr->filename = strdup(xconfigGetConfigFileName());
         *configPtr = ptr;
         return XCONFIG_RETURN_SUCCESS;
@@ -263,7 +261,7 @@
  * objects cannot be found.
  */
 
-int xconfigValidateConfig(XConfigPtr p, const char *screenName)
+int xconfigValidateConfig(XConfigPtr p)
 {
     if (!xconfigValidateDevice(p))
         return FALSE;
@@ -271,11 +269,32 @@
         return FALSE;
     if (!xconfigValidateInput(p))
         return FALSE;
-    if (!xconfigValidateLayout(p, screenName))
+    if (!xconfigValidateLayout(p))
         return FALSE;
     
     return(TRUE);
 }
+
+
+
+/*
+ * This function fixes up any problems that it finds in the config,
+ * when possible.
+ */
+
+int xconfigSanitizeConfig(XConfigPtr p,
+                          const char *screenName,
+                          GenerateOptions *gop)
+{
+    if (!xconfigSanitizeScreen(p))
+        return FALSE;
+    
+    if (!xconfigSanitizeLayout(p, screenName, gop))
+        return FALSE;
+    
+    return TRUE;
+}
+
 
 
 /* 
@@ -304,6 +323,35 @@
     else
         return (new);
 }
+
+
+/*
+ * removes an item from the linked list. Any record whose first field
+ * is a GenericListRec can be cast to this type and used with this function.
+ * A pointer to the head of the list is returned to handle the removal of
+ * the first item.
+ */
+GenericListPtr
+xconfigRemoveListItem (GenericListPtr head, GenericListPtr item)
+{
+    GenericListPtr cur = head;
+    GenericListPtr prev = NULL;
+
+    while (cur)
+    {
+        if (cur == item)
+        {
+            if (prev) prev->next = item->next;
+            if (head == item) head = item->next;
+            break;
+        }
+        prev = cur;
+        cur  = cur->next;
+    }
+    
+    return head;
+}
+
 
 /* 
  * Test if one chained list contains the other.

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Scan.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Scan.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Scan.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Scan.c Tue Jun 24 17:53:25 2008
@@ -177,10 +177,129 @@
 }
 
 
+/*
+ * xconfigGetNextLine --
+ *
+ *  read from the configFile FILE stream until we encounter a new
+ *  line; this is effectively just a big wrapper for fgets(3).
+ *
+ *  xconfigGetToken() assumes that we will read up to the next
+ *  newline; we need to grow configBuf and configRBuf as needed to
+ *  support that.
+ */
+
+static char *xconfigGetNextLine()
+{
+    static int configBufLen = CONFIG_BUF_LEN;
+    char *tmpConfigBuf, *tmpConfigRBuf;
+    int c, i, pos = 0, eolFound = 0;
+    char *ret = NULL;
+    
+    /*
+     * reallocate the string if it was grown last time (i.e., is no
+     * longer CONFIG_BUF_LEN); we malloc the new strings first, so
+     * that if either of the mallocs fail, we can fall back on the
+     * existing buffer allocations
+     */
+    
+    if (configBufLen != CONFIG_BUF_LEN) {
+                 
+        tmpConfigBuf = malloc(CONFIG_BUF_LEN);
+        tmpConfigRBuf = malloc(CONFIG_BUF_LEN);
+        
+        if (!tmpConfigBuf || !tmpConfigRBuf) {
+            
+            /*
+             * at least one of the mallocs failed; keep the old buffers
+             * and free any partial allocations
+             */
+            
+            free(tmpConfigBuf);
+            free(tmpConfigRBuf);
+            
+        } else {
+            
+            /*
+             * malloc succeeded; free the old buffers and use the new
+             * buffers
+             */
+            
+            configBufLen = CONFIG_BUF_LEN;
+            
+            free(configBuf);
+            free(configRBuf);
+            
+            configBuf = tmpConfigBuf;
+            configRBuf = tmpConfigRBuf;
+        }
+    }
+
+    /* read in another block of chars */
+    
+    do {
+        ret = fgets(configBuf + pos, configBufLen - pos - 1, configFile);
+        
+        if (!ret) break;
+        
+        /* search for EOL in the new block of chars */
+        
+        for (i = pos; i < (configBufLen - 1); i++) {
+            c = configBuf[i];
+            
+            if (c == '\0') break;
+            
+            if ((c == '\n') || (c == '\r')) {
+                eolFound = 1;
+                break;
+            }
+        }
+        
+        /*
+         * if we didn't find EOL, then grow the string and
+         * read in more
+         */
+        
+        if (!eolFound) {
+            
+            tmpConfigBuf = realloc(configBuf, configBufLen + CONFIG_BUF_LEN);
+            tmpConfigRBuf = realloc(configRBuf, configBufLen + CONFIG_BUF_LEN);
+            
+            if (!tmpConfigBuf || !tmpConfigRBuf) {
+                
+                /*
+                 * at least one of the reallocations failed; use the
+                 * new allocation that succeeded, but we have to
+                 * fallback to the previous configBufLen size and use
+                 * the string we have, even though we don't have an
+                 * EOL
+                 */
+                
+                if (tmpConfigBuf) configBuf = tmpConfigBuf;
+                if (tmpConfigRBuf) configRBuf = tmpConfigRBuf;
+                
+                break;
+                
+            } else {
+                
+                /* reallocation succeeded */
+
+                configBuf = tmpConfigBuf;
+                configRBuf = tmpConfigRBuf;
+                pos = i;
+                configBufLen += CONFIG_BUF_LEN;
+            }
+        }
+        
+    } while (!eolFound);
+    
+    return ret;
+}
+
+
 
 /* 
  * xconfigGetToken --
- *      Read next Token form the config file. Handle the global variable
+ *      Read next Token from the config file. Handle the global variable
  *      pushToken.
  */
 
@@ -214,7 +333,7 @@
         {
             char *ret;
             if (configFile)
-                ret = fgets (configBuf, CONFIG_BUF_LEN - 1, configFile);
+                ret = xconfigGetNextLine();
             else {
                 if (builtinConfig[builtinIndex] == NULL)
                     ret = NULL;
@@ -303,6 +422,7 @@
             configRBuf[i] = '\0';
             val.num = xconfigStrToUL (configRBuf);
             val.realnum = atof (configRBuf);
+            val.str = configRBuf;
             return (NUMBER);
         }
 
@@ -465,7 +585,6 @@
  *    %E    config file environment ($XF86CONFIG) as an absolute path
  *    %F    config file environment ($XF86CONFIG) as a relative path
  *    %G    config file environment ($XF86CONFIG) as a safe path
- *    %D    $HOME
  *    %P    projroot
  *    %M    major version number
  *    %%    %
@@ -521,7 +640,7 @@
 {
     char *result;
     int i, l;
-    static const char *env = NULL, *home = NULL;
+    static const char *env = NULL;
     static char *hostname = NULL;
     static char majorvers[3] = "";
 
@@ -612,14 +731,6 @@
                 } else
                     BAIL_OUT;
                 break;
-            case 'D':
-                if (!home)
-                    home = getenv("HOME");
-                if (home && pathIsAbsolute(home))
-                    APPEND_STR(home);
-                else
-                    BAIL_OUT;
-                break;
             case 'P':
                 if (projroot && pathIsAbsolute(projroot))
                     APPEND_STR(projroot);
@@ -679,7 +790,6 @@
 "%F,"               /* $XF86CONFIG (as relative path) */
 "/etc/X11/%F,"      /* /etc/X11/$XF86CONFIG */
 "%P/etc/X11/%F,"    /* /usr/X11R6/etc/X11/$XF86CONFIG */
-"%D/%X,"            /* $HOME/XF86Config */
 "/etc/X11/%X-%M,"   /* /etc/X11/XF86Config-4 */
 "/etc/X11/%X,"      /* /etc/X11/XF86Config */
 "/etc/%X,"          /* /etc/XF86Config */
@@ -736,7 +846,7 @@
     if (getuid() == 0) {
         searchpath = __root_configpath;
     } else {
-	searchpath = __user_configpath;
+        searchpath = __user_configpath;
     }
 
     if (!projroot) projroot = PROJECTROOT;
@@ -944,3 +1054,32 @@
     }
     return (c1 - c2);
 }
+
+/* 
+ * Compare two modelines.  The modeline identifiers and comments are
+ * ignored in the comparison.
+ */
+int
+xconfigModelineCompare(XConfigModeLinePtr m1, XConfigModeLinePtr m2)
+{
+    if (!m1 && !m2)
+        return (0);
+
+    if (!m1 || !m2)
+        return (1);
+
+    if (m1->clock      != m2->clock &&
+        m1->hdisplay   != m2->hdisplay &&
+        m1->hsyncstart != m2->hsyncstart &&
+        m1->hsyncend   != m2->hsyncend &&
+        m1->htotal     != m2->htotal &&
+        m1->vdisplay   != m2->vdisplay &&
+        m1->vsyncstart != m2->vsyncstart &&
+        m1->vsyncend   != m2->vsyncend &&
+        m1->vtotal     != m2->vtotal &&
+        m1->vscan      != m2->vscan &&
+        m1->flags      != m2->flags &&
+        m1->hskew      != m2->hskew)
+        return (1);
+    return (0);
+}

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Screen.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Screen.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Screen.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Screen.c Tue Jun 24 17:53:25 2008
@@ -190,10 +190,6 @@
         }
     }
 
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Display subsection parsed\n");
-#endif
-
     return ptr;
 }
 
@@ -322,10 +318,6 @@
 
     if (!has_ident && !has_driver)
         Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Screen section parsed\n");
-#endif
 
     return ptr;
 }
@@ -563,6 +555,64 @@
     return (TRUE);
 }
 
+int xconfigSanitizeScreen(XConfigPtr p)
+{
+    XConfigScreenPtr screen = p->screens;
+    XConfigMonitorPtr monitor;
+   
+    while (screen) {
+        
+        /*
+         * if no monitor for this screen (either the monitor name, or
+         * the actual monitor pointer), find a monitor: resolve
+         * discrepancies between screen->monitor_name and
+         * screen->monitor; otherwise use the first monitor in the
+         * config; if we still don't have a monitor, add a new one
+         */
+
+        if (!screen->monitor_name || !screen->monitor) {
+        
+            monitor = NULL;
+
+            if (!monitor && screen->monitor) {
+                monitor = screen->monitor;
+            }
+
+            if (!monitor && screen->monitor_name) {
+                monitor = xconfigFindMonitor(screen->monitor_name,
+                                             p->monitors);
+            }
+            
+            if (!monitor && p->monitors) {
+                monitor = p->monitors;
+            }
+
+            if (!monitor) {
+                monitor = xconfigAddMonitor(p, 0);
+            }
+            
+            if (monitor) {
+                screen->monitor = monitor;
+                
+                if (screen->monitor_name) {
+                    free(screen->monitor_name);
+                }
+                
+                screen->monitor_name = xconfigStrdup(monitor->identifier);
+                
+                if (!xconfigValidateMonitor(p, screen))
+                    return (FALSE);
+            }
+        }
+        
+        screen = screen->next;        
+    }
+    
+    return TRUE;
+}
+
+
+
 XConfigScreenPtr
 xconfigFindScreen (const char *ident, XConfigScreenPtr p)
 {
@@ -576,6 +626,18 @@
     return (NULL);
 }
 
+XConfigModePtr
+xconfigFindMode (const char *name, XConfigModePtr p)
+{
+    while (p)
+    {
+        if (xconfigNameCompare (name, p->mode_name) == 0)
+            return (p);
+
+        p = p->next;
+    }
+    return (NULL);
+}
 
 XConfigModePtr
 xconfigAddMode(XConfigModePtr head, const char *name)

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Vendor.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Vendor.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Vendor.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Vendor.c Tue Jun 24 17:53:25 2008
@@ -106,10 +106,6 @@
         }
     }
 
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Vendor subsection parsed\n");
-#endif
-
     return ptr;
 }
 
@@ -171,10 +167,6 @@
 
     if (!has_ident)
         Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "Vendor section parsed\n");
-#endif
 
     return ptr;
 }

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Video.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Video.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Video.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Video.c Tue Jun 24 17:53:25 2008
@@ -104,10 +104,6 @@
             break;
         }
     }
-
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "VideoPort subsection parsed\n");
-#endif
 
     return ptr;
 }
@@ -195,10 +191,6 @@
 
     if (!has_ident)
         Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
-    xconfigErrorMsg(DebugMsg, "VideoAdaptor section parsed\n");
-#endif
 
     return ptr;
 }

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/Write.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/Write.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/Write.c (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/Write.c Tue Jun 24 17:53:25 2008
@@ -64,10 +64,13 @@
 #include <sys/wait.h>
 #include <signal.h>
 #include <errno.h>
+#include <locale.h>
+
 
 int xconfigWriteConfigFile (const char *filename, XConfigPtr cptr)
 {
     FILE *cf;
+    char *locale;
     
     if ((cf = fopen(filename, "w")) == NULL)
     {
@@ -76,18 +79,36 @@
         return FALSE;
     }
 
+    /*
+     * read the current locale and then set the standard "C" locale,
+     * so that the X configuration writer does not use locale-specific
+     * formatting.  After writing the configuration file, we restore
+     * the original locale.
+     */
+
+    locale = setlocale(LC_ALL, NULL);
+    
+    if (locale) locale = strdup(locale);
+
+    setlocale(LC_ALL, "C");
+    
+    
     if (cptr->comment)
         fprintf (cf, "%s\n", cptr->comment);
 
     xconfigPrintLayoutSection (cf, cptr->layouts);
 
-    fprintf (cf, "Section \"Files\"\n");
-    xconfigPrintFileSection (cf, cptr->files);
-    fprintf (cf, "EndSection\n\n");
+    if (cptr->files) {
+        fprintf (cf, "Section \"Files\"\n");
+        xconfigPrintFileSection (cf, cptr->files);
+        fprintf (cf, "EndSection\n\n");
+    }
 
-    fprintf (cf, "Section \"Module\"\n");
-    xconfigPrintModuleSection (cf, cptr->modules);
-    fprintf (cf, "EndSection\n\n");
+    if (cptr->modules) {
+        fprintf (cf, "Section \"Module\"\n");
+        xconfigPrintModuleSection (cf, cptr->modules);
+        fprintf (cf, "EndSection\n\n");
+    }
 
     xconfigPrintVendorSection (cf, cptr->vendors);
 
@@ -110,5 +131,13 @@
     xconfigPrintExtensionsSection (cf, cptr->extensions);
 
     fclose(cf);
+
+    /* restore the original locale */
+
+    if (locale) {
+        setlocale(LC_ALL, locale);
+        free(locale);
+    }
+
     return TRUE;
 }

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/configProcs.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/configProcs.h?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/configProcs.h (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/configProcs.h Tue Jun 24 17:53:25 2008
@@ -54,7 +54,9 @@
 /* Layout.c */
 XConfigLayoutPtr xconfigParseLayoutSection(void);
 void xconfigPrintLayoutSection(FILE *cf, XConfigLayoutPtr ptr);
-int xconfigValidateLayout(XConfigPtr p, const char *screenName);
+int xconfigValidateLayout(XConfigPtr p);
+int xconfigSanitizeLayout(XConfigPtr p, const char *screenName,
+                          GenerateOptions *gop);
 
 /* Module.c */
 XConfigLoadPtr xconfigParseModuleSubSection(XConfigLoadPtr head, char *name);
@@ -78,6 +80,7 @@
 XConfigScreenPtr xconfigParseScreenSection(void);
 void xconfigPrintScreenSection(FILE *cf, XConfigScreenPtr ptr);
 int xconfigValidateScreen(XConfigPtr p);
+int xconfigSanitizeScreen(XConfigPtr p);
 
 /* Vendor.c */
 XConfigVendorPtr xconfigParseVendorSection(void);
@@ -90,7 +93,7 @@
 void xconfigPrintVideoAdaptorSection(FILE *cf, XConfigVideoAdaptorPtr ptr);
 
 /* Read.c */
-int xconfigValidateConfig(XConfigPtr p, const char *);
+int xconfigValidateConfig(XConfigPtr p);
 
 /* Scan.c */
 int xconfigGetToken(XConfigSymTabRec *tab);
@@ -116,3 +119,8 @@
 /* Extensions.c */
 XConfigExtensionsPtr xconfigParseExtensionsSection (void);
 void xconfigPrintExtensionsSection (FILE * cf, XConfigExtensionsPtr ptr);
+
+/* Generate.c */
+XConfigMonitorPtr xconfigAddMonitor(XConfigPtr config, int count);
+int xconfigAddMouse(GenerateOptions *gop, XConfigPtr config);
+int xconfigAddKeyboard(GenerateOptions *gop, XConfigPtr config);

Modified: packages/nvidia-xconfig/trunk/XF86Config-parser/xf86Parser.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/XF86Config-parser/xf86Parser.h?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/XF86Config-parser/xf86Parser.h (original)
+++ packages/nvidia-xconfig/trunk/XF86Config-parser/xf86Parser.h Tue Jun 24 17:53:25 2008
@@ -148,7 +148,6 @@
     struct __xconfigoptionrec *next;
     char *name;
     char *val;
-    int   used;
     char *comment;
 } XConfigOptionRec, *XConfigOptionPtr;
 
@@ -217,7 +216,7 @@
 typedef struct __xconfigconfmodelinerec {
     struct __xconfigconfmodelinerec *next;
     char *identifier;
-    int clock;
+    char *clock; /* stored in MHz */
     int hdisplay;
     int hsyncstart;
     int hsyncend;
@@ -578,12 +577,30 @@
 } XConfigSymTabRec, *XConfigSymTabPtr;
 
 
+/*
+ * data structure containing options; used during generation of X
+ * config, and when sanitizing an existing config
+ */
+
+#define X_IS_XF86 0
+#define X_IS_XORG 1
+
+typedef struct {
+    int   xserver;
+    char *x_project_root;
+    char *keyboard;
+    char *mouse;
+    char *keyboard_driver;
+} GenerateOptions;
+
 
 /*
  * Functions for open, reading, and writing XConfig files.
  */
 const char *xconfigOpenConfigFile(const char *, const char *);
-XConfigError xconfigReadConfigFile(const char *, XConfigPtr *);
+XConfigError xconfigReadConfigFile(XConfigPtr *);
+int xconfigSanitizeConfig(XConfigPtr p, const char *screenName,
+                          GenerateOptions *gop);
 void xconfigCloseConfigFile(void);
 int xconfigWriteConfigFile(const char *, XConfigPtr);
 
@@ -600,6 +617,7 @@
 XConfigModeLinePtr xconfigFindModeLine(const char *ident,
                                        XConfigModeLinePtr p);
 XConfigScreenPtr   xconfigFindScreen(const char *ident, XConfigScreenPtr p);
+XConfigModePtr     xconfigFindMode(const char *name, XConfigModePtr p);
 XConfigInputPtr    xconfigFindInput(const char *ident, XConfigInputPtr p);
 XConfigInputPtr    xconfigFindInputByDriver(const char *driver,
                                             XConfigInputPtr p);
@@ -633,20 +651,16 @@
 void xconfigFreeBuffersList (XConfigBuffersPtr ptr);
 void xconfigFreeDRI(XConfigDRIPtr ptr);
 void xconfigFreeExtensions(XConfigExtensionsPtr ptr);
-
-
-/*
- * check (and update, if necessary) the inputs in the specified layout
- * section
- */
-
-int xconfigCheckCoreInputDevices(XConfigPtr config, XConfigLayoutPtr layout);
+void xconfigFreeModesLinkList(XConfigModesLinkPtr ptr);
+
+
 
 /*
  * item/list manipulation
  */
 
 GenericListPtr xconfigAddListItem(GenericListPtr head, GenericListPtr c_new);
+GenericListPtr xconfigRemoveListItem(GenericListPtr list, GenericListPtr item);
 int xconfigItemNotSublist(GenericListPtr list_1, GenericListPtr list_2);
 char *xconfigAddComment(char *cur, char *add);
 XConfigLoadPtr xconfigAddNewLoadDirective(XConfigLoadPtr head,
@@ -660,22 +674,20 @@
  */
 
 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 *, int);
-XConfigOptionPtr xconfigOptionListCreate(const char **options,
-                                         int count, int used);
+                                           const char *name);
 XConfigOptionPtr xconfigOptionListMerge(XConfigOptionPtr head,
                                         XConfigOptionPtr tail);
 
@@ -686,13 +698,16 @@
 char *xconfigStrdup(const char *s);
 char *xconfigStrcat(const char *str, ...);
 int xconfigNameCompare(const char *s1, const char *s2);
+int xconfigModelineCompare(XConfigModeLinePtr m1, XConfigModeLinePtr m2);
 char *xconfigULongToString(unsigned long i);
-void xconfigDebugListOptions(XConfigOptionPtr);
 XConfigOptionPtr xconfigParseOption(XConfigOptionPtr head);
 void xconfigPrintOptionList(FILE *fp, XConfigOptionPtr list, int tabs);
 int xconfigParsePciBusString(const char *busID,
                              int *bus, int *device, int *func);
 
+XConfigDisplayPtr
+xconfigAddDisplay(XConfigDisplayPtr head, const int depth);
+
 XConfigModePtr
 xconfigAddMode(XConfigModePtr head, const char *name);
 
@@ -700,17 +715,6 @@
 xconfigRemoveMode(XConfigModePtr head, const char *name);
 
 
-#define X_IS_XF86 0
-#define X_IS_XORG 1
-
-typedef struct {
-    int   xserver;
-    char *x_project_root;
-    char *keyboard;
-    char *mouse;
-    char *keyboard_driver;
-} GenerateOptions;
-
 XConfigPtr xconfigGenerate(GenerateOptions *gop);
 
 XConfigScreenPtr xconfigGenerateAddScreen(XConfigPtr config, int bus, int slot,
@@ -721,4 +725,21 @@
 void xconfigGeneratePrintPossibleMice(void);
 void xconfigGeneratePrintPossibleKeyboards(void);
 
+/*
+ * check (and update, if necessary) the inputs in the specified layout
+ * section
+ */
+
+int xconfigCheckCoreInputDevices(GenerateOptions *gop,
+                                 XConfigPtr config, XConfigLayoutPtr layout);
+
+
+/*
+ * X config tools
+ */
+
+int xconfigMergeConfigs(XConfigPtr dstConfig, XConfigPtr srcConfig);
+
+
+
 #endif /* _xf86Parser_h_ */

Modified: packages/nvidia-xconfig/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/debian/changelog?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/debian/changelog (original)
+++ packages/nvidia-xconfig/trunk/debian/changelog Tue Jun 24 17:53:25 2008
@@ -1,3 +1,9 @@
+nvidia-xconfig (1.0+20080522-1) UNRELEASED; urgency=low
+
+  * new upstream
+
+ -- Randall Donald <rdonald at debian.org>  Tue, 24 Jun 2008 10:51:01 -0700
+
 nvidia-xconfig (1.0+20070502-1) unstable; urgency=low
 
   * New upstream.

Modified: packages/nvidia-xconfig/trunk/gen-manpage-opts.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/gen-manpage-opts.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/gen-manpage-opts.c (original)
+++ packages/nvidia-xconfig/trunk/gen-manpage-opts.c Tue Jun 24 17:53:25 2008
@@ -3,6 +3,7 @@
  */
 #include <stdio.h>
 #include <ctype.h>
+#include <string.h>
 
 #include "XF86Config-parser/xf86Parser.h"
 #include "nvidia-xconfig.h"
@@ -11,30 +12,108 @@
 
 static void print_option(const NVGetoptOption *o)
 {
-    printf(".TP\n.BI ");
+    char scratch[64], *s;
+    int j, len;
+
+    int omitWhiteSpace;
+    
+    /* if we are going to need the argument, process it now */
+    if (o->flags & NVGETOPT_HAS_ARGUMENT) {
+        if (o->arg_name) {
+            strcpy(scratch, o->arg_name);
+        } else {
+            len = strlen(o->name);
+            for (j = 0; j < len; j++) scratch[j] = toupper(o->name[j]);
+            scratch[len] = '\0';
+        }
+    }
+    
+    printf(".TP\n.BI \"");
     /* Print the name of the option */
     /* XXX We should backslashify the '-' characters in o->name. */
-    if (o->flags & NVGETOPT_IS_BOOLEAN) {
-        /* "\-\-name, \-\-no\-name */
-        printf("\"\\-\\-%s, \\-\\-no\\-%s", o->name, o->name);
-    } else if (isalpha(o->val)) {
-        /* "\-c, \-\-name */
-        printf("\"\\-%c, \\-\\-%s", o->val, o->name);
-    } else {
-        /* "\-\-name */
-        printf("\"\\-\\-%s", o->name);
+    
+    if (isalpha(o->val)) {
+        /* '\-c' */
+        printf("\\-%c", o->val);
+
+        if (o->flags & NVGETOPT_HAS_ARGUMENT) {
+            /* ' " "ARG" "' */
+            printf(" \" \"%s\" \"", scratch);
+        }
+        /* ', ' */
+        printf(", ");
     }
-
+    
+    /* '\-\-name' */
+    printf("\\-\\-%s", o->name);
+    
+    /* '=" "ARG' */
     if (o->flags & NVGETOPT_HAS_ARGUMENT) {
-        printf("=\" \"%s", o->name);
+        printf("=\" \"%s", scratch);
+        
+        /* '" "' */
+        if ((o->flags & NVGETOPT_IS_BOOLEAN) ||
+            (o->flags & NVGETOPT_ALLOW_DISABLE)) {
+            printf("\" \"");
+        }
     }
-
+    
+    /* ', \-\-no\-name' */
+    if (((o->flags & NVGETOPT_IS_BOOLEAN) &&
+         !(o->flags & NVGETOPT_HAS_ARGUMENT)) ||
+        (o->flags & NVGETOPT_ALLOW_DISABLE)) {
+        printf(", \\-\\-no\\-%s", o->name);
+    }
+    
     printf("\"\n");
-
+    
     /* Print the option description */
     /* XXX Each sentence should be on its own line! */
-    /* XXX We need to backslashify the '-' characters here. */
-    printf("%s\n", o->description);
+    
+    /*
+     * Print the option description:  write each character one at a
+     * time (ugh) so that we can special-case a few characters:
+     *
+     * "[" --> "\n.I "
+     * "]" --> "\n"
+     * "-" --> "\-"
+     *
+     * Brackets are used to mark the text inbetween as italics.
+     * '-' is special cased so that we can backslashify it.
+     *
+     * XXX Each sentence should be on its own line!
+     */
+    
+    omitWhiteSpace = 0;
+    
+    for (s = o->description; s && *s; s++) {
+        
+        switch (*s) {
+          case '[':
+              printf("\n.I ");
+              omitWhiteSpace = 0;
+              break;
+          case ']':
+              printf("\n");
+              omitWhiteSpace = 1;
+              break;
+          case '-':
+              printf("\\-");
+              omitWhiteSpace = 0;
+              break;
+          case ' ':
+              if (!omitWhiteSpace) {
+                  printf("%c", *s);
+              }
+              break;
+          default:
+              printf("%c", *s);
+              omitWhiteSpace = 0;
+              break;
+        }
+    }
+    
+    printf("\n");
 }
 
 int main(int argc, char* argv[])

Modified: packages/nvidia-xconfig/trunk/lscf.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/lscf.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/lscf.c (original)
+++ packages/nvidia-xconfig/trunk/lscf.c Tue Jun 24 17:53:25 2008
@@ -32,7 +32,11 @@
                             scf_service_t *current_svc,
                             const char *group, 
                             const char *name, int value);
-
+static int lscf_getprop_int(scf_handle_t *scf_handle, 
+                            scf_scope_t *scf_scope,
+                            scf_service_t *current_svc,
+                            const char *group, 
+                            const char *name, int *value);
 
 /* UPDATE THE DEFAULT DEPTH PROPERTY IN SMF WITH THE LIBSCF FUNCTIONS */
 int update_scf_depth(int depth) 
@@ -72,6 +76,49 @@
     }
     if (!status) {
         fmterr("Unable to set X server default depth through "
+               "Solaris Service Management Facility");
+    }
+    return status;
+}
+
+/* READ THE DEFAULT DEPTH PROPERTY FROM SMF WITH THE LIBSCF FUNCTIONS */
+int read_scf_depth(int *depth) 
+{  
+    static scf_handle_t *scf_handle = NULL;
+    static scf_scope_t *scf_scope  = NULL;
+    scf_service_t       *curren_svc = NULL;
+    int status = 1;
+    
+    // Initialization of the handles
+    lscf_init_handle(&scf_handle, &scf_scope);
+    if (scf_handle == NULL) {
+        status =0;
+        goto done;
+    }
+    
+    // Set the current selection
+    if(!lscf_select(scf_handle, scf_scope, "application/x11/x11-server",
+                    &curren_svc)) {
+        status =0;
+        goto done;
+    }
+    
+    // Get the depth property of the current selection
+    if(!lscf_getprop_int(scf_handle, scf_scope, curren_svc,
+                         "options", "default_depth", depth)) {
+        status =0;
+        goto done;
+    }
+
+done:
+    if(curren_svc)  scf_service_destroy(curren_svc);
+    if(scf_scope)   scf_scope_destroy(scf_scope);    
+    if(scf_handle) {
+                    scf_handle_unbind(scf_handle);
+                    scf_handle_destroy(scf_handle);
+    }
+    if (!status) {
+        fmterr("Unable to get X server default depth from "
                "Solaris Service Management Facility");
     }
     return status;
@@ -270,10 +317,99 @@
     return status;
 }
 
-
+/* EQUIVALENT TO THE SVCCFG SETPROP COMMAND FOR AN INTEGER TYPED VALUE */
+static int lscf_getprop_int(scf_handle_t *scf_handle, 
+                            scf_scope_t *scf_scope,
+                            scf_service_t *current_svc,
+                            const char *group, 
+                            const char *name, int *value) 
+{
+    scf_transaction_entry_t *entry=NULL;
+    scf_propertygroup_t *pg = NULL;
+    scf_property_t *prop = NULL;
+    scf_value_t *v = NULL;
+    int status = 1;
+    int64_t t;
+    
+    // Allocate a new transaction entry handle
+    entry = scf_entry_create(scf_handle);
+    if (entry == NULL) {
+        status=0;
+        goto done;
+    }
+    
+    // Allocate a property group. 
+    pg = scf_pg_create(scf_handle);
+    if (pg == NULL) {
+        status=0;
+        goto done;
+    }
+    
+    // Allocate a property. A property is a named set
+    // of values.
+    prop = scf_property_create(scf_handle);
+    if (prop == NULL) {
+        status=0;
+        goto done;
+    }
+       
+    // Set the the property group 'pg' to the 
+    // groups specified by 'group' in the service
+    // specified by 'current_svc'
+    if (scf_service_get_pg(current_svc, group, pg) != SCF_SUCCESS) {
+        status=0;
+        goto done;
+    }
+    
+    // Update the property group.
+    if (scf_pg_update(pg) == -1) {
+        status=0;
+        goto done;
+    }
+    
+    // Set the property 'prop' to the property 
+    // specified ny 'name' in the property group 'pg'
+    if (scf_pg_get_property(pg, name, prop) != SCF_SUCCESS) {
+        status=0;
+        goto done;
+    }
+
+    // Allocate a value.
+    v = scf_value_create(scf_handle);
+    if (v == NULL) {
+        status=0;
+        goto done;
+    }
+    
+    // Get the value
+    if (scf_property_get_value(prop, v) != SCF_SUCCESS) {
+        status=0;
+        goto done;
+    }   
+    
+    // Get the integer value
+    if (scf_value_get_integer(v, &t) != SCF_SUCCESS) {
+        status=0;
+        goto done;
+    }
+    
+    *value = (int)t;
+    
+done:
+    if (entry)      scf_entry_destroy(entry);
+    if (pg)         scf_pg_destroy(pg);
+    if (prop)       scf_property_destroy(prop);
+    if (v)          scf_value_destroy(v);
+    return status;
+}
 #else // NOT SOLARIS
 int update_scf_depth(int depth) 
 {
     return 1;
 }
+
+int read_scf_depth(int *depth) 
+{
+    return 0;
+}
 #endif

Modified: packages/nvidia-xconfig/trunk/make_usable.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/make_usable.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/make_usable.c (original)
+++ packages/nvidia-xconfig/trunk/make_usable.c Tue Jun 24 17:53:25 2008
@@ -27,40 +27,65 @@
 
 #include <unistd.h>
 #include <string.h>
+#include <stdlib.h>
 #include <sys/types.h>
 
 #include "nvidia-xconfig.h"
 #include "xf86Parser.h"
-
-
+#include "configProcs.h"
+
+
+static void ensure_module_loaded(XConfigPtr config, char *name);
 static int update_device(XConfigPtr config, XConfigDevicePtr device);
 static void update_depth(Options *op, XConfigScreenPtr screen);
 static void update_display(Options *op, XConfigScreenPtr screen);
 
-
-/*
- * update_modules() - make sure the glx module is present, and remove
- * the GLcore and dri modules if they are present.
- */
-
-int update_modules(XConfigPtr config)
-{
-    XConfigLoadPtr load, next;
-    int found;
-
-    /* make sure glx is loaded */
-
-    found = FALSE;
-    for (load = config->modules->loads; load; load = load->next) {
-        if (xconfigNameCompare("glx", load->name) == 0) found = TRUE;
+/*
+ * ensure_module_loaded() - make sure the given module is present
+ */
+
+static void ensure_module_loaded(XConfigPtr config, char *name) {
+    XConfigLoadPtr load;
+    int found = FALSE;
+
+    for (load = config->modules->loads; load && !found; load = load->next) {
+        if (xconfigNameCompare(name, load->name) == 0) found = TRUE;
     }
 
     if (!found) {
         config->modules->loads =
             xconfigAddNewLoadDirective(config->modules->loads,
-                                       "glx", XCONFIG_LOAD_MODULE,
+                                       name, XCONFIG_LOAD_MODULE,
                                        NULL, FALSE);
     }
+} /* ensure_module_loaded */
+
+/*
+ * update_modules() - make sure the glx module is present, and remove
+ * the GLcore and dri modules if they are present.
+ */
+
+int update_modules(XConfigPtr config)
+{
+    XConfigLoadPtr load, next;
+
+    /*
+     * Return early if the original X configuration file lacked a
+     * "Module" section, and rely on the server's builtin list
+     * of modules to load, instead. We can safely do this if the
+     * X server is an X.Org server or XFree86 release >= 4.4.0. On
+     * installations with older XFree86 servers, the vendor's X
+     * configuration utility should have added a "Module" section
+     * we can extend, if necessary.
+     */
+    if (config->modules == NULL)
+        return FALSE;
+
+    /* make sure all our required modules are loaded */
+    ensure_module_loaded(config, "glx");
+#if defined(NV_SUNOS)
+    ensure_module_loaded(config, "xtsol");
+#endif // defined(NV_SUNOS)
 
     /* make sure GLcore and dri are not loaded */
 
@@ -144,6 +169,84 @@
 
 
 /*
+ * update_extensions() - apply any requested updates to the Extensions
+ * section; currently, this only applies to the Composite option.
+ */
+
+int update_extensions(Options *op, XConfigPtr config)
+{
+    char *value;
+
+    /* validate the composite option against any other options specified */
+
+    validate_composite(op, config);
+
+    if (GET_BOOL_OPTION(op->boolean_options, COMPOSITE_BOOL_OPTION)) {
+
+        /* if we don't already have the Extensions section, create it now */
+
+        if (!config->extensions) {
+            config->extensions = calloc(1, sizeof(XConfigExtensionsRec));
+        }
+
+        /* remove any existing composite extension option */
+        
+        remove_option_from_list(&(config->extensions->options), "Composite");
+
+        /* determine the value to set for the Composite option */
+
+        value = GET_BOOL_OPTION(op->boolean_option_values,
+                                COMPOSITE_BOOL_OPTION) ?
+            "Enable" : "Disable";
+        
+        /* add the option */
+
+        config->extensions->options =
+            xconfigAddNewOption(config->extensions->options,
+                                "Composite", value);
+    }
+    
+    return TRUE;
+
+} /* update_extensions() */
+
+
+/*
+ * update_server_flags() - update the server flags section with any
+ * server flag options; the only option so far is "HandleSpecialKeys"
+ */
+
+int update_server_flags(Options *op, XConfigPtr config)
+{
+    if (!op->handle_special_keys) return TRUE;
+
+    if (!config->flags) {
+        config->flags = nvalloc(sizeof(XConfigFlagsRec));
+        if ( !config->flags ) {
+            return FALSE;
+        }
+    }
+
+    if (config->flags->options) {
+        remove_option_from_list(&(config->flags->options),
+                                "HandleSpecialKeys");
+    }
+
+    if (op->handle_special_keys != NV_DISABLE_STRING_OPTION) {
+        config->flags->options =
+            xconfigAddNewOption(config->flags->options,
+                                "HandleSpecialKeys",
+                                op->handle_special_keys);
+    }
+
+    return TRUE;
+
+} /* update_server_flags() */
+
+
+
+
+/*
  * update_device() - update the device; there is a lot of information
  * in the device that is not relevant to the NVIDIA X driver.  In
  * fact, some options, like "Chipset" can actually prevent XFree86
@@ -213,9 +316,20 @@
     
     /* update the depth */
     if ((op->depth == 8) || (op->depth == 15) ||
-        (op->depth == 16) || (op->depth == 24)) {
+        (op->depth == 16) || (op->depth == 24) ||
+        (op->depth == 30)) {
         screen->defaultdepth = op->depth;
-    }
+    } else {
+        /* read the default depth to SVC and set it as the default depth */
+        int scf_depth;
+        
+        if (read_scf_depth(&scf_depth) && scf_depth != screen->defaultdepth) {
+            fmtwarn("The default depth of %d read from "
+                "the Solaris Management Facility is set as the default "
+                "depth for screen \"%s\"", scf_depth, screen->identifier);
+            screen->defaultdepth = scf_depth;
+        }
+    }         
     
     /*
      * if there is no display at the default depth, force the first
@@ -250,11 +364,7 @@
         XConfigDisplayPtr display;
         XConfigModePtr mode = NULL;
         
-        mode = xconfigAddMode(mode, "640x480");
-        mode = xconfigAddMode(mode, "800x600");
-        mode = xconfigAddMode(mode, "1024x768");
-        mode = xconfigAddMode(mode, "1280x1024");
-        mode = xconfigAddMode(mode, "1600x1200");
+        mode = xconfigAddMode(mode, "nvidia-auto-select");
         
         display = nvalloc(sizeof(XConfigDisplayRec));
         display->depth = screen->defaultdepth;

Modified: packages/nvidia-xconfig/trunk/multiple_screens.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/multiple_screens.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/multiple_screens.c (original)
+++ packages/nvidia-xconfig/trunk/multiple_screens.c Tue Jun 24 17:53:25 2008
@@ -33,17 +33,6 @@
 #include <dlfcn.h>
 
 
-typedef struct _device_rec {
-    NvCfgDevice dev;
-    NvCfgDisplayDeviceInformation info[2];
-    int edid_valid;
-    int crtcs;
-    char *name;
-    unsigned int display_device_mask;
-} DeviceRec, *DevicePtr;
-
-static DevicePtr find_devices(Options *op, int *num);
-
 static int enable_separate_x_screens(Options *op, XConfigPtr config,
                                      XConfigLayoutPtr layout);
 static int disable_separate_x_screens(Options *op, XConfigPtr config,
@@ -88,9 +77,9 @@
     
 
     if (GET_BOOL_OPTION(op->boolean_options,
-                        SEPARATE_X_SCREENS_OPTION)) {
+                        SEPARATE_X_SCREENS_BOOL_OPTION)) {
         if (GET_BOOL_OPTION(op->boolean_option_values,
-                            SEPARATE_X_SCREENS_OPTION)) {
+                            SEPARATE_X_SCREENS_BOOL_OPTION)) {
             if (!enable_separate_x_screens(op, config, layout)) return FALSE;
         } else {
             if (!disable_separate_x_screens(op, config, layout)) return FALSE;
@@ -98,9 +87,9 @@
     }
     
     if (GET_BOOL_OPTION(op->boolean_options,
-                        XINERAMA_OPTION)) {
+                        XINERAMA_BOOL_OPTION)) {
         if (!set_xinerama(GET_BOOL_OPTION(op->boolean_option_values,
-                                          XINERAMA_OPTION),
+                                          XINERAMA_BOOL_OPTION),
                           config)) return FALSE;
     }
     
@@ -119,13 +108,16 @@
  * available information about the GPUs in the system.
  */
 
-static DevicePtr find_devices(Options *op, int *num)
-{
-    DevicePtr devices = NULL;
+DevicesPtr find_devices(Options *op)
+{
+    DevicesPtr pDevices = NULL;
+    DisplayDevicePtr pDisplayDevice;
     int i, j, n, count = 0;
     unsigned int mask, bit;
+    DeviceRec tmpDevice;
     NvCfgDeviceHandle handle;
     NvCfgDevice *devs = NULL;
+    NvCfgBool is_primary_device;
     char *lib_path;
     void *lib_handle;
 
@@ -138,10 +130,10 @@
     NvCfgBool (*__getEDID)(NvCfgDeviceHandle handle,
                            unsigned int display_device,
                            NvCfgDisplayDeviceInformation *info);
+    NvCfgBool (*__isPrimaryDevice)(NvCfgDeviceHandle handle,
+                                  NvCfgBool *is_primary_device);
     NvCfgBool (*__closeDevice)(NvCfgDeviceHandle handle);
     
-    *num = 0;
-
     /* dlopen() the nvidia-cfg library */
     
 #define __LIB_NAME "libnvidia-cfg.so.1"
@@ -169,7 +161,8 @@
         dlclose(lib_handle);                                   \
         return NULL;                                           \
     }
-        
+
+    /* required functions */
     __GET_FUNC(__getDevices, "nvCfgGetDevices");
     __GET_FUNC(__openDevice, "nvCfgOpenDevice");
     __GET_FUNC(__getNumCRTCs, "nvCfgGetNumCRTCs");
@@ -177,6 +170,9 @@
     __GET_FUNC(__getDisplayDevices, "nvCfgGetDisplayDevices");
     __GET_FUNC(__getEDID, "nvCfgGetEDID");
     __GET_FUNC(__closeDevice, "nvCfgCloseDevice");
+
+    /* optional functions */
+    __isPrimaryDevice = dlsym(lib_handle, "nvCfgIsPrimaryDevice");
     
     if (__getDevices(&count, &devs) != NVCFG_TRUE) {
         return NULL;
@@ -184,59 +180,123 @@
 
     if (count == 0) return NULL;
 
-    devices = nvalloc(sizeof(DeviceRec) * count);
+    pDevices = nvalloc(sizeof(DevicesRec));
+    
+    pDevices->devices = nvalloc(sizeof(DeviceRec) * count);
+
+    pDevices->nDevices = count;
 
     for (i = 0; i < count; i++) {
         
-        devices[i].dev = devs[i];
+        pDevices->devices[i].dev = devs[i];
         
         if (__openDevice(devs[i].bus, devs[i].slot, &handle) != NVCFG_TRUE)
             goto fail;
         
-        if (__getNumCRTCs(handle, &devices[i].crtcs) != NVCFG_TRUE)
+        if (__getNumCRTCs(handle, &pDevices->devices[i].crtcs) != NVCFG_TRUE)
             goto fail;
         
-        if (__getProductName(handle, &devices[i].name) != NVCFG_TRUE)
+        if (__getProductName(handle, &pDevices->devices[i].name) != NVCFG_TRUE)
             goto fail;
         
         if (__getDisplayDevices(handle, &mask) != NVCFG_TRUE)
             goto fail;
         
-        devices[i].display_device_mask = mask;
-
+        pDevices->devices[i].displayDeviceMask = mask;
+
+        /* count the number of display devices */
+        
         for (n = j = 0; j < 32; j++) {
-            bit = 1 << j;
-            if (!(bit & mask)) continue;
+            if (mask & (1 << j)) n++;
+        }
+        
+        pDevices->devices[i].nDisplayDevices = n;
+
+        if (n) {
+
+            /* allocate the info array of the right size */
             
-            if (__getEDID(handle, bit, &devices[i].info[n]) != NVCFG_TRUE) {
-                devices[i].edid_valid = FALSE;
-            } else {
-                devices[i].edid_valid = TRUE;
+            pDevices->devices[i].displayDevices =
+                nvalloc(sizeof(DisplayDeviceRec) * n);
+            
+            /* fill in the info array */
+            
+            for (n = j = 0; j < 32; j++) {
+                bit = 1 << j;
+                if (!(bit & mask)) continue;
+                
+                pDisplayDevice = &pDevices->devices[i].displayDevices[n];
+                pDisplayDevice->mask = bit;
+
+                if (__getEDID(handle, bit,
+                              &pDisplayDevice->info) != NVCFG_TRUE) {
+                    pDisplayDevice->info_valid = FALSE;
+                } else {
+                    pDisplayDevice->info_valid = TRUE;
+                }
+                n++;
             }
-            
-            n++;
-        }
-
+        } else {
+            pDevices->devices[i].displayDevices = NULL;
+        }
+
+        if ((i != 0) && (__isPrimaryDevice != NULL) &&
+            (__isPrimaryDevice(handle, &is_primary_device) == NVCFG_TRUE) &&
+            (is_primary_device == NVCFG_TRUE)) {
+            memcpy(&tmpDevice, &pDevices->devices[0], sizeof(DeviceRec));
+            memcpy(&pDevices->devices[0], &pDevices->devices[i], sizeof(DeviceRec));
+            memcpy(&pDevices->devices[i], &tmpDevice, sizeof(DeviceRec));
+        }
+        
         if (__closeDevice(handle) != NVCFG_TRUE)
             goto fail;
     }
     
-    *num = count;
-
-    return devices;
-
+    goto done;
+    
  fail:
 
-    *num = 0;
-    if (devices) nvfree((void *) devices);
-    if (devs) free(devs);
-    
     fmtwarn("Unable to use the nvidia-cfg library to query NVIDIA "
             "hardware.");
-    
-    return NULL;
+
+    free_devices(pDevices);
+    pDevices = NULL;
+
+    /* fall through */
+
+ done:
+    
+    if (devs) free(devs);
+    
+    return pDevices;
     
 } /* find_devices() */
+
+
+
+/*
+ * free_devices()
+ */
+
+void free_devices(DevicesPtr pDevices)
+{
+    int i;
+    
+    if (!pDevices) return;
+    
+    for (i = 0; i < pDevices->nDevices; i++) {
+        if (pDevices->devices[i].displayDevices) {
+            nvfree(pDevices->devices[i].displayDevices);
+        }
+    }
+    
+    if (pDevices->devices) {
+        nvfree(pDevices->devices);
+    }
+        
+    nvfree(pDevices);
+    
+} /* free_devices() */
 
 
 
@@ -260,8 +320,8 @@
 
     config->flags->options =
         xconfigAddNewOption(config->flags->options,
-                            nvstrdup("Xinerama"),
-                            nvstrdup(xinerama_enabled?"1":"0"));
+                            "Xinerama",
+                            (xinerama_enabled ? "1" : "0"));
 
     return TRUE;
 
@@ -348,11 +408,10 @@
      */
     
     if (!have_busids) {
-        DevicePtr devs;
-        int ndevs;
-        
-        devs = find_devices(op, &ndevs);
-        if (!devs) {
+        DevicesPtr pDevices;
+        
+        pDevices = find_devices(op);
+        if (!pDevices) {
             fmterr("Unable to determine number or location of "
                    "GPUs in system; cannot "
                    "honor '--separate-x-screens' option.");
@@ -360,7 +419,7 @@
         }
         
         for (i = 0; i < nscreens; i++) {
-            if (i > ndevs) {
+            if (i >= pDevices->nDevices) {
                 /*
                  * we have more screens than GPUs, this screen is no
                  * longer a candidate
@@ -371,9 +430,13 @@
             
             screenlist[i]->device->busid = nvalloc(32);
             snprintf(screenlist[i]->device->busid, 32,
-                     "PCI:%d:%d:0", devs[i].dev.bus, devs[i].dev.slot);
-            screenlist[i]->device->board = nvstrdup(devs[i].name);
-        }
+                     "PCI:%d:%d:0",
+                     pDevices->devices[i].dev.bus,
+                     pDevices->devices[i].dev.slot);
+            screenlist[i]->device->board = nvstrdup(pDevices->devices[i].name);
+        }
+
+        free_devices(pDevices);
     }
     
     /*
@@ -410,6 +473,7 @@
                                           &bus1, &slot1, &scratch)) continue;
             if ((bus0 == bus1) && (slot0 == slot1)) {
                 screenlist[i] = NULL; /* no longer a candidate */
+                break;
             }
         }
     }
@@ -421,7 +485,13 @@
         clone_screen(screenlist[i]);
     }
     
-    /* wipe the existing adjacencies and recreate them */
+    /*
+     * wipe the existing adjacencies and recreate them
+     * 
+     * XXX we should really only use the screens in the current
+     * adjacency list, plus the new cloned screens, when building the
+     * new adjacencies
+     */
     
     xconfigFreeAdjacencyList(layout->adjacencies);
     layout->adjacencies = NULL;
@@ -747,11 +817,11 @@
 static int enable_all_gpus(Options *op, XConfigPtr config,
                            XConfigLayoutPtr layout)
 {
-    DevicePtr devs;
-    int n, i;
-
-    devs = find_devices(op, &n);
-    if (!devs) {
+    DevicesPtr pDevices;
+    int i;
+
+    pDevices = find_devices(op);
+    if (!pDevices) {
         fmterr("Unable to determine number of GPUs in system; cannot "
                "honor '--enable-all-gpus' option.");
         return FALSE;
@@ -773,11 +843,15 @@
 
     /* add N new screens; this will also add device and monitor sections */
     
-    for (i = 0; i < n; i++) {
-        xconfigGenerateAddScreen(config, devs[i].dev.bus, devs[i].dev.slot,
-                                 devs[i].name, i);
-    }
-    
+    for (i = 0; i < pDevices->nDevices; i++) {
+        xconfigGenerateAddScreen(config,
+                                 pDevices->devices[i].dev.bus,
+                                 pDevices->devices[i].dev.slot,
+                                 pDevices->devices[i].name, i);
+    }
+    
+    free_devices(pDevices);
+
     /* create adjacencies for the layout */
     
     create_adjacencies(op, config, layout);

Modified: packages/nvidia-xconfig/trunk/nvgetopt.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/nvgetopt.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/nvgetopt.c (original)
+++ packages/nvidia-xconfig/trunk/nvgetopt.c Tue Jun 24 17:53:25 2008
@@ -23,8 +23,7 @@
  *
  *
  * nvgetopt.c - portable getopt_long() replacement; removes the need
- * for the stupid optstring argument.  Also adds support for the
- * "-feature"/"+feature" syntax.
+ * for the stupid optstring argument.
  */
 
 #include <stdio.h>
@@ -50,10 +49,12 @@
  */
 
 int nvgetopt(int argc, char *argv[], const NVGetoptOption *options,
-             char **strval, int *boolval, int *intval)
+             char **strval, int *boolval, int *intval, double *doubleval,
+             int *disable_val)
 {
     char *c, *a, *arg, *name = NULL, *argument=NULL;
     int i, found = NVGETOPT_FALSE, ret = 0, val = NVGETOPT_FALSE;
+    int disable = NVGETOPT_FALSE;
     const NVGetoptOption *o = NULL;
     static int argv_index = 0;
     
@@ -183,81 +184,80 @@
         fprintf(stderr, "%s: unrecognized option: \"%s\"\n", argv[0], arg);
         goto done;
     }
-
+    
+    
+    /* if the option is boolean, record 'val' as the boolean value */
+    
     if (o->flags & NVGETOPT_IS_BOOLEAN) {
-
-        /* assign boolval */
-        
         if (boolval) *boolval = val;
     }
-
-
-    /*
-     * if this option takes an integer argument, then let the "--no-"
-     * prefix set the integer argument to -2 (remove option from  x config).
-     * Otherwise, get the string argument and interpret it as an integer.
-     */
-    
-    if (o->flags & NVGETOPT_IS_INTEGER) {
-        
-        if (val == NVGETOPT_FALSE) {
-            if (intval) {
-                *intval = -2;
-            }
-        } else {
-            if (argument) {
-                if (!argument[0]) {
-                    fprintf(stderr, "%s: option \"%s\" requires an "
-                            "argument.\n", argv[0], arg);
-                    goto done;
-                }
-            } else {
-                argv_index++;
-                if (argv_index >= argc) {
-                    fprintf(stderr, "%s: option \"%s\" requires an "
-                            "argument.\n", argv[0], arg);
-                    goto done;
-                }
-                argument = argv[argv_index];
-            }
-            
-            /* argument is now a valid string: parse it */
-
-            if (intval) {
-                char *endptr;
-                *intval = (int) strtol(argument, &endptr, 0);
-                if (*endptr) {
-                    fprintf(stderr, "%s: \"%s\" is not a valid argument for "
-                            "option \"%s\".\n", argv[0], argument, arg);
-                    goto done;
-                }
-            }
-        }
-
-    /*
-     * if this option takes an argument, then we either need to use
-     * what was after the "=" in this argv[] entry, or we need to pull
-     * the next entry off of argv[]
-     */
-
-    } else if (o->flags & NVGETOPT_HAS_ARGUMENT) {
+    
+    
+    /*
+     * if this option is flagged as "disable-able", then let the
+     * "--no-" prefix get interpreted to mean that the option should
+     * be disabled
+     */
+    
+    if ((o->flags & NVGETOPT_ALLOW_DISABLE) && (val == NVGETOPT_FALSE)) {
+        disable = NVGETOPT_TRUE;
+    }
+    
+    
+    /*
+     * if the option takes an argument (either string or integer), and
+     * we haven't already decided to disable the option, then we
+     * either need to use what was after the "=" in this argv[] entry,
+     * or we need to pull the next entry off of argv[]
+     */
+    
+    if ((o->flags & NVGETOPT_HAS_ARGUMENT) && !disable) {
         if (argument) {
             if (!argument[0]) {
-                fprintf(stderr, "%s: option \"%s\" requires an argument.\n",
-                        argv[0], arg);
-                goto done;
-            }
-            if (strval) *strval = strdup(argument);
+                fprintf(stderr, "%s: option \"%s\" requires an "
+                        "argument.\n", argv[0], arg);
+                goto done;
+            }
         } else {
             argv_index++;
             if (argv_index >= argc) {
-                fprintf(stderr, "%s: option \"%s\" requires an argument.\n",
-                        argv[0], arg);
-                goto done;
-            }
-            if (strval) *strval = argv[argv_index];
-        } 
+                fprintf(stderr, "%s: option \"%s\" requires an "
+                        "argument.\n", argv[0], arg);
+                goto done;
+            }
+            argument = argv[argv_index];
+        }
+        
+        /* argument is now a valid string: parse it */
+        
+        if ((o->flags & NVGETOPT_INTEGER_ARGUMENT) && (intval)) {
+            char *endptr;
+            *intval = (int) strtol(argument, &endptr, 0);
+            if (*endptr) {
+                fprintf(stderr, "%s: \"%s\" is not a valid argument for "
+                        "option \"%s\".\n", argv[0], argument, arg);
+                goto done;
+            }
+        } else if ((o->flags & NVGETOPT_STRING_ARGUMENT) && (strval)) {
+            *strval = strdup(argument);
+        } else if ((o->flags & NVGETOPT_DOUBLE_ARGUMENT) && (doubleval)) {
+            char *endptr;
+            *doubleval = (double) strtod(argument, &endptr);
+            if (*endptr) {
+                fprintf(stderr, "%s: \"%s\" is not a valid argument for "
+                        "option \"%s\".\n", argv[0], argument, arg);
+                goto done;
+            }
+        } else {
+            fprintf(stderr, "%s: error while assigning argument for "
+                    "option \"%s\".\n", argv[0], arg);
+            goto done;
+        }
+        
     } else {
+
+        /* if we have an argument when we shouldn't; complain */
+        
         if (argument) {
             fprintf(stderr, "%s: option \"%s\" does not take an argument, but "
                     "was given an argument of \"%s\".\n",
@@ -270,6 +270,8 @@
 
  done:
 
+    if (disable_val) *disable_val = disable;
+
     free(arg);
     return ret;
 

Modified: packages/nvidia-xconfig/trunk/nvgetopt.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/nvgetopt.h?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/nvgetopt.h (original)
+++ packages/nvidia-xconfig/trunk/nvgetopt.h Tue Jun 24 17:53:25 2008
@@ -31,18 +31,70 @@
 #define NVGETOPT_FALSE 0
 #define NVGETOPT_TRUE 1
 
-#define NVGETOPT_HAS_ARGUMENT 0x1
-#define NVGETOPT_IS_BOOLEAN   0x2
-#define NVGETOPT_IS_INTEGER   0x4
+
+/*
+ * indicates that the option is a boolean value; the presence of the
+ * option will be interpretted as a TRUE value; if the option is
+ * prepended with '--no-', the option will be interpretted as a FALSE
+ * value.  On success, nvgetopt will return the parsed boolean value
+ * through 'boolval'.
+ */
+
+#define NVGETOPT_IS_BOOLEAN       0x1
+
+
+/*
+ * indicates that the option takes an argument to be interpretted as a
+ * string; on success, nvgetopt will return the parsed string argument
+ * through 'strval'.
+ */
+
+#define NVGETOPT_STRING_ARGUMENT  0x2
+
+
+/*
+ * indicates that the option takes an argument to be interpretted as
+ * an integer; on success, nvgetopt will return the parsed integer
+ * argument through 'intval'.
+ */
+
+#define NVGETOPT_INTEGER_ARGUMENT 0x4
+
+
+/*
+ * indicates that the option, which normally takes an argument, can be
+ * disabled if the option is prepended with '--no-', in which case,
+ * the option does not take an argument.  If the option is disabled,
+ * nvgetopt will return TRUE through 'disable_val'.
+ *
+ * Note that NVGETOPT_ALLOW_DISABLE can only be used with options that
+ * take arguments.
+ */
+
+#define NVGETOPT_ALLOW_DISABLE    0x8
+
+/*
+ * indicates that the option takes an argument to be interpretted as
+ * an double; on success, nvgetopt will return the parsed double
+ * argument through 'doubleval'.
+ */
+
+#define NVGETOPT_DOUBLE_ARGUMENT  0x10
+
+#define NVGETOPT_HAS_ARGUMENT (NVGETOPT_STRING_ARGUMENT | \
+                               NVGETOPT_INTEGER_ARGUMENT | \
+                               NVGETOPT_DOUBLE_ARGUMENT)
 
 typedef struct {
     const char *name;
     int val;
     unsigned int flags;
+    char *arg_name; /* not used by nvgetopt() */
     char *description; /* not used by nvgetopt() */
 } NVGetoptOption;
 
 int nvgetopt(int argc, char *argv[], const NVGetoptOption *options,
-             char **strval, int *boolval, int *intval);
+             char **strval, int *boolval, int *intval, double *doubleval,
+             int *disable_val);
 
 #endif /* __NVGETOPT_H__ */

Modified: packages/nvidia-xconfig/trunk/nvidia-cfg.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/nvidia-cfg.h?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/nvidia-cfg.h (original)
+++ packages/nvidia-xconfig/trunk/nvidia-cfg.h Tue Jun 24 17:53:25 2008
@@ -226,4 +226,16 @@
                        unsigned int display_device,
                        NvCfgDisplayDeviceInformation *info);
 
+
+/*
+ * nvCfgIsPrimaryDevice() - determines whether the specified NVIDIA
+ * device is the primary device.  On success, NVCFG_TRUE will be
+ * returned and is_primary_device set to indicate whether the
+ * device is the primary device.  On failure, NVCFG_FALSE will be
+ * returned.
+ */
+
+NvCfgBool nvCfgIsPrimaryDevice(NvCfgDeviceHandle handle,
+                               NvCfgBool *is_primary_device);
+
 #endif /* __NVIDIA_CFG__ */

Modified: packages/nvidia-xconfig/trunk/nvidia-xconfig.1.m4
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/nvidia-xconfig.1.m4?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/nvidia-xconfig.1.m4 (original)
+++ packages/nvidia-xconfig/trunk/nvidia-xconfig.1.m4 Tue Jun 24 17:53:25 2008
@@ -32,7 +32,7 @@
 if the X server
 in use is X.org or 
 .I /etc/X11/XF86Config
-if the X server in use is XFree86."
+if the X server in use is XFree86.
 .TP
 2)
 The configuration in memory is modified to support the NVIDIA driver.
@@ -79,6 +79,9 @@
 .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

Modified: packages/nvidia-xconfig/trunk/nvidia-xconfig.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/nvidia-xconfig.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/nvidia-xconfig.c (original)
+++ packages/nvidia-xconfig/trunk/nvidia-xconfig.c Tue Jun 24 17:53:25 2008
@@ -32,6 +32,9 @@
 #include <ctype.h>
 #include <errno.h>
 #include <libgen.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #include "nvidia-xconfig.h"
 #include "nvgetopt.h"
@@ -81,6 +84,35 @@
 
 
 /*
+ * cook_description() - the description string may contain text within
+ * brackets, which is used by the manpage generator to denote text to
+ * be italicized.  We want to omit the bracket characters here.
+ */
+
+static char *cook_description(const char *description)
+{
+    int len;
+    char *s, *dst;
+    const char *src;
+    
+    len = strlen(description);
+    s = nvalloc(len + 1);
+    
+    for (src = description, dst = s; *src; src++) {
+        if (*src != '[' && (*src != ']')) {
+            *dst = *src;
+            dst++;
+        }
+    }
+
+    *dst = '\0';
+
+    return s;
+    
+} /* cook_description() */
+
+
+/*
  * print_help() - loop through the __options[] table, and print the
  * description of each option.
  */
@@ -88,7 +120,7 @@
 static void print_help(int advanced)
 {
     int i, j, len;
-    char *msg, *tmp, scratch[64];
+    char *msg, *tmp, scratch[8], arg[64];
     const NVGetoptOption *o;
     
     print_version();
@@ -108,33 +140,88 @@
 
         if (!advanced && !(o->flags & OPTION_HELP_ALWAYS)) continue;
 
+        /* if we are going to need the argument, process it now */
+
+        if (o->flags & NVGETOPT_HAS_ARGUMENT) {
+            if (o->arg_name) {
+                strcpy(arg, o->arg_name);
+            } else {
+                len = strlen(o->name);
+                for (j = 0; j < len; j++) arg[j] = toupper(o->name[j]);
+                arg[len] = '\0';
+            }
+        }
+        
+        msg = nvstrcat("--", o->name, NULL);
+
         if (isalpha(o->val)) {
             sprintf(scratch, "%c", o->val);
-            msg = nvstrcat("-", scratch, ", --", o->name, NULL);
-        } else {
-            msg = nvstrcat("--", o->name, NULL);
-        }
-        if (o->flags & NVGETOPT_HAS_ARGUMENT) {
-            len = strlen(o->name);
-            for (j = 0; j < len; j++) scratch[j] = toupper(o->name[j]);
-            scratch[len] = '\0';
-            tmp = nvstrcat(msg, "=[", scratch, "]", NULL);
+
+            if (o->flags & NVGETOPT_HAS_ARGUMENT) {
+                tmp = nvstrcat("-", scratch, " ", arg, ", ", msg, NULL);
+            } else {
+                tmp = nvstrcat("-", scratch, ", ", msg, NULL);
+            }
             free(msg);
             msg = tmp;
         }
-        if (o->flags & NVGETOPT_IS_BOOLEAN ||
-            o->flags & NVGETOPT_IS_INTEGER) {
-            tmp = nvstrcat(msg, "/--no-", o->name, NULL);
+        
+        if (o->flags & NVGETOPT_HAS_ARGUMENT) {
+            tmp = nvstrcat(msg, "=", arg, NULL);
             free(msg);
             msg = tmp;
         }
+        if (((o->flags & NVGETOPT_IS_BOOLEAN) &&
+             !(o->flags & NVGETOPT_HAS_ARGUMENT)) ||
+            (o->flags & NVGETOPT_ALLOW_DISABLE)) {
+            tmp = nvstrcat(msg, ", --no-", o->name, NULL);
+            free(msg);
+            msg = tmp;
+        }
 
         fmtoutp(TAB, msg);
-        if (o->description) fmtoutp(BIGTAB, o->description);
+        if (o->description) {
+            tmp = cook_description(o->description);
+            fmtoutp(BIGTAB, tmp);
+            free(tmp);
+        }
         fmtout("");
         free(msg);
     }
 } /* print_help() */
+
+
+
+/*
+ * get_default_project_root() - scan some common directories for the X
+ * project root
+ *
+ * Users of this information should be careful to account for the
+ * modular layout.
+ */
+
+char *get_default_project_root(void)
+{
+    char *paths[] = { "/usr/X11R6", "/usr/X11", NULL };
+    struct stat stat_buf;
+    int i;
+        
+    for (i = 0; paths[i]; i++) {
+        
+        if (stat(paths[i], &stat_buf) == -1) {
+            continue;
+        }
+    
+        if (S_ISDIR(stat_buf.st_mode)) {
+            return paths[i];
+        }
+    }
+    
+    /* default to "/usr/X11R6", I guess */
+
+    return paths[0];
+
+} /* get_default_project_root() */
 
 
 
@@ -147,40 +234,34 @@
 {
     Options *op;
     int c, boolval;
-    u32 bit;
     char *strval;
-    int intval;
+    int intval, disable;
+    double doubleval;
 
     op = (Options *) nvalloc(sizeof(Options));
     
-    op->gop.x_project_root = "/usr/X11R6";
+    op->gop.x_project_root = get_default_project_root();
     op->nvagp = -1;
-    op->digital_vibrance = -1;
     op->transparent_index = -1;
     op->stereo = -1;
+    op->cool_bits = -1;
+    op->tv_over_scan = -1.0;
     
     while (1) {
         
-        c = nvgetopt(argc, argv, __options, &strval, &boolval, &intval);
+        c = nvgetopt(argc, argv, __options, &strval,
+                     &boolval, &intval, &doubleval, &disable);
 
         if (c == -1)
             break;
 
         /* catch the boolean options */
 
-        if ((c >= XCONFIG_OPTION_START) &&
-            (c <= (XCONFIG_OPTION_START + XCONFIG_BOOL_OPTION_COUNT))) {
+        if ((c >= XCONFIG_BOOL_OPTION_START) &&
+            (c <= (XCONFIG_BOOL_OPTION_START + XCONFIG_BOOL_OPTION_COUNT))) {
+
+            set_boolean_option(op, c - XCONFIG_BOOL_OPTION_START, boolval);
             
-            bit = GET_BOOL_OPTION_BIT(c - XCONFIG_OPTION_START);
-            GET_BOOL_OPTION_SLOT(op->boolean_options,
-                                 c - XCONFIG_OPTION_START) |= bit;
-            if (boolval) {
-                GET_BOOL_OPTION_SLOT(op->boolean_option_values,
-                                     c - XCONFIG_OPTION_START) |= bit;
-            } else {
-                GET_BOOL_OPTION_SLOT(op->boolean_option_values,
-                                     c - XCONFIG_OPTION_START) &= ~bit;
-            }
             continue;
         }
         
@@ -197,11 +278,12 @@
         case 'a': op->enable_all_gpus = TRUE; break;
         case '1': op->only_one_screen = TRUE; break;
         
-        case 'd': op->depth = atoi(strval);
+        case 'd': op->depth = intval;
             if ((op->depth != 8) &&
                 (op->depth != 15) &&
                 (op->depth != 16) &&
-                (op->depth != 24)) {
+                (op->depth != 24) &&
+                (op->depth != 30)) {
                 fprintf(stderr, "\n");
                 fprintf(stderr, "Invalid depth: %d.\n", op->depth);
                 fprintf(stderr, "\n");
@@ -225,7 +307,54 @@
 
         case FORCE_GENERATE_OPTION: op->force_generate = TRUE; break;
 
+        case ACPID_SOCKET_PATH_OPTION: 
+            if (disable) {
+                op->acpid_socket_path = NV_DISABLE_STRING_OPTION;
+            } else {
+                op->acpid_socket_path = strval; 
+            }
+            break;
+
+        case HANDLE_SPECIAL_KEYS_OPTION:
+            {
+                const char *valid_values[] = {
+                    "Always",
+                    "Never",
+                    "WhenNeeded",
+                    NULL,
+                };
+
+                int i;
+
+                if (disable) {
+                    op->handle_special_keys = NV_DISABLE_STRING_OPTION;
+                    break;
+                }
+
+                for (i = 0; valid_values[i]; i++) {
+                    if (!strcasecmp(strval, valid_values[i])) {
+                        break;
+                    }
+                }
+
+                if (valid_values[i]) {
+                    op->handle_special_keys = strval;
+                } else {
+                    fprintf(stderr, "Invalid HandleSpecialKeys option: %s.\n", strval);
+                    goto fail;
+                }
+                break;
+            }
+
         case NVAGP_OPTION:
+
+            /* mark as disabled, so we can remove the option later */
+            
+            if (disable) {
+                op->nvagp = -2;
+                break;
+            }
+
             if      (strcasecmp(strval, "none")    == 0) op->nvagp = 0;
             else if (strcasecmp(strval, "nvagp")   == 0) op->nvagp = 1;
             else if (strcasecmp(strval, "agpgart") == 0) op->nvagp = 2;
@@ -242,18 +371,16 @@
             }
             break;
 
-        case DIGITAL_VIBRANCE_OPTION:
-            if ( intval != -2 && (intval < 0 || intval > 255) ) {
-                fprintf(stderr, "\n");
-                fprintf(stderr, "Invalid digital vibrance: %d.\n", intval);
-                fprintf(stderr, "\n");
-                goto fail;
-            }
-            op->digital_vibrance = intval;
-            break;
-
         case TRANSPARENT_INDEX_OPTION:
-            if ( intval != -2 && (intval < 0 || intval > 255) ) {
+
+            /* mark as disabled, so we can remove the option later */
+            
+            if (disable) {
+                op->transparent_index = -2;
+                break;
+            }
+
+            if (intval < 0 || intval > 255) {
                 fprintf(stderr, "\n");
                 fprintf(stderr, "Invalid transparent index: %d.\n", intval);
                 fprintf(stderr, "\n");
@@ -262,8 +389,111 @@
             op->transparent_index = intval;
             break;
 
+        case TV_STANDARD_OPTION:
+            
+            {
+                const char* valid_values[] = {
+                    "PAL-B",
+                    "PAL-D",
+                    "PAL-G",
+                    "PAL-H",
+                    "PAL-I",
+                    "PAL-K1",
+                    "PAL-M",
+                    "PAL-N",
+                    "PAL-NC",
+                    "NTSC-J",
+                    "NTSC-M",
+                    "HD480i",
+                    "HD480p",
+                    "HD720p",
+                    "HD1080i",
+                    "HD1080p",
+                    "HD576i",
+                    "HD576p",
+                    NULL
+                };
+                int i;
+                
+                /* mark as disabled, so we can remove the option later */
+
+                if (disable) {
+                    op->tv_standard = NV_DISABLE_STRING_OPTION;
+                    break;
+                }
+
+                for (i = 0; valid_values[i]; i++) {
+                    if (!strcasecmp(strval, valid_values[i]))
+                        break;
+                }
+
+                if (valid_values[i]) {
+                    op->tv_standard = strval;
+                } else {
+                    fprintf(stderr, "Invalid TVStandard option: %s.\n", strval);
+                    goto fail;
+                }
+            }
+            break;
+
+        case TV_OUT_FORMAT_OPTION:
+            
+            /* mark as disabled, so we can remove the option later */
+
+            if (disable) {
+                op->tv_out_format = NV_DISABLE_STRING_OPTION;
+                break;
+            }
+
+            if (!strcasecmp(strval, "SVIDEO")) {
+                op->tv_out_format = "SVIDEO";
+            } else if (!strcasecmp(strval, "COMPOSITE")) {
+                op->tv_out_format = "COMPOSITE";
+            } else {
+                fprintf(stderr, "Invalid TVOutFormat option: %s.\n", strval);
+                goto fail;
+            }
+            break;
+
+        case TV_OVER_SCAN_OPTION:
+            
+            /* mark as disabled, so we can remove the option later */
+
+            if (disable) {
+                op->tv_over_scan = -2.0;
+                break;
+            }
+
+            if (doubleval >= 0.0 && doubleval <= 1.0) {
+                op->tv_over_scan = doubleval;
+            } else {
+                fprintf(stderr, "Invalid TVOverScan value: %f.\n", doubleval);
+                goto fail;
+            }
+            break;
+
+        case COOL_BITS_OPTION:
+
+            /* mark as disabled, so we can remove the option later */
+
+            if (disable) {
+                op->cool_bits = -2;
+                break;
+            }
+
+            op->cool_bits = intval;
+            break;
+
         case STEREO_OPTION:
-            if ( intval != -2 && (intval < 1 || intval > 6) ) {
+
+            /* mark as disabled, so we can remove the option later */
+            
+            if (disable) {
+                op->stereo = -2;
+                break;
+            }
+
+            if (intval < 1 || intval > 6) {
                 fprintf(stderr, "\n");
                 fprintf(stderr, "Invalid stereo: %d.\n", intval);
                 fprintf(stderr, "\n");
@@ -279,6 +509,69 @@
             } else {
                 /* remove this mode */
                 nv_text_rows_append(&op->remove_modes, strval);
+            }
+            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;
+
+        case MULTI_GPU_OPTION:
+            {
+                const char* valid_values[] = {
+                    "0",
+                    "no",
+                    "off",
+                    "false",
+                    "single",
+                    "1",
+                    "yes",
+                    "on",
+                    "true",
+                    "auto",
+                    "afr",
+                    "sfr",
+                    "aa",
+                    NULL
+                };
+                int i;
+
+                /* mark as disabled, so we can remove the option later */
+                
+                if (disable) {
+                    op->multigpu = NV_DISABLE_STRING_OPTION;
+                    break;
+                }
+
+                for (i = 0; valid_values[i]; i++) {
+                    if (!strcasecmp(strval, valid_values[i]))
+                        break;
+                }
+
+                if (valid_values[i]) {
+                    op->multigpu = strval;
+                } else {
+                    fprintf(stderr, "Invalid MultiGPU option: %s.\n", strval);
+                    goto fail;
+                }
             }
             break;
 
@@ -297,10 +590,18 @@
                     "auto",
                     "afr",
                     "sfr",
-                    "sliaa",
+                    "aa",
+                    "afrofaa",
                     NULL
                 };
                 int i;
+
+                /* mark as disabled, so we can remove the option later */
+                
+                if (disable) {
+                    op->sli = NV_DISABLE_STRING_OPTION;
+                    break;
+                }
 
                 for (i = 0; valid_values[i]; i++) {
                     if (!strcasecmp(strval, valid_values[i]))
@@ -332,6 +633,13 @@
                 };
                 int i;
 
+                /* mark as disabled, so we can remove the option later */
+
+                if (disable) {
+                    op->rotate = NV_DISABLE_STRING_OPTION;
+                    break;
+                }
+
                 for (i = 0; valid_values[i]; i++) {
                     if (!strcasecmp(strval, valid_values[i]))
                         break;
@@ -348,6 +656,89 @@
 
         case DISABLE_SCF_OPTION: op->disable_scf = TRUE; break;
         
+        case QUERY_GPU_INFO_OPTION: op->query_gpu_info = TRUE; break;
+
+        case 'E':
+            op->extract_edids_from_file = strval;
+            break;
+
+        case EXTRACT_EDIDS_OUTPUT_FILE_OPTION:
+            op->extract_edids_output_file = strval;
+            break;
+
+        case TWINVIEW_XINERAMA_INFO_ORDER_OPTION:
+            op->twinview_xinerama_info_order =
+                disable ? NV_DISABLE_STRING_OPTION : strval;
+            break;
+
+        case TWINVIEW_ORIENTATION_OPTION:
+            {
+                const char* valid_values[] = {
+                    "RightOf",
+                    "LeftOf",
+                    "Above",
+                    "Below",
+                    "Clone",
+                    NULL
+                };
+                int i;
+
+                if (disable) {
+                    op->twinview_orientation = NV_DISABLE_STRING_OPTION;
+                    break;
+                }
+                
+                for (i = 0; valid_values[i]; i++) {
+                    if (!strcasecmp(strval, valid_values[i]))
+                        break;
+                }
+
+                if (!valid_values[i]) {
+                    fprintf(stderr, "Invalid TwinViewOrientation option: "
+                            "\"%s\".\n", strval);
+                    goto fail;
+                }
+                
+                op->twinview_orientation = strval;
+            }
+            break;
+
+        case VIRTUAL_OPTION:
+            {
+                int ret, x, y;
+
+                if (disable) {
+                    op->virtual.x = op->virtual.y = -1;
+                    break;
+                }
+
+                ret = sscanf(strval, "%dx%d", &x, &y);
+                
+                if (ret != 2) {
+                    fprintf(stderr, "Invalid Virtual option: \"%s\".\n",
+                            strval);
+                    goto fail;
+                }
+                
+                op->virtual.x = x;
+                op->virtual.y = y;
+                
+                break;
+            }
+
+        case LOGO_PATH_OPTION:
+            op->logo_path = disable ? NV_DISABLE_STRING_OPTION : strval;
+            break;
+  
+        case USE_DISPLAY_DEVICE_OPTION:
+            op->use_display_device = 
+                disable ? NV_DISABLE_STRING_OPTION : strval;
+            break;
+       
+        case CUSTOM_EDID_OPTION:
+            op->custom_edid = disable ? NV_DISABLE_STRING_OPTION : strval;
+            break;
+          
         default:
             goto fail;
         }
@@ -527,6 +918,16 @@
     fmtmsg("New X configuration file written to '%s'", filename);
     fmtmsg("");
     
+    
+    /* Set the default depth in the Solaris Management Facility 
+     * to the default depth of the first screen 
+     */
+    if (op->disable_scf == FALSE) {
+        if(!update_scf_depth(config->screens[0].defaultdepth)) {
+            goto done;
+        }
+    }
+    
     ret = TRUE;
     
  done:
@@ -620,7 +1021,7 @@
     
     /* Read the opened X config file */
     
-    error = xconfigReadConfigFile(op->screen, &config);
+    error = xconfigReadConfigFile(&config);
     if (error != XCONFIG_RETURN_SUCCESS) {
         xconfigCloseConfigFile();
         return NULL;;
@@ -630,6 +1031,13 @@
     
     xconfigCloseConfigFile();
     
+    /* Sanitize the X config file */
+    
+    if (!xconfigSanitizeConfig(config, op->screen, &(op->gop))) {
+        xconfigFreeConfig(config);
+        return NULL;
+    }
+
     return config;
 
 } /* find_system_xconfig() */
@@ -649,12 +1057,6 @@
         return FALSE;
     }
 
-    /* make sure the layout has the needed input devices */
-    
-    if (!xconfigCheckCoreInputDevices(config, layout)) {
-        return FALSE;
-    }
-
     /* apply multi-display options */
     
     if (!apply_multi_screen_options(op, config, layout)) {
@@ -679,8 +1081,12 @@
         }
     }
     
+    update_extensions(op, config);
+
     update_modules(config);
 
+    update_server_flags(op, config);
+
     update_banner(config);
     
     return TRUE;
@@ -688,28 +1094,74 @@
 } /* update_xconfig() */
 
 
-# define NV_LINE_LEN 1024
+
+/*
+ * get_xserver_in_use() - try to determine which X server is in use
+ * (XFree86, Xorg); also determine if the X server supports the
+ * Extension section of the X config file; support for the "Extension"
+ * section was added between X.Org 6.7 and 6.8.
+ *
+ * Some of the parsing here mimics what is done in the
+ * check_for_modular_xorg() function in nvidia-installer
+ */
+
+#define NV_LINE_LEN 1024
+#define EXTRA_PATH "/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin:/usr/bin/X11"
+#define VERSION_FORMAT "X Protocol Version %d, Revision %d, Release %d.%d"
+
 static void get_xserver_in_use(Options *op)
 {
 #if defined(NV_SUNOS)    
-    op->gop.xserver=X_IS_XORG;
+
+    /*
+     * Solaris x86/x64 always uses X.Org 6.8 or higher, atleast as far
+     * as the NVIDIA X driver is concerned
+     */
+    
+    op->gop.xserver = X_IS_XORG;
+    op->supports_extension_section = TRUE;
+    
 #else
-    char *cmd;
+    
     FILE *stream = NULL;
     int xserver = -1;
-
-    cmd = xconfigStrcat(op->gop.x_project_root, "/bin/X -version 2>&1", NULL);
+    int dummy, len, release_major, release_minor;
+    char *cmd, *ptr, *ret;
+    
+    op->supports_extension_section = FALSE;
+    
+    /* run `X -version` with a PATH that hopefully includes the X binary */
+    
+    cmd = xconfigStrcat("PATH=", op->gop.x_project_root, ":",
+                        EXTRA_PATH, ":$PATH X -version 2>&1", NULL);
+    
     if ((stream = popen(cmd, "r"))) {
-         char buf[NV_LINE_LEN];
-
-         while (1) {
-            if (fgets(buf, NV_LINE_LEN-1, stream) == NULL) break;
-            
-            if (xserver == -1) {
-                if (strcmp(buf, "XFree86") >= 0) {
-                    xserver = X_IS_XF86;
-                } else if (strcmp(buf, "X Window System") >= 0) {
-                    xserver = X_IS_XORG;
+        char buf[NV_LINE_LEN];
+        
+        /* read in as much of the input as we can fit into the buffer */
+        
+        ptr = buf;
+
+        do {
+            len = NV_LINE_LEN - (ptr - buf) - 1;
+            ret = fgets(ptr, len, stream);
+            ptr = strchr(ptr, '\0');
+        } while ((ret != NULL) && (len > 1));
+        
+        /* Check if this is an XFree86 release */
+        
+        if (strstr(buf, "XFree86 Version") != NULL) {
+            xserver = X_IS_XF86;
+            op->supports_extension_section = FALSE;
+        } else if (strstr(buf, "X Window System") != NULL) {
+            xserver = X_IS_XORG;
+            if ((ptr = strstr(buf, "X Protocol Version")) != NULL &&
+                sscanf(ptr, VERSION_FORMAT, &dummy, &dummy,
+                       &release_major, &release_minor) == 4) {
+                
+                if ((release_major > 6) ||
+                    ((release_major == 6) && (release_minor >= 8))) {
+                    op->supports_extension_section = TRUE; 
                 }
             }
         } 
@@ -775,7 +1227,17 @@
         xconfigGeneratePrintPossibleMice();
         return 0;
     }
+
+    if (op->query_gpu_info) {
+        ret = query_gpu_info(op);
+        return (ret ? 0 : 1);
+    }
  
+    if (op->extract_edids_from_file) {
+        ret = extract_edids(op);
+        return (ret ? 0 : 1);
+    }
+
     /*
      * we want to open and parse the system's existing X config file,
      * if possible
@@ -835,14 +1297,6 @@
         return 1;
     }
 
-    /* Set the default depth in the Solaris Management Facility 
-     * to the default depth of the first screen 
-     */
-    if (op->disable_scf == TRUE) {
-        return 0;
-    } else if(!update_scf_depth(config->screens[0].defaultdepth)) {
-        return 1;
-    }
     return 0;
     
 } /* main() */

Modified: packages/nvidia-xconfig/trunk/nvidia-xconfig.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/nvidia-xconfig.h?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/nvidia-xconfig.h (original)
+++ packages/nvidia-xconfig/trunk/nvidia-xconfig.h Tue Jun 24 17:53:25 2008
@@ -52,35 +52,48 @@
 
 
 /* Boolean options */
-#define NOLOGO_OPTION                      1
-#define UBB_OPTION                         2
-#define RENDER_ACCEL_OPTION                3
-#define NO_RENDER_EXTENSION_OPTION         4
-#define OVERLAY_OPTION                     5
-#define CIOVERLAY_OPTION                   6
-#define OVERLAY_DEFAULT_VISUAL_OPTION      7
-#define NO_BANDWIDTH_TEST_OPTION           8
-#define NO_POWER_CONNECTOR_CHECK_OPTION    9
-#define ALLOW_DFP_STEREO_OPTION            10
-#define ALLOW_GLX_WITH_COMPOSITE_OPTION    11
-#define RANDR_ROTATION_OPTION              12
-#define TWINVIEW_OPTION                    13
-#define SEPARATE_X_SCREENS_OPTION          14
-#define XINERAMA_OPTION                    15
-#define NO_TWINVIEW_XINERAMA_INFO_OPTION   16
-#define NOFLIP_OPTION                      17
-#define DAC_8BIT_OPTION                    18
-#define USE_EDID_FREQS_OPTION              19
-#define IGNORE_EDID_OPTION                 20
-#define USE_INT10_MODULE_OPTION            21
-#define FORCE_STEREO_FLIPPING_OPTION       22
-#define MULTISAMPLE_COMPATIBILITY_OPTION   23
-#define XVMC_USES_TEXTURES_OPTION          24
-#define EXACT_MODE_TIMINGS_DVI_OPTION      25
-#define ALLOW_DDCCI_OPTION                 26
-#define LOAD_KERNEL_MODULE_OPTION          27
-
-#define XCONFIG_BOOL_OPTION_COUNT LOAD_KERNEL_MODULE_OPTION
+#define NOLOGO_BOOL_OPTION                      0
+#define UBB_BOOL_OPTION                         1
+#define RENDER_ACCEL_BOOL_OPTION                2
+#define NO_RENDER_EXTENSION_BOOL_OPTION         3
+#define OVERLAY_BOOL_OPTION                     4
+#define CIOVERLAY_BOOL_OPTION                   5
+#define OVERLAY_DEFAULT_VISUAL_BOOL_OPTION      6
+#define NO_BANDWIDTH_TEST_BOOL_OPTION           7
+#define NO_POWER_CONNECTOR_CHECK_BOOL_OPTION    8
+#define ALLOW_DFP_STEREO_BOOL_OPTION            9
+#define ALLOW_GLX_WITH_COMPOSITE_BOOL_OPTION    10
+#define RANDR_ROTATION_BOOL_OPTION              11
+#define TWINVIEW_BOOL_OPTION                    12
+#define SEPARATE_X_SCREENS_BOOL_OPTION          13
+#define XINERAMA_BOOL_OPTION                    14
+#define NO_TWINVIEW_XINERAMA_INFO_BOOL_OPTION   15
+#define NOFLIP_BOOL_OPTION                      16
+#define DAC_8BIT_BOOL_OPTION                    17
+#define USE_EDID_FREQS_BOOL_OPTION              18
+#define USE_EDID_BOOL_OPTION                    19
+#define USE_INT10_MODULE_BOOL_OPTION            20
+#define FORCE_STEREO_FLIPPING_BOOL_OPTION       21
+#define MULTISAMPLE_COMPATIBILITY_BOOL_OPTION   22
+#define XVMC_USES_TEXTURES_BOOL_OPTION          23
+#define EXACT_MODE_TIMINGS_DVI_BOOL_OPTION      24
+#define ALLOW_DDCCI_BOOL_OPTION                 25
+#define LOAD_KERNEL_MODULE_BOOL_OPTION          26
+#define ADD_ARGB_GLX_VISUALS_BOOL_OPTION        27
+#define COMPOSITE_BOOL_OPTION                   28
+#define DISABLE_GLX_ROOT_CLIPPING_BOOL_OPTION   29
+#define USE_EDID_DPI_BOOL_OPTION                30
+#define DAMAGE_EVENTS_BOOL_OPTION               31
+#define CONSTANT_DPI_BOOL_OPTION                32
+#define PROBE_ALL_GPUS_BOOL_OPTION              33
+#define DYNAMIC_TWINVIEW_BOOL_OPTION            34
+#define INCLUDE_IMPLICIT_METAMODES_BOOL_OPTION  35
+#define USE_EVENTS_BOOL_OPTION                  36
+#define CONNECT_TO_ACPID_BOOL_OPTION            37
+#define ENABLE_ACPI_HOTKEYS_BOOL_OPTION         38
+
+
+#define XCONFIG_BOOL_OPTION_COUNT (ENABLE_ACPI_HOTKEYS_BOOL_OPTION + 1)
 
 /* # of 32-bit variables needed to hold all the boolean options (bits) */
 #define XCONFIG_BOOL_OPTION_SLOTS  \
@@ -96,6 +109,10 @@
 #define GET_BOOL_OPTION(BLOCKS, VAR)        \
   (GET_BOOL_OPTION_SLOT((BLOCKS), (VAR)) &  \
    GET_BOOL_OPTION_BIT(VAR))
+
+
+/* define to store in string options */
+#define NV_DISABLE_STRING_OPTION ((void *) -1)
 
 /* 32 bit unsigned variable (used to pack booleans) */
 typedef unsigned int u32;
@@ -111,6 +128,7 @@
     int enable_all_gpus;
     int only_one_screen;
     int disable_scf;
+    int query_gpu_info;
     
     /*
      * the option parser will set bits in boolean_options to indicate
@@ -124,25 +142,69 @@
 
     int depth;
     int nvagp;
-    int digital_vibrance;
     int transparent_index;
     int stereo;
+    int cool_bits;
 
     char *xconfig;
     char *output_xconfig;
     char *layout;
     char *screen;
+    char *multigpu;
     char *sli;
     char *rotate;
 
     char *nvidia_cfg_path;
+    char *extract_edids_from_file;
+    char *extract_edids_output_file;
+    char *twinview_xinerama_info_order;
+    char *logo_path;
+    char *twinview_orientation;
+    char *use_display_device;
+    char *custom_edid;
+    char *tv_standard;
+    char *tv_out_format;
+    char *acpid_socket_path;
+    char *handle_special_keys;
+
+    double tv_over_scan;
+
+    struct {
+        int x;
+        int y;
+    } virtual;
 
     TextRows add_modes;
+    TextRows add_modes_list;
     TextRows remove_modes;
 
+    int supports_extension_section;
+
     GenerateOptions gop;
 
 } Options;
+
+/* data structures for storing queried GPU information */
+
+typedef struct _display_device_rec {
+    NvCfgDisplayDeviceInformation info;
+    int info_valid;
+    unsigned int mask;
+} DisplayDeviceRec, *DisplayDevicePtr;
+
+typedef struct _device_rec {
+    NvCfgDevice dev;
+    int crtcs;
+    char *name;
+    unsigned int displayDeviceMask;
+    int nDisplayDevices;
+    DisplayDevicePtr displayDevices;    
+} DeviceRec, *DevicePtr;
+
+typedef struct {
+    int nDevices;
+    DevicePtr devices;
+} DevicesRec, *DevicesPtr;
 
 
 /* util.c */
@@ -151,7 +213,7 @@
 char *nvstrcat(const char *str, ...);
 void *nvrealloc(void *ptr, size_t size);
 char *nvstrdup(const char *s);
-void nvfree(char *s);
+void nvfree(void *s);
 int copy_file(const char *srcfile, const char *dstfile, mode_t mode);
 
 int directory_exists(const char *dir);
@@ -180,8 +242,13 @@
 int update_modules(XConfigPtr config);
 int update_screen(Options *op, XConfigPtr config, XConfigScreenPtr screen);
 XConfigLayoutPtr get_layout(Options *op, XConfigPtr config);
+int update_extensions(Options *op, XConfigPtr config);
+int update_server_flags(Options *op, XConfigPtr config);
 
 /* multiple_screens.c */
+
+DevicesPtr find_devices(Options *op);
+void free_devices(DevicesPtr devs);
 
 int apply_multi_screen_options(Options *op, XConfigPtr config,
                                XConfigLayoutPtr layout);
@@ -193,9 +260,22 @@
 /* options.c */
 
 void remove_option_from_list(XConfigOptionPtr *list, const char *name);
+void set_boolean_option(Options *op, const int c, const int boolval);
+void validate_composite(Options *op, XConfigPtr config);
 void update_options(Options *op, XConfigScreenPtr screen);
 
 /* lscf.c */
 int update_scf_depth(int depth);
+int read_scf_depth(int *depth);
+
+/* query_gpu_info.c */
+
+int query_gpu_info(Options *op);
+
+/* extract_edids.c */
+
+int extract_edids(Options *op);
+
+
 
 #endif /* __NVIDIA_XCONFIG_H__ */

Modified: packages/nvidia-xconfig/trunk/option_table.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/option_table.h?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/option_table.h (original)
+++ packages/nvidia-xconfig/trunk/option_table.h Tue Jun 24 17:53:25 2008
@@ -5,8 +5,7 @@
  *
  * shortname - this is the one character short option name
  *
- * flags - bitmask; possible values are NVGETOPT_HAS_ARGUMENT and
- * NVGETOPT_IS_BOOLEAN
+ * flags - bitmask; see NVGETOPT_ constants in nvgetopt.h
  *
  * description - text for use by print_help() to describe the option
  */
@@ -21,20 +20,67 @@
 #define FORCE_GENERATE_OPTION               9
 #define MOUSE_LIST_OPTION                   10
 #define MODE_OPTION                         11
-#define NVIDIA_CFG_PATH_OPTION              12
-#define NVAGP_OPTION                        13
-#define SLI_OPTION                          14
-#define DISABLE_SCF_OPTION                  15
-#define DIGITAL_VIBRANCE_OPTION             16
-#define TRANSPARENT_INDEX_OPTION            17
-#define STEREO_OPTION                       18
-#define ROTATE_OPTION                       19
-
-#define XCONFIG_OPTION_START        128
+#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
+#define ACPID_SOCKET_PATH_OPTION            34
+#define HANDLE_SPECIAL_KEYS_OPTION          35
+
+/*
+ * To add a boolean option to nvidia-xconfig:
+ *
+ * 1) Add the definition of the constant to the "Boolean options" list
+ *    in nvidia-xconfig.h
+ *
+ * 2) add an entry in the below (alphabetized) __options[] table; for
+ *    the second field in the __options[] table, specify
+ *    XCONFIG_BOOL_VAL(<your-new-constant>)
+ *
+ * 3) add an entry to the __options[] table at the top of options.c
+ *    with the constant and the option name as it should appear in the X
+ *    config file.
+ *
+ * nvidia-xconfig.c:parse_commandline() will record in
+ * op->boolean_options whether the commandline option was specified,
+ * and will record in op->boolean_option_values whether the option was
+ * specified to be true or false.  options.c:update_options() will
+ * apply your boolean option to the X config file.
+ */
+
+
+#define XCONFIG_BOOL_OPTION_START        128
+
+
+/*
+ * The XCONFIG_BOOL_VAL() macro packs boolean options into the val
+ * field of the __option[] table; these are above 128, so that
+ * isalpha(3) returns FALSE for them.
+ */
+
+#define XCONFIG_BOOL_VAL(x) (XCONFIG_BOOL_OPTION_START + (x))
 
 /*
  * The OPTION_HELP_ALWAYS flag is or'ed into the nvgetopts flags, but
- * is used by print_help() to know whether to print the help
+ * is only used by print_help() to know whether to print the help
  * information for that option all the time, or only when advanced
  * help is requested.
  */
@@ -44,81 +90,178 @@
 static const NVGetoptOption __options[] = {
     /* These options are printed by "nvidia-xconfig --help" */
 
-    { "xconfig", 'c', NVGETOPT_HAS_ARGUMENT | OPTION_HELP_ALWAYS,
+    { "xconfig", 'c', NVGETOPT_STRING_ARGUMENT | OPTION_HELP_ALWAYS, NULL,
       "Use [XCONFIG] as the input X config file; if this option is not "
       "specified, then the same search path used by the X server will be "
       "used to find the X configuration file." },
 
-    { "output-xconfig", 'o', NVGETOPT_HAS_ARGUMENT | OPTION_HELP_ALWAYS,
+    { "output-xconfig", 'o',
+      NVGETOPT_STRING_ARGUMENT | OPTION_HELP_ALWAYS, NULL,
       "Use [OUTPUT-XCONFIG] as the output X configuration file; if this "
       "option is not specified, then the input X configuration filename will "
-      "also be used as the output filename." },
-
-    { "silent", 's', OPTION_HELP_ALWAYS,
+      "also be used as the output X configuration filename." },
+
+    { "silent", 's', OPTION_HELP_ALWAYS, NULL,
       "Run silently; no messages will be printed to stdout, except for "
       "warning and error messages to stderr." },
 
-    { "tree", 't',  OPTION_HELP_ALWAYS,
+    { "tree", 't',  OPTION_HELP_ALWAYS, NULL,
       "Read the X configuration file, print to stdout the X "
       "configuration data in a tree format, and exit." },
 
-    { "version", 'v', OPTION_HELP_ALWAYS,
+    { "version", 'v', OPTION_HELP_ALWAYS, NULL,
       "Print the nvidia-xconfig version and exit." },
 
-    { "help", 'h', OPTION_HELP_ALWAYS, "Print usage information for the "
-      "common commandline options and exit." },
-
-    { "advanced-help", 'A', OPTION_HELP_ALWAYS, "Print usage information "
-      "for the common commandline options as well as the advanced options, "
-      "and then exit." },
+    { "help", 'h', OPTION_HELP_ALWAYS,  NULL,
+      "Print usage information for the common commandline options and exit." },
+
+    { "advanced-help", 'A', OPTION_HELP_ALWAYS,  NULL,
+      "Print usage information for the common commandline options as well "
+      "as the advanced options, and then exit." },
 
     /* These options are only printed by "nvidia-xconfig --advanced-help" */
 
-    { "allow-ddcci", XCONFIG_OPTION_START + ALLOW_DDCCI_OPTION,
-      NVGETOPT_IS_BOOLEAN, "Enables or disables DDC/CI support in the "
+    { "acpid-socket-path", 
+      ACPID_SOCKET_PATH_OPTION, 
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, NULL,
+      "Set this option to specify an alternate path to the Linux ACPI daemon "
+      "(acpid)'s socket, which the NVIDIA X driver will use to connect to "
+      "acpid." },
+
+    { "add-argb-glx-visuals",
+      XCONFIG_BOOL_VAL(ADD_ARGB_GLX_VISUALS_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN,  NULL,
+      "Enables or disables support for OpenGL rendering into 32-bit ARGB "
+      "windows and pixmaps." },
+
+    { "allow-ddcci", XCONFIG_BOOL_VAL(ALLOW_DDCCI_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN,  NULL, "Enables or disables DDC/CI support in the "
       "NV-CONTROL X extension." },
 
-    { "allow-dfp-stereo",
-      XCONFIG_OPTION_START + ALLOW_DFP_STEREO_OPTION, NVGETOPT_IS_BOOLEAN,
+    { "allow-dfp-stereo", XCONFIG_BOOL_VAL(ALLOW_DFP_STEREO_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
       "Enable or disable the \"AllowDFPStereo\" X configuration option." },
 
     { "allow-glx-with-composite",
-      XCONFIG_OPTION_START + ALLOW_GLX_WITH_COMPOSITE_OPTION,
-      NVGETOPT_IS_BOOLEAN, "Enable or disable the \"AllowGLXWithComposite\" "
-      "X configuration option." },
-
-    { "bandwidth-test",
-      XCONFIG_OPTION_START + NO_BANDWIDTH_TEST_OPTION, NVGETOPT_IS_BOOLEAN,
+      XCONFIG_BOOL_VAL(ALLOW_GLX_WITH_COMPOSITE_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable the \"AllowGLXWithComposite\" X configuration "
+      "option." },
+
+    { "bandwidth-test", XCONFIG_BOOL_VAL(NO_BANDWIDTH_TEST_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
       "Disable or enable the \"NoBandWidthTest\" X configuration option." },
 
-    { "dac-8bit", XCONFIG_OPTION_START + DAC_8BIT_OPTION, NVGETOPT_IS_BOOLEAN,
+    { "cool-bits", COOL_BITS_OPTION,
+      NVGETOPT_INTEGER_ARGUMENT | NVGETOPT_ALLOW_DISABLE, NULL,
+      "Enable or disable the \"Coolbits\" X configuration option. Setting this "
+      "option will enable support in the NV-CONTROL X extension for manipulating "
+      "GPU clock settings. Default value is 0.\n"
+      "WARNING: this may cause system damage and void warranties." },
+
+    { "composite",
+      XCONFIG_BOOL_VAL(COMPOSITE_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable the \"Composite\" X extension." },
+
+    { "connect-to-acpid",
+      XCONFIG_BOOL_VAL(CONNECT_TO_ACPID_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable the \"ConnectToAcpid\" X configuration option.  "
+      "If this option is set, the NVIDIA X driver will attempt to connect "
+      "to the Linux ACPI daemon (acpid).  Set this option to off to prevent "
+      "the X driver from attempting to connect to acpid." },
+
+    { "constant-dpi",
+      XCONFIG_BOOL_VAL(CONSTANT_DPI_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable the \"ConstantDPI\" X configuration option, "
+      "which controls whether the NVIDIA X driver maintains a constant "
+      "dots per inch (DPI) value by recomputing the reported size in "
+      "millimeters of the X screen when XRandR changes the size in pixels "
+      "of the X screen." },
+
+    { "custom-edid", CUSTOM_EDID_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, "CUSTOM-EDID",
+      "Enable or disable the  \"CustomEDID\" X configuration option; "
+      "setting this option forces the X driver to use the EDID specified."
+      "This option is a semicolon-separated list of pairs of display device names "
+      "and filename pairs; e.g \"CRT-0:\\tmp\\edid.bin\". Note that a display "
+      "device name must always be specified even if only one EDID is"
+      " specified. " },
+
+    { "dac-8bit", XCONFIG_BOOL_VAL(DAC_8BIT_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
       "Most Quadro parts by default use a 10 bit color look up table (LUT) "
       "by default; setting this option to TRUE forces these graphics chips "
       "to use an 8 bit (LUT)." },
     
-    { "ddc",
-      XCONFIG_OPTION_START + IGNORE_EDID_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Synonym for \"ignore-edid\"" },
-
-    { "depth", 'd', NVGETOPT_HAS_ARGUMENT,
-      "Set the default depth to [DEPTH]; valid values are 8, 15, 16 and 24." },
-
-    { "digital-vibrance", DIGITAL_VIBRANCE_OPTION,
-      NVGETOPT_IS_INTEGER | NVGETOPT_HAS_ARGUMENT,
-      "Enables digital vibrance control.  Valid values are 0-255." },
-
-    { "enable-all-gpus", 'a', 0,
+    { "depth", 'd', NVGETOPT_INTEGER_ARGUMENT, NULL,
+      "Set the default depth to [DEPTH]; valid values for [DEPTH] are "
+      "8, 15, 16, 24, and 30." },
+
+    { "disable-glx-root-clipping",
+      XCONFIG_BOOL_VAL(DISABLE_GLX_ROOT_CLIPPING_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL, "Disable or enable clipping OpenGL rendering "
+      "to the root window via the \"DisableGLXRootClipping\" "
+      "X configuration option." },
+
+    { "damage-events",
+      XCONFIG_BOOL_VAL(DAMAGE_EVENTS_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL, "Use OS-level events to notify the X server "
+      "when a direct-rendering client has performed rendering that needs to be "
+      "composited to the screen.  Improves performance when using GLX with the "
+      "composite extension." },
+    
+#if defined(NV_SUNOS)
+    { "disable-scf", DISABLE_SCF_OPTION, 0, NULL,
+      "On Solaris, nvidia-xconfig updates the service configuration "
+      "repository with the default depth being set in the X configuration "
+      "file.  The property 'default_depth' of the group 'options' in the "
+      "selection 'application/x11/x11-server' is set to the default depth. "
+      "Use this option to disable the service configuration repository "
+      "update." },
+#endif
+
+    { "dynamic-twinview", XCONFIG_BOOL_VAL(DYNAMIC_TWINVIEW_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable support for dynamically configuring TwinView." },
+    
+    { "enable-acpi-hotkeys",
+      XCONFIG_BOOL_VAL(ENABLE_ACPI_HOTKEYS_BOOL_OPTION), 
+      NVGETOPT_IS_BOOLEAN, NULL,
+      "The \"EnableACPIHotkeys\" option can be specified to override the "
+      "NVIDIA X driver's default decision to enable or disable ACPI "
+      "display change hotkey events." },
+
+    { "enable-all-gpus", 'a', 0, NULL,
       "Configure an X screen on every GPU in the system." },
     
     { "exact-mode-timings-dvi",
-      XCONFIG_OPTION_START + EXACT_MODE_TIMINGS_DVI_OPTION,
-      NVGETOPT_IS_BOOLEAN, "Forces the initialization of the X server with "
+      XCONFIG_BOOL_VAL(EXACT_MODE_TIMINGS_DVI_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
+      "Forces the initialization of the X server with "
       "the exact timings specified in the ModeLine." },
 
-    { "flip", XCONFIG_OPTION_START + NOFLIP_OPTION, NVGETOPT_IS_BOOLEAN,
+    { "extract-edids-from-file", 'E', NVGETOPT_STRING_ARGUMENT, "FILE",
+      "Extract any raw EDID byte blocks contained in the specified X "
+      "log file [LOG]; raw EDID bytes are printed by the NVIDIA X driver to "
+      "the X log as hexidecimal when verbose logging is enabled with the "
+      "\"-logverbose 6\" X server commandline option.  Any extracted EDIDs "
+      "are then written as binary data to individual files.  These files "
+      "can later be used by the NVIDIA X driver through the \"CustomEDID\" "
+      "X configuration option." },
+    
+    { "extract-edids-output-file", 
+      EXTRACT_EDIDS_OUTPUT_FILE_OPTION, NVGETOPT_STRING_ARGUMENT, "FILENAME",
+      "When the '--extract-edids-from-log' option is used, nvidia-xconfig "
+      "writes any extracted EDID to a file, typically \"edid.bin\" in the "
+      "current directory.  Use this option to specify an alternate "
+      "filename.  Note that nvidia-xconfig, if necessary, will append a "
+      "unique number to the EDID filename, to avoid overwriting existing "
+      "files (e.g., \"edid.bin.1\" if \"edid.bin\" already exists)." },
+
+    { "flip", XCONFIG_BOOL_VAL(NOFLIP_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
       "Enable or disable OpenGL flipping" },
 
-    { "force-generate", FORCE_GENERATE_OPTION, 0,
+    { "force-generate", FORCE_GENERATE_OPTION, 0, NULL,
       "Force generation of a new X config file, ignoring any existing "
       "system X config file.  This is not typically recommended, as things "
       "like the mouse protocol, keyboard layout, font paths, etc, are setup "
@@ -127,24 +270,26 @@
       "X config file for the basis of anything that nvidia-xconfig creates." },
 
     { "force-stereo-flipping",
-      XCONFIG_OPTION_START + FORCE_STEREO_FLIPPING_OPTION, NVGETOPT_IS_BOOLEAN,
+      XCONFIG_BOOL_VAL(FORCE_STEREO_FLIPPING_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
       "Normally, stereo flipping is only performed when a stereo drawable is "
       "visible. This option forces stereo flipping even when no stereo "
       "drawables are visible." },
 
-    { "ignore-edid",
-      XCONFIG_OPTION_START + IGNORE_EDID_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Disable or enable probing of EDID (Extended Display Identification "
-      "Data) from your monitor." },
-
-    { "use-edid-freqs",
-      XCONFIG_OPTION_START + USE_EDID_FREQS_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Allow or disallow the X server to use the HorizSync and VertRefresh "
-      "ranges given in a display device's EDID, if any.  EDID provided "
-      "range information will override the HorizSync and VertRefresh ranges "
-      "specified in the Monitor section." },
-
-    { "keyboard", KEYBOARD_OPTION, NVGETOPT_HAS_ARGUMENT,
+    { "handle-special-keys", HANDLE_SPECIAL_KEYS_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, "WHEN",
+      "Specify when the X server should use the builtin keyboard handler to "
+      "process special key combinations (such as Ctrl+Alt+Backspace); see "
+      "the X configuration man page for details.  The value of [WHEN] can be "
+      "'Always', 'Never', or 'WhenNeeded'." },
+
+    { "include-implicit-metamodes",
+      XCONFIG_BOOL_VAL(INCLUDE_IMPLICIT_METAMODES_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable the \"IncludeImplicitMetaModes\" X configuration "
+      "option." },
+
+    { "keyboard", KEYBOARD_OPTION, NVGETOPT_STRING_ARGUMENT, NULL,
       "When generating a new X configuration file (which happens when no "
       "system X configuration file can be found, or the '--force-generate' "
       "option is specified), use [KEYBOARD] as the keyboard type, rather "
@@ -152,25 +297,152 @@
       "For a list of possible keyboard types, see the '--keyboard-list' "
       "option." },
 
-    { "keyboard-driver", KEYBOARD_DRIVER_OPTION, NVGETOPT_HAS_ARGUMENT,
+    { "keyboard-driver", KEYBOARD_DRIVER_OPTION,
+      NVGETOPT_STRING_ARGUMENT, "DRIVER",
       "In most cases nvidia-xconfig can automatically determine the correct "
       "keyboard driver to use (either 'kbd' or 'keyboard'). Use this "
       "option to override what nvidia-xconfig detects. Typically, if you are "
-      "using an X.org X server, use 'kdb'; if you are using an XFree86 X "
+      "using an X.Org X server, use 'kdb'; if you are using an XFree86 X "
       "server, use 'keyboard'." },
 
-    { "keyboard-list", KEYBOARD_LIST_OPTION, 0,
+    { "keyboard-list", KEYBOARD_LIST_OPTION, 0, NULL,
       "Print to stdout the available keyboard types recognized by the "
       "'--keyboard' option, and then exit." },
 
-    { "layout", LAYOUT_OPTION, NVGETOPT_HAS_ARGUMENT,
+    { "layout", LAYOUT_OPTION, NVGETOPT_STRING_ARGUMENT, NULL,
       "The nvidia-xconfig utility operates on a Server Layout within the X "
       "configuration file.  If this option is specified, the layout named "
       "[LAYOUT] in the X configuration file will be used.  If this option is "
       "not specified, the first Server Layout in the X configuration "
       "file is used." },
 
-    { "screen", SCREEN_OPTION, NVGETOPT_HAS_ARGUMENT,
+    { "load-kernel-module",
+      XCONFIG_BOOL_VAL(LOAD_KERNEL_MODULE_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
+      "Allow or disallow NVIDIA Linux X driver module to load the NVIDIA "
+      "Linux kernel module automatically."},
+    
+    { "logo",
+      XCONFIG_BOOL_VAL(NOLOGO_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Disable or enable the \"NoLogo\" X configuration option." },
+
+    { "logo-path", LOGO_PATH_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, "PATH",
+      "Set the path to the PNG file to be used as the logo splash screen at X "
+      "server startup." },
+
+    { "mode",
+      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." },
+
+    { "mouse", MOUSE_OPTION, NVGETOPT_STRING_ARGUMENT, NULL,
+      "When generating a new X configuration file (which happens when no "
+      "system X configuration file can be found, or the '--force-generate' "
+      "option is specified), use [MOUSE] as the mouse type, rather than "
+      "attempting to probe the system for the mouse type.  For a list of "
+      "possible mouse types, see the '--mouse-list' option." },
+
+    { "mouse-list", MOUSE_LIST_OPTION, 0, NULL,
+      "Print to stdout the available mouse types recognized by the "
+      "'--mouse' option, and then exit." },
+
+    { "multigpu", MULTI_GPU_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, NULL,
+      "Enable or disable MultiGPU.  Valid values for [MULTIGPU] are 'Off', 'On',"
+      " 'Auto', 'AFR', 'SFR', 'AA'." },
+
+    { "multisample-compatibility",
+      XCONFIG_BOOL_VAL(MULTISAMPLE_COMPATIBILITY_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable the use of separate front and "
+      "back multisample buffers." },
+
+    { "nvagp", NVAGP_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, NULL,
+      "Set the NvAGP X config option value.  Possible values are 0 (no AGP), "
+      "1 (NVIDIA's AGP), 2 (AGPGART), 3 (try AGPGART, then try NVIDIA's AGP); "
+      "these values can also be specified as 'none', 'nvagp', 'agpgart', or "
+      "'any'." },
+
+    { "nvidia-cfg-path",
+      NVIDIA_CFG_PATH_OPTION, NVGETOPT_STRING_ARGUMENT, "PATH",
+      "The nvidia-cfg library is used to communicate with the NVIDIA kernel "
+      "module to query basic properties of every GPU in the system.  This "
+      "library is typically only used by nvidia-xconfig when configuring "
+      "multiple X screens.  This option tells nvidia-xconfig where to look "
+      "for this library (in case it cannot find it on its own).  This option "
+      "should normally not be needed." },
+
+    { "only-one-x-screen", '1', 0,
+      "Disable all but one X screen." },
+
+    { "overlay",
+      XCONFIG_BOOL_VAL(OVERLAY_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable the \"Overlay\" X configuration option." },
+
+    { "cioverlay",
+      XCONFIG_BOOL_VAL(CIOVERLAY_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable the color index overlay." },
+
+    { "overlay-default-visual",
+      XCONFIG_BOOL_VAL(OVERLAY_DEFAULT_VISUAL_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable the \"OverlayDefaultVisual\" "
+      "X configuration option." },
+
+    { "transparent-index", TRANSPARENT_INDEX_OPTION,
+      NVGETOPT_INTEGER_ARGUMENT | NVGETOPT_ALLOW_DISABLE, "INDEX",
+      "Pixel to use as transparent when using color index overlays.  "
+      "Valid values for [TRANSPARENT-INDEX] are 0-255."},
+
+    { "post-tree", 'T', 0, NULL,
+      "Like the '--tree' option, but goes through the full process of "
+      "applying any user requested updates to the X configuration, before "
+      "printing the final configuration to stdout in a tree format.  "
+      "Effectively, this option just causes the configuration to be printed "
+      "to stdout as a tree instead of writing the results to file." },
+
+    { "power-connector-check",
+      XCONFIG_BOOL_VAL(NO_POWER_CONNECTOR_CHECK_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
+      "Disable or enable the \"NoPowerConnectorCheck\" "
+      "X configuration option." },
+
+    { "probe-all-gpus", XCONFIG_BOOL_VAL(PROBE_ALL_GPUS_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
+      "Disable or enable the \"ProbeAllGpus\" X configuration option." },
+      
+      
+    { "query-gpu-info", QUERY_GPU_INFO_OPTION, 0, NULL,
+      "Print information about all recognized NVIDIA GPUs in the system." },
+    
+    { "randr-rotation",
+      XCONFIG_BOOL_VAL(RANDR_ROTATION_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable the \"RandRRotation\" X configuration option." },
+
+    { "render-accel",
+      XCONFIG_BOOL_VAL(RENDER_ACCEL_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable the \"RenderAccel\" X configuration option." },
+
+    { "render-extension",
+      XCONFIG_BOOL_VAL(NO_RENDER_EXTENSION_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
+      "Disable or enable the \"NoRenderExtension\" X configuration option." },
+
+    { "rotate",
+      ROTATE_OPTION, NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, NULL,
+      "Enable or disable the \"Rotate\" X configuration option.  Valid values "
+      "for [ROTATE] are 'normal', 'left', 'CCW', 'inverted', "
+      "'right', and 'CW'.  Rotation can be disabled " },
+ 
+    { "screen", SCREEN_OPTION, NVGETOPT_STRING_ARGUMENT, NULL,
       "The nvidia-xconfig utility operates on one or more screens within a "
       "Server Layout in the X configuration file.  If this option is "
       "specified, the screen named [SCREEN] in the X configuration file will "
@@ -178,100 +450,9 @@
       "selected Server Layout in the X configuration file "
       "will be used used." },
 
-    { "load-kernel-module",
-      XCONFIG_OPTION_START + LOAD_KERNEL_MODULE_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Allow or disallow NVIDIA Linux X driver module to load the NVIDIA "
-      "Linux kernel module automatically."},
-    
-    { "logo",
-      XCONFIG_OPTION_START + NOLOGO_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Disable or enable the \"NoLogo\" X configuration option." },
-
-    { "mode", MODE_OPTION, NVGETOPT_IS_BOOLEAN | NVGETOPT_HAS_ARGUMENT,
-      "Adds or removes the specified mode from the mode list." },
-
-    { "mouse", MOUSE_OPTION, NVGETOPT_HAS_ARGUMENT,
-      "When generating a new X configuration file (which happens when no "
-      "system X configuration file can be found, or the '--force-generate' "
-      "option is specified), use [MOUSE] as the mouse type, rather than "
-      "attempting to probe the system for the mouse type.  For a list of "
-      "possible mouse types, see the '--mouse-list' option." },
-
-    { "mouse-list", MOUSE_LIST_OPTION, 0,
-      "Print to stdout the available mouse types recognized by the "
-      "'--mouse' option, and then exit." },
-
-    { "multisample-compatibility",
-      XCONFIG_OPTION_START + MULTISAMPLE_COMPATIBILITY_OPTION,
-      NVGETOPT_IS_BOOLEAN, "Enable or disable the use of separate front and "
-      "back multisample buffers." },
-
-    { "nvagp", NVAGP_OPTION, NVGETOPT_HAS_ARGUMENT,
-      "Set the NvAGP X config option value.  Possible values are 0 (no AGP), "
-      "1 (NVIDIA's AGP), 2 (AGPGART), 3 (try AGPGART, then try NVIDIA's AGP); "
-      "these values can also be specified as 'none', 'nvagp', 'agpgart', or "
-      "'any'." },
-
-    { "nvidia-cfg-path", NVIDIA_CFG_PATH_OPTION, NVGETOPT_HAS_ARGUMENT,
-      "The nvidia-cfg library is used to communicate with the NVIDIA kernel "
-      "module to query basic properties of every GPU in the system.  This "
-      "library is typically only used by nvidia-xconfig when configuring "
-      "multiple X screens.  This option tells nvidia-xconfig where to look "
-      "for this library (in case it cannot find it on its own).  This option "
-      "should normally not be needed." },
-
-    { "only-one-x-screen", '1', 0,
-      "Disable all but one X screen." },
-
-    { "overlay",
-      XCONFIG_OPTION_START + OVERLAY_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Enable or disable the \"Overlay\" X configuration option." },
-
-    { "cioverlay",
-      XCONFIG_OPTION_START + CIOVERLAY_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Enable or disable the color index overlay." },
-
-    { "transparent-index", TRANSPARENT_INDEX_OPTION,
-      NVGETOPT_IS_INTEGER | NVGETOPT_HAS_ARGUMENT,
-      "Pixel to use as transparent when using color index overlays.  "
-      "Valid values are 0-255."},
-
-    { "overlay-default-visual",
-      XCONFIG_OPTION_START + OVERLAY_DEFAULT_VISUAL_OPTION,
-      NVGETOPT_IS_BOOLEAN, "Enable or disable the \"OverlayDefaultVisual\" "
-      "X configuration option." },
-
-    { "post-tree", 'T', 0,
-      "Like the '--tree' option, but goes through the full process of "
-      "applying any user requested updates to the X configuration, before "
-      "printing the final configuration to stdout in a tree format.  "
-      "Effectively, this option just causes the configuration to be printed "
-      "to stdout as a tree instead of writing the results to file." },
-
-    { "power-connector-check",
-      XCONFIG_OPTION_START + NO_POWER_CONNECTOR_CHECK_OPTION,
-      NVGETOPT_IS_BOOLEAN, "Disable or enable the \"NoPowerConnectorCheck\" "
-      "X configuration option." },
-
-    { "randr-rotation",
-      XCONFIG_OPTION_START + RANDR_ROTATION_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Enable or disable the \"RandRRotation\" X configuration option." },
-
-    { "rotate",
-      ROTATE_OPTION, NVGETOPT_HAS_ARGUMENT,
-      "Enable or disable the \"Rotate\" X configuration option.  Valid values "
-      "are 'normal', 'left', 'inverted', and 'right'." },
-
-    { "render-accel",
-      XCONFIG_OPTION_START + RENDER_ACCEL_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Enable or disable the \"RenderAccel\" X configuration option." },
-
-    { "render-extension",
-      XCONFIG_OPTION_START + NO_RENDER_EXTENSION_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Disable or enable the \"NoRenderExtension\" X configuration option." },
-
     { "separate-x-screens",
-      XCONFIG_OPTION_START + SEPARATE_X_SCREENS_OPTION, NVGETOPT_IS_BOOLEAN,
+      XCONFIG_BOOL_VAL(SEPARATE_X_SCREENS_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
       "A GPU that supports multiple simultaneous display devices can either "
       "drive these display devices in TwinView, or as separate X screens.  "
       "When the '--separate-x-screens' option is specified, each GPU on which "
@@ -281,53 +462,123 @@
       "README description of \"Separate X Screens on One GPU\" for further "
       "details." },
 
-    { "sli", SLI_OPTION, NVGETOPT_HAS_ARGUMENT,
-      "Enable or disable SLI.  Valid options are 'Off', 'Auto', 'AFR', 'SFR', "
-      "and 'SLIAA'." },
-
-    { "stereo", STEREO_OPTION, NVGETOPT_IS_INTEGER | NVGETOPT_HAS_ARGUMENT,
-      "Enable/Disable the stereo mode.  Valid options are: 1 (DCC glasses), "
-      "2 (Blueline glasses), 3 (Onboard stereo), 4 (TwinView clone mode "
-      "stereo), 5 (SeeReal digital flat panel), 6 (Sharp3D digital flat "
-      "panel)." },
-
-    { "twinview", XCONFIG_OPTION_START + TWINVIEW_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Enable or disable TwinView." },
-
+    { "sli", SLI_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, NULL,
+      "Enable or disable SLI.  Valid values for [SLI] are 'Off', 'On', 'Auto', "
+      "'AFR', 'SFR', 'AA', 'AFRofAA'." },
+
+    { "stereo", STEREO_OPTION,
+      NVGETOPT_INTEGER_ARGUMENT | NVGETOPT_ALLOW_DISABLE, NULL,
+      "Enable or disable the stereo mode.  Valid values for [STEREO] are: 1 "
+      "(DCC glasses), 2 (Blueline glasses), 3 (Onboard stereo), 4 (TwinView "
+      "clone mode stereo), 5 (SeeReal digital flat panel), 6 (Sharp3D "
+      "digital flat panel)." },
+
+    { "tv-standard", TV_STANDARD_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, "TV-STANDARD",
+      "Enable or disable the \"TVStandard\" X configuration option. Valid " 
+      "values for \"TVStandard\" are: \"PAL-B\", \"PAL-D\", \"PAL-G\", "
+      "\"PAL-H\", \"PAL-I\", \"PAL-K1\", \"PAL-M\", \"PAL-N\", \"PAL-NC\", " 
+      "\"NTSC-J\", \"NTSC-M\", \"HD480i\", \"HD480p\", \"HD720p\", "
+      "\"HD1080i\", \"HD1080p\", \"HD576i\", \"HD576p\"." },
+    
+    { "tv-out-format", TV_OUT_FORMAT_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, "TV-OUT-FORMAT",
+      "Enable or disable the \"TVOutFormat\" X configuration option. Valid "
+      "values for \"TVOutFormat\" are: \"SVIDEO\" and \"COMPOSITE\"." },
+  
+    { "tv-over-scan", TV_OVER_SCAN_OPTION,
+      NVGETOPT_DOUBLE_ARGUMENT | NVGETOPT_ALLOW_DISABLE, NULL,
+      "Enable or disable the \"TVOverScan\" X configuration option. Valid "
+      "values are decimal values in the range 1.0 and 0.0." }, 
+          
+    { "twinview", XCONFIG_BOOL_VAL(TWINVIEW_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL, "Enable or disable TwinView." },
+
+    { "twinview-orientation", TWINVIEW_ORIENTATION_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, "ORIENTATION",
+      "Specify the TwinViewOrientation.  Valid values for [ORIENTATION] are: "
+      "\"RightOf\" (the default), \"LeftOf\", \"Above\", \"Below\", or "
+      "\"Clone\"." },
+    
     { "twinview-xinerama-info",
-      XCONFIG_OPTION_START + NO_TWINVIEW_XINERAMA_INFO_OPTION,
-      NVGETOPT_IS_BOOLEAN,
+      XCONFIG_BOOL_VAL(NO_TWINVIEW_XINERAMA_INFO_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
       "Prohibits providing Xinerama information when in TwinView." },
 
+    { "twinview-xinerama-info-order",
+      TWINVIEW_XINERAMA_INFO_ORDER_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, NULL,
+      "Enable or disable the \"TwinViewXineramaInfoOrder\" X configuration "
+      "option.  [TWINVIEW-XINERAMA-INFO-ORDER] is a comma-separated list "
+      "of display device names that describe the order in which "
+      "TwinViewXineramaInfo should be reported.  E.g., \"CRT, DFP, TV\"." },
+
     { "ubb",
-      XCONFIG_OPTION_START + UBB_OPTION, NVGETOPT_IS_BOOLEAN,
+      XCONFIG_BOOL_VAL(UBB_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
       "Enable or disable the \"UBB\" X configuration option." },
 
+    { "use-edid",
+      XCONFIG_BOOL_VAL(USE_EDID_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable use of the EDID (Extended Display Identification "
+      "Data) from your display device(s).  The EDID will be used for driver "
+      "operations such as building lists of available modes, determining "
+      "valid frequency ranges, and computing the DPI (Dots Per Inch).  "
+      "This option defaults to TRUE (the NVIDIA X driver will use the EDID, "
+      "when available).  It is NOT recommended that you use this option to "
+      "globally disable use of the EDID; instead, use '--no-use-edid-freqs' "
+      "or '--no-use-edid-dpi' to disable specific uses of the EDID." },
+
+    { "use-edid-dpi",
+      XCONFIG_BOOL_VAL(USE_EDID_DPI_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable use of the physical size information in the display "
+      "device's EDID, if any, to compute the DPI (Dots Per Inch) of the X "
+      "screen.  This option defaults to TRUE (the NVIDIA X driver uses the "
+      "EDID's physical size, when available, to compute the DPI)." },
+      
+    { "use-edid-freqs",
+      XCONFIG_BOOL_VAL(USE_EDID_FREQS_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable use of the HorizSync and VertRefresh "
+      "ranges given in a display device's EDID, if any.  EDID provided "
+      "range information will override the HorizSync and VertRefresh ranges "
+      "specified in the Monitor section.  This option defaults to TRUE (the "
+      "NVIDIA X driver will use frequency information from the EDID, when "
+      "available)." },
+
     { "use-int10-module",
-      XCONFIG_OPTION_START + USE_INT10_MODULE_OPTION, NVGETOPT_IS_BOOLEAN,
+      XCONFIG_BOOL_VAL(USE_INT10_MODULE_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
       "Enable use of the X Int10 module to soft-boot all secondary cards, "
       "rather than POSTing the cards through the NVIDIA kernel module." },
 
-    { "x-prefix", X_PREFIX_OPTION, NVGETOPT_HAS_ARGUMENT,
+    { "use-display-device", USE_DISPLAY_DEVICE_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, "DISPLAY-DEVICE",
+      "Force the X driver to use the display device specified." },
+
+    { "use-events", 
+      XCONFIG_BOOL_VAL(USE_EVENTS_BOOL_OPTION), NVGETOPT_IS_BOOLEAN, NULL,
+      "Enable or disable \"UseEvents\" X configuration option. Setting this " 
+      "option will enable the X driver to use the system events in some cases "
+      "when it is waiting for the hardware. With this option X driver sets an "
+      "event handler and waits for the hardware through the poll() system "
+      "call. This option defaults to FALSE." },
+     
+    { "virtual", VIRTUAL_OPTION,
+      NVGETOPT_STRING_ARGUMENT | NVGETOPT_ALLOW_DISABLE, "WIDTHxHEIGHT",
+      "Specify the virtual screen resolution." },
+      
+    { "x-prefix", X_PREFIX_OPTION, NVGETOPT_STRING_ARGUMENT, NULL,
       "The X installation prefix; the default is /usr/X11R6/.  Only "
       "under rare circumstances should this option be needed." },
 
-    { "xinerama", XCONFIG_OPTION_START + XINERAMA_OPTION, NVGETOPT_IS_BOOLEAN,
-      "Enable or disable Xinerama." },
+    { "xinerama", XCONFIG_BOOL_VAL(XINERAMA_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL, "Enable or disable Xinerama." },
 
     { "xvmc-uses-textures",
-      XCONFIG_OPTION_START + XVMC_USES_TEXTURES_OPTION, NVGETOPT_IS_BOOLEAN,
+      XCONFIG_BOOL_VAL(XVMC_USES_TEXTURES_BOOL_OPTION),
+      NVGETOPT_IS_BOOLEAN, NULL,
       "Forces XvMC to use the 3D engine for XvMCPutSurface requests rather "
       "than the video overlay." },
       
-#if defined(NV_SUNOS)
-    { "disable-scf", DISABLE_SCF_OPTION, 0,
-      "On Solaris, nvidia-xconfig updates the service configuration repository "
-      "with the default depth being set in the X configuration file. " 
-      "The property 'default_depth' of the group 'options' in the "
-      "selection 'application/x11/x11-server' is set to the default depth. "
-      "Use this option to disable the service configuration repository update." },
-#endif
-     
-    { NULL, 0 ,  0, NULL },
+    { NULL, 0, 0, NULL, NULL },
 };

Modified: packages/nvidia-xconfig/trunk/options.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/options.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/options.c (original)
+++ packages/nvidia-xconfig/trunk/options.c Tue Jun 24 17:53:25 2008
@@ -27,6 +27,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 
 #include "nvidia-xconfig.h"
 #include "xf86Parser.h"
@@ -40,33 +41,44 @@
 
 static const NvidiaXConfigOption __options[] = {
     
-    { NOLOGO_OPTION,                    TRUE,  "NoLogo" },
-    { UBB_OPTION,                       FALSE, "UBB" },
-    { RENDER_ACCEL_OPTION,              FALSE, "RenderAccel" },
-    { NO_RENDER_EXTENSION_OPTION,       TRUE,  "NoRenderExtension" },
-    { OVERLAY_OPTION,                   FALSE, "Overlay" },
-    { CIOVERLAY_OPTION,                 FALSE, "CIOverlay" },
-    { OVERLAY_DEFAULT_VISUAL_OPTION,    FALSE, "OverlayDefaultVisual" },
-    { NO_BANDWIDTH_TEST_OPTION,         TRUE,  "NoBandWidthTest" },
-    { NO_POWER_CONNECTOR_CHECK_OPTION,  TRUE,  "NoPowerConnectorCheck" },
-    { ALLOW_DFP_STEREO_OPTION,          FALSE, "AllowDFPStereo" },
-    { ALLOW_GLX_WITH_COMPOSITE_OPTION,  FALSE, "AllowGLXWithComposite" },
-    { RANDR_ROTATION_OPTION,            FALSE, "RandRRotation" },
-    { TWINVIEW_OPTION,                  FALSE, "TwinView" },
-    { XINERAMA_OPTION,                  FALSE, "Xinerama" },
-    { NO_TWINVIEW_XINERAMA_INFO_OPTION, TRUE,  "NoTwinViewXineramaInfo" },
-    { NOFLIP_OPTION,                    TRUE,  "NoFlip" },
-    { DAC_8BIT_OPTION,                  FALSE, "Dac8Bit" },
-    { USE_EDID_FREQS_OPTION,            FALSE, "UseEdidFreqs" },
-    { IGNORE_EDID_OPTION,               FALSE, "IgnoreEDID" },
-    { USE_INT10_MODULE_OPTION,          FALSE, "UseInt10Module" },
-    { FORCE_STEREO_FLIPPING_OPTION,     FALSE, "ForceStereoFlipping" },
-    { MULTISAMPLE_COMPATIBILITY_OPTION, FALSE, "MultisampleCompatibility" },
-    { XVMC_USES_TEXTURES_OPTION,        FALSE, "XvmcUsesTextures" },
-    { EXACT_MODE_TIMINGS_DVI_OPTION,    FALSE, "ExactModeTimingsDVI" },
-    { ALLOW_DDCCI_OPTION,               FALSE, "AllowDDCCI" },
-    { LOAD_KERNEL_MODULE_OPTION,        FALSE, "LoadKernelModule" },
-    { 0,                                FALSE, NULL },
+    { NOLOGO_BOOL_OPTION,                    TRUE,  "NoLogo" },
+    { UBB_BOOL_OPTION,                       FALSE, "UBB" },
+    { RENDER_ACCEL_BOOL_OPTION,              FALSE, "RenderAccel" },
+    { NO_RENDER_EXTENSION_BOOL_OPTION,       TRUE,  "NoRenderExtension" },
+    { OVERLAY_BOOL_OPTION,                   FALSE, "Overlay" },
+    { CIOVERLAY_BOOL_OPTION,                 FALSE, "CIOverlay" },
+    { OVERLAY_DEFAULT_VISUAL_BOOL_OPTION,    FALSE, "OverlayDefaultVisual" },
+    { NO_BANDWIDTH_TEST_BOOL_OPTION,         TRUE,  "NoBandWidthTest" },
+    { NO_POWER_CONNECTOR_CHECK_BOOL_OPTION,  TRUE,  "NoPowerConnectorCheck" },
+    { ALLOW_DFP_STEREO_BOOL_OPTION,          FALSE, "AllowDFPStereo" },
+    { ALLOW_GLX_WITH_COMPOSITE_BOOL_OPTION,  FALSE, "AllowGLXWithComposite" },
+    { RANDR_ROTATION_BOOL_OPTION,            FALSE, "RandRRotation" },
+    { TWINVIEW_BOOL_OPTION,                  FALSE, "TwinView" },
+    { XINERAMA_BOOL_OPTION,                  FALSE, "Xinerama" },
+    { NO_TWINVIEW_XINERAMA_INFO_BOOL_OPTION, TRUE,  "NoTwinViewXineramaInfo" },
+    { NOFLIP_BOOL_OPTION,                    TRUE,  "NoFlip" },
+    { DAC_8BIT_BOOL_OPTION,                  FALSE, "Dac8Bit" },
+    { USE_EDID_FREQS_BOOL_OPTION,            FALSE, "UseEdidFreqs" },
+    { USE_EDID_BOOL_OPTION,                  FALSE, "UseEdid" },
+    { USE_INT10_MODULE_BOOL_OPTION,          FALSE, "UseInt10Module" },
+    { FORCE_STEREO_FLIPPING_BOOL_OPTION,     FALSE, "ForceStereoFlipping" },
+    { MULTISAMPLE_COMPATIBILITY_BOOL_OPTION, FALSE, "MultisampleCompatibility" },
+    { XVMC_USES_TEXTURES_BOOL_OPTION,        FALSE, "XvmcUsesTextures" },
+    { EXACT_MODE_TIMINGS_DVI_BOOL_OPTION,    FALSE, "ExactModeTimingsDVI" },
+    { ALLOW_DDCCI_BOOL_OPTION,               FALSE, "AllowDDCCI" },
+    { LOAD_KERNEL_MODULE_BOOL_OPTION,        FALSE, "LoadKernelModule" },
+    { ADD_ARGB_GLX_VISUALS_BOOL_OPTION,      FALSE, "AddARGBGLXVisuals" },
+    { DISABLE_GLX_ROOT_CLIPPING_BOOL_OPTION, FALSE, "DisableGLXRootClipping" },
+    { USE_EDID_DPI_BOOL_OPTION,              FALSE, "UseEdidDpi" },
+    { DAMAGE_EVENTS_BOOL_OPTION,             FALSE, "DamageEvents" },
+    { CONSTANT_DPI_BOOL_OPTION,              FALSE, "ConstantDPI" },
+    { PROBE_ALL_GPUS_BOOL_OPTION,            FALSE, "ProbeAllGpus" },
+    { DYNAMIC_TWINVIEW_BOOL_OPTION,          FALSE, "DynamicTwinView" },
+    { INCLUDE_IMPLICIT_METAMODES_BOOL_OPTION,FALSE, "IncludeImplicitMetaModes" },
+    { USE_EVENTS_BOOL_OPTION,                FALSE, "UseEvents" },
+    { CONNECT_TO_ACPID_BOOL_OPTION,          FALSE, "ConnectToAcpid" },
+    { ENABLE_ACPI_HOTKEYS_BOOL_OPTION,       FALSE, "EnableACPIHotkeys" },
+    { 0,                                     FALSE, NULL },
 };
 
 
@@ -101,6 +113,126 @@
         *list = xconfigRemoveOption(*list, opt);
     }
 } /* remove_option_from_list() */
+
+
+
+/*
+ * set_boolean_option() - set boolean option 'c' to the given 'boolval'
+ */
+
+void set_boolean_option(Options *op, const int c, const int boolval)
+{
+    u32 bit;
+    
+    bit = GET_BOOL_OPTION_BIT(c);
+    
+    GET_BOOL_OPTION_SLOT(op->boolean_options, c) |= bit;
+    
+    if (boolval) {
+        GET_BOOL_OPTION_SLOT(op->boolean_option_values, c) |= bit;
+    } else {
+        GET_BOOL_OPTION_SLOT(op->boolean_option_values, c) &= ~bit;
+    }
+} /* set_boolean_option() */
+
+
+
+/*
+ * validate_composite() - check whether any options conflict with the
+ * Composite extension; update the composite option value, if
+ * appropriate.
+ */
+
+void validate_composite(Options *op, XConfigPtr config)
+{
+    int i, n, opt, disable_composite;
+    char scratch[256], *s;
+    
+    
+    /*
+     * the composite_incompatible_options[] array lists all the
+     * options that are incompatible with the composite extension; we
+     * list boolean options and then special-case any non-boolean options
+     */
+
+    static int composite_incompatible_options[] = {
+        XINERAMA_BOOL_OPTION,
+        OVERLAY_BOOL_OPTION,
+        CIOVERLAY_BOOL_OPTION,
+        UBB_BOOL_OPTION,
+        -1, /* stereo */
+        -2 /* end */
+    };
+    
+    disable_composite = FALSE;
+    s = scratch;
+    n = 0;
+    
+    /*
+     * loop through all the incompatible options, and check if the
+     * user specified any of them
+     */
+
+    for (i = 0; composite_incompatible_options[i] != -2; i++) {
+
+        int present = 0;
+        const char *name;
+        
+        opt = composite_incompatible_options[i];
+     
+        if (opt == -1) { /* special case stereo */
+            
+            present = (op->stereo > 0);
+            name = "Stereo";
+            
+        } else {
+            const NvidiaXConfigOption *o;
+            
+            present = (GET_BOOL_OPTION(op->boolean_options, opt) &&
+                       GET_BOOL_OPTION(op->boolean_option_values, opt));
+            
+            o = get_option(opt);
+            name = o->name;
+        }
+        
+        /*
+         * if the option is present, then we have to disable
+         * composite; append to the scratch string that lists all the
+         * present conflicting options
+         */
+        
+        if (present) {
+            disable_composite = TRUE;
+            n++;
+            s += sprintf(s, "%s%s", (n > 1) ? " or " : "", name);
+        }
+    }
+    
+    /*
+     * if we have to disable the composite extension, print a warning
+     * and set the option value.
+     *
+     * We need to be careful to only set the option value if the X
+     * server is going to recognize the Extension section and the
+     * composite option.  We guess whether the server will recognize
+     * the option: if get_xserver_in_use() thinks the X server
+     * supports the "Composite" extension, or the current config
+     * already has an extension section, or the user specified the
+     * composite option.
+     */
+    
+    if (disable_composite &&
+        (op->supports_extension_section ||
+         config->extensions ||
+         GET_BOOL_OPTION(op->boolean_options, COMPOSITE_BOOL_OPTION))) {
+        
+        fmtwarn("The Composite X extension does not currently interact well "
+                "with the %s option%s; the Composite X extension will be "
+                "disabled.", scratch, (n > 1) ? "s": "");
+        
+        set_boolean_option(op, COMPOSITE_BOOL_OPTION, FALSE);
+    }
+} /* validate_composite() */
 
 
 
@@ -117,8 +249,14 @@
 {
     XConfigDisplayPtr display;
 
-    remove_option_from_list(&screen->device->options, name);
-    remove_option_from_list(&screen->monitor->options, name);
+    if (!screen) return;
+
+    if (screen->device) {
+        remove_option_from_list(&screen->device->options, name);
+    }
+    if (screen->monitor) {
+        remove_option_from_list(&screen->monitor->options, name);
+    }
     remove_option_from_list(&screen->options, name);
     
     for (display = screen->displays; display; display = display->next) {
@@ -129,6 +267,41 @@
 
 
 /*
+ * get_screen_option() - get the option structure with the specified
+ * name, searching all the option lists associated with this screen
+ */
+
+XConfigOptionPtr get_screen_option(XConfigScreenPtr screen, const char *name)
+{
+    XConfigDisplayPtr display;
+    XConfigOptionPtr opt;
+
+    if (!screen) return NULL;
+
+    if (screen->device) {
+        opt = xconfigFindOption(screen->device->options, name);
+        if (opt) return opt;
+    }
+    if (screen->monitor) {
+        opt = xconfigFindOption(screen->monitor->options, name);
+        if (opt) return opt;
+    }
+
+    opt = xconfigFindOption(screen->options, name);
+    if (opt) return opt;
+
+    for (display = screen->displays; display; display = display->next) {
+        opt = xconfigFindOption(display->options, name);
+        if (opt) return opt;
+    }
+
+    return NULL;
+
+} /* get_screen_option() */
+
+
+
+/*
  * set_option_value() - set the given option to the specified value
  */
 
@@ -142,8 +315,7 @@
 
     /* 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() */
 
 
@@ -159,19 +331,213 @@
      * options, too
      */
 
-    if (GET_BOOL_OPTION(op->boolean_options, TWINVIEW_OPTION)) {
-        if (GET_BOOL_OPTION(op->boolean_option_values, TWINVIEW_OPTION)) {
-            set_option_value(screen, "TwinViewOrientation", "RightOf");
-            set_option_value(screen, "UseEdidFreqs", "True"); /* XXX */
-            set_option_value(screen, "MetaModes", "1024x768, 1024x768");
-        } else {
-            remove_option(screen, "TwinViewOrientation");
-            remove_option(screen, "SecondMonitorHorizSync");
-            remove_option(screen, "SecondMonitorVertRefresh");
-            remove_option(screen, "MetaModes");
+    if (GET_BOOL_OPTION(op->boolean_options, TWINVIEW_BOOL_OPTION)) {
+        remove_option(screen, "TwinViewOrientation");
+        remove_option(screen, "SecondMonitorHorizSync");
+        remove_option(screen, "SecondMonitorVertRefresh");
+        remove_option(screen, "MetaModes");
+        
+        if (GET_BOOL_OPTION(op->boolean_option_values, TWINVIEW_BOOL_OPTION)) {
+            set_option_value(screen, "MetaModes",
+                             "nvidia-auto-select, nvidia-auto-select");
         }
     }
 } /* update_twinview_options() */
+
+
+
+/*
+ * find_metamode_offset() - find the first metamode offset in
+ * 'string'; returns a pointer to the start of the offset
+ * specification and assigns 'end' (if non-NULL) to the first character
+ * beyond the offset specification.
+ */
+
+static char *find_metamode_offset(char *string, char **end)
+{
+    enum {
+        StateBeforeOffset,
+        StateInFirstPlus,
+        StateInFirstNumber,
+        StateInSecondPlus,
+        StateInSecondNumber
+    } state = StateBeforeOffset;
+
+    char *s, *start = NULL, c;
+
+    for (s = string; s && *s; s++) {
+        c = *s;
+        switch (state) {
+
+        case StateBeforeOffset:
+            if ((c == '-') || (c == '+')) {
+                start = s;
+                state = StateInFirstPlus;
+            }
+            break;
+
+        case StateInFirstPlus:
+            if (isspace(c)) state = StateInFirstPlus;
+            else if (isdigit(c)) state = StateInFirstNumber;
+            else state = StateBeforeOffset;
+            break;
+
+        case StateInFirstNumber:
+            if (isdigit(c) || isspace(c)) state = StateInFirstNumber;
+            else if ((c == '-') || (c == '+')) state = StateInSecondPlus;
+            else state = StateBeforeOffset;
+            break;
+
+        case StateInSecondPlus:
+            if (isspace(c)) state = StateInSecondPlus;
+            else if (isdigit(c)) state = StateInSecondNumber;
+            else state = StateBeforeOffset;
+            break;
+
+        case StateInSecondNumber:
+            if (isdigit(c)) state = StateInSecondNumber;
+            else goto done;
+            break;
+        }
+    }
+
+ done:
+    if (state == StateInSecondNumber) {
+        if (end) *end = s;
+        return start;
+    }
+
+    return NULL;
+
+} /* find_metamode_offset() */
+
+
+
+/*
+ * remove_metamode_offsets() - remove any offset specifications from
+ * the MetaMode option for this screen; if we find any offsets, return
+ * TRUE and assign old_metamodes and new_metamodes to copies of the
+ * MetaModes string before and after removing the offsets.  If no
+ * offsets appear in the MetaModes string, return FALSE.
+ */
+
+static int remove_metamode_offsets(XConfigScreenPtr screen,
+                                   char **old_metamodes, char **new_metamodes)
+{
+    char *start, *end;
+    char *new_string;
+    char *n, *o, *tmp;
+
+    XConfigOptionPtr opt = get_screen_option(screen, "MetaModes");
+
+    /* return if no MetaModes option */
+
+    if (!opt || !opt->val) return FALSE;
+
+    /* return if no explicit offsets in the MetaModes option */
+
+    if (!find_metamode_offset(opt->val, NULL)) return FALSE;
+
+    if (old_metamodes) *old_metamodes = nvstrdup(opt->val);
+
+    /*
+     * if we get this far, there are offsets in the MetaModes string;
+     * build a new string without the offsets
+     */
+
+    new_string = nvstrdup(opt->val);
+
+    o = start = opt->val;
+    n = new_string;
+
+    while (1) {
+
+        tmp = find_metamode_offset(start, &end);
+
+        if (tmp) *tmp = '\0';
+
+        while (*o) *n++ = *o++;
+
+        *n = '\0';
+
+        if (!tmp) break;
+
+        o = start = end;
+    }
+
+    nvfree(opt->val);
+
+    opt->val = new_string;
+
+    if (new_metamodes) *new_metamodes = nvstrdup(opt->val);
+
+    return TRUE;
+
+} /* remove_metamode_offsets() */
+
+
+
+/*
+ * update_display_options() - update the Display SubSection options
+ */
+
+static void update_display_options(Options *op, XConfigScreenPtr screen)
+{
+    XConfigDisplayPtr display;
+    int i;
+    
+    /* update the mode list, based on what we have on the commandline */
+    
+    for (display = screen->displays; display; display = display->next) {
+
+        /*
+         * if virtual.[xy] are less than 0, then clear the virtual
+         * screen size; if they are greater than 0, assign the virtual
+         * screen size; if they are 0, leave the virtual screen size
+         * alone
+         */
+
+        if ((op->virtual.x < 0) || (op->virtual.y < 0)) {
+            display->virtualX = display->virtualY = 0;
+        } else if (op->virtual.x || op->virtual.y) {
+            display->virtualX = op->virtual.x;
+            display->virtualY = op->virtual.y;
+        }
+        
+        for (i = 0; i < op->remove_modes.n; i++) {
+            display->modes = xconfigRemoveMode(display->modes,
+                                               op->remove_modes.t[i]);
+        }
+        for (i = 0; i < op->add_modes.n; i++) {
+            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? */
+
+        /*
+         * XXX should we update the mode list with what we can get
+         * through libnvidia-cfg?
+         */
+    }
+    
+} /* update_display_options() */
 
 
 
@@ -183,7 +549,6 @@
 void update_options(Options *op, XConfigScreenPtr screen)
 {
     int i;
-    XConfigDisplayPtr display;    
     const NvidiaXConfigOption *o;
     char *val;
     char scratch[8];
@@ -194,12 +559,13 @@
         if (GET_BOOL_OPTION(op->boolean_options, i)) {
             
             /*
-             * SEPARATE_X_SCREENS_OPTION and XINERAMA_OPTION are
-             * handled separately
+             * SEPARATE_X_SCREENS_BOOL_OPTION, XINERAMA_BOOL_OPTION,
+             * and COMPOSITE_BOOL_OPTION are handled separately
              */
 
-            if (i == SEPARATE_X_SCREENS_OPTION) continue;
-            if (i == XINERAMA_OPTION) continue;
+            if (i == SEPARATE_X_SCREENS_BOOL_OPTION) continue;
+            if (i == XINERAMA_BOOL_OPTION) continue;
+            if (i == COMPOSITE_BOOL_OPTION) continue;
             
             o = get_option(i);
             
@@ -224,26 +590,10 @@
 
     update_twinview_options(op, screen);
     
-    /* update the mode list, based on what we have on the commandline */
-    
-    for (display = screen->displays; display; display = display->next) {
-        for (i = 0; i < op->remove_modes.n; i++) {
-            display->modes = xconfigRemoveMode(display->modes,
-                                               op->remove_modes.t[i]);
-        }
-        for (i = 0; i < op->add_modes.n; i++) {
-            display->modes = xconfigAddMode(display->modes,
-                                            op->add_modes.t[i]);
-        }
-
-        /* XXX should we sort the mode list? */
-
-        /*
-         * XXX should we update the mode list with what we can get
-         * through libnvidia-cfg?
-         */
-    }
-    
+    /* update the Display SubSection options */
+    
+    update_display_options(op, screen);
+
     /* add the nvagp option */
     
     if (op->nvagp != -1) {
@@ -254,16 +604,6 @@
         }
     }
 
-    /* add the digital vibrance option */
-    
-    if (op->digital_vibrance != -1) {
-        remove_option(screen, "digitalvibrance");
-        if (op->digital_vibrance != -2) {
-            snprintf(scratch, 8, "%d", op->digital_vibrance);        
-            set_option_value(screen, "DigitalVibrance", scratch);
-        }
-    }
-
     /* add the transparent index option */
     
     if (op->transparent_index != -1) {
@@ -284,17 +624,145 @@
         }
     }
 
+    /* add the MultiGPU option */
+
+    if (op->multigpu) {
+        remove_option(screen, "MultiGPU");
+        if (op->multigpu != NV_DISABLE_STRING_OPTION) {
+            set_option_value(screen, "MultiGPU", op->multigpu);
+        }
+    }
+
     /* add the SLI option */
 
     if (op->sli) {
         remove_option(screen, "SLI");
-        set_option_value(screen, "SLI", op->sli);
+        if (op->sli != NV_DISABLE_STRING_OPTION) {
+            set_option_value(screen, "SLI", op->sli);
+        }
     }
 
     /* add the rotate option */
 
     if (op->rotate) {
         remove_option(screen, "Rotate");
-        set_option_value(screen, "Rotate", op->rotate);
-    }
+        if (op->rotate != NV_DISABLE_STRING_OPTION) {
+            set_option_value(screen, "Rotate", op->rotate);
+        }
+    }
+
+    /* add acpid socket path option*/
+ 
+    if (op->acpid_socket_path) {
+        remove_option(screen, "AcpidSocketPath");
+        if (op->acpid_socket_path != NV_DISABLE_STRING_OPTION) {
+            set_option_value(screen, "AcpidSocketPath", op->acpid_socket_path);
+        }
+    }
+        
+
+    /* add the twinview xinerama info order option */
+    
+    if (op->twinview_xinerama_info_order) {
+        remove_option(screen, "TwinViewXineramaInfoOrder");
+        if (op->twinview_xinerama_info_order != NV_DISABLE_STRING_OPTION) {
+            set_option_value(screen, "TwinViewXineramaInfoOrder",
+                             op->twinview_xinerama_info_order);
+        }
+    }
+
+    /* add the twinview orientation option */
+    
+    if (op->twinview_orientation) {
+        remove_option(screen, "TwinViewOrientation");
+        if (op->twinview_orientation != NV_DISABLE_STRING_OPTION) {
+            char *old_metamodes, *new_metamodes;
+            set_option_value(screen, "TwinViewOrientation",
+                             op->twinview_orientation);
+            if (remove_metamode_offsets(screen,
+                                        &old_metamodes, &new_metamodes)) {
+                fmtmsg("");
+                fmtwarn("The MetaModes option contained explicit offsets, "
+                        "which would have overridden the specified "
+                        "TwinViewOrientation; in order to honor the "
+                        "requested TwinViewOrientation, the explicit offsets "
+                        "have been removed from the MetaModes option.\n\n"
+                        "Old MetaModes option: \"%s\"\n"
+                        "New MetaModes option: \"%s\".",
+                        old_metamodes, new_metamodes);
+                fmtmsg("");
+                nvfree(old_metamodes);
+                nvfree(new_metamodes);
+            }
+        }
+    }
+    
+    /* add the LogoPath option */
+
+    if (op->logo_path) {
+        remove_option(screen, "LogoPath");
+        if (op->logo_path != NV_DISABLE_STRING_OPTION) {
+            set_option_value(screen, "LogoPath", op->logo_path);
+        }
+    }
+   
+    /* add the UseDisplayDevice option */
+ 
+    if (op->use_display_device) {
+        remove_option(screen, "UseDisplayDevice");
+        if (op->use_display_device != NV_DISABLE_STRING_OPTION) {
+            set_option_value(screen, "UseDisplayDevice",
+                             op->use_display_device);
+        }
+    }
+
+    /* add the CustomEDID option */
+
+    if (op->custom_edid) {
+        remove_option(screen, "CustomEDID");
+        if (op->custom_edid != NV_DISABLE_STRING_OPTION) {
+            set_option_value(screen, "CustomEDID", op->custom_edid);
+        }
+    }
+
+    /* add the TVStandard option */
+
+    if (op->tv_standard) {
+        remove_option(screen, "TVStandard");
+        if (op->tv_standard != NV_DISABLE_STRING_OPTION) {
+           set_option_value(screen, "TVStandard", op->tv_standard);
+        }
+    }
+
+    /* add the TVOutFormat option */
+
+    if (op->tv_out_format) {
+        remove_option(screen, "TVOutFormat");
+        if (op->tv_out_format != NV_DISABLE_STRING_OPTION) {
+           set_option_value(screen, "TVOutFormat", op->tv_out_format);
+        }
+    }
+
+    /* add the TVOverScan option */
+
+    if (op->tv_over_scan != -1.0) {
+        remove_option(screen, "TVOverScan");
+        if (op->tv_over_scan != -2.0) {
+            snprintf(scratch, 8, "%f", op->tv_over_scan);
+            set_option_value(screen, "TVOverScan", scratch);
+        }
+    }
+
+    /* add the Coolbits option */
+
+    if (op->cool_bits != -1) {
+        remove_option(screen, "Coolbits");
+        if (op->cool_bits != -2) {
+            snprintf(scratch, 8, "%d", op->cool_bits);
+            set_option_value(screen, "Coolbits", scratch);
+        }
+    }
+
+
+  
 } /* update_options() */

Modified: packages/nvidia-xconfig/trunk/tree.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/tree.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/tree.c (original)
+++ packages/nvidia-xconfig/trunk/tree.c Tue Jun 24 17:53:25 2008
@@ -160,21 +160,48 @@
 {
     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() */
+
+
+
+/*
+ * print_virtual()
+ */
+
+static void print_virtual(XConfigScreenPtr screen)
+{
+    XConfigDisplayPtr display;
+
+    for (display = screen->displays; display; display = display->next) {
+        if (display->depth == screen->defaultdepth) {
+            if (display->virtualX || display->virtualY) {
+                printf("        |       |--> Virtual %d %d\n",
+                       display->virtualX, display->virtualY);
+            }
+            break;
+        }
+    }
+    
+} /* print_virtual() */
 
 
 
@@ -195,7 +222,8 @@
     printf("        |       |--> DefaultColorDepth %d\n",
            screen->defaultdepth);
     print_modes(screen);
-
+    print_virtual(screen);
+    
     printf("        |\n");
     
 } /* print_screen() */
@@ -267,6 +295,26 @@
     printf("\n");
 
 } /* print_server_flags() */
+
+
+
+/*
+ * print_server_extensions()
+ */
+
+static void print_server_extensions(XConfigPtr config)
+{
+    if (!config->extensions || !config->extensions->options) return;
+    
+    printf("\n");
+    printf("    Extensions\n");
+    printf("        |\n");
+    
+    print_options(config->extensions->options, 1);
+    
+    printf("\n");
+
+} /* print_server_extensions() */
 
 
 
@@ -305,6 +353,8 @@
 
     print_server_flags(config);
 
+    print_server_extensions(config);
+
     return TRUE;
 
 } /* print_tree() */

Modified: packages/nvidia-xconfig/trunk/util.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/trunk/util.c?rev=419&op=diff
==============================================================================
--- packages/nvidia-xconfig/trunk/util.c (original)
+++ packages/nvidia-xconfig/trunk/util.c Tue Jun 24 17:53:25 2008
@@ -210,7 +210,7 @@
 /*
  * nvfree() - 
  */
-void nvfree(char *s)
+void nvfree(void *s)
 {
     if (s) free(s);
 




More information about the Pkg-nvidia-devel mailing list