[pkg-nvidia-devel] r418 - in /packages/nvidia-xconfig/branches/upstream/current: ./ XF86Config-parser/

rdonald at users.alioth.debian.org rdonald at users.alioth.debian.org
Tue Jun 24 17:49:43 UTC 2008


Author: rdonald
Date: Tue Jun 24 17:49:43 2008
New Revision: 418

URL: http://svn.debian.org/wsvn/pkg-nvidia/?sc=1&rev=418
Log:
[svn-upgrade] Integrating new upstream version, nvidia-xconfig (1.0)

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

Added: packages/nvidia-xconfig/branches/upstream/current/COPYING
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/COPYING?rev=418&op=file
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/COPYING (added)
+++ packages/nvidia-xconfig/branches/upstream/current/COPYING Tue Jun 24 17:49:43 2008
@@ -1,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.

Modified: packages/nvidia-xconfig/branches/upstream/current/Makefile
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/Makefile?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/Makefile (original)
+++ packages/nvidia-xconfig/branches/upstream/current/Makefile Tue Jun 24 17:49:43 2008
@@ -98,6 +98,7 @@
 NVIDIA_XCONFIG_DISTDIR = $(NVIDIA_XCONFIG)-$(NVIDIA_XCONFIG_VERSION)
 
 EXTRA_DIST = \
+	COPYING \
 	nvgetopt.h \
 	nvidia-xconfig.h \
 	nvidia-cfg.h \
@@ -120,7 +121,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/branches/upstream/current/XF86Config-parser/DRI.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/DRI.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/DRI.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/DRI.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Device.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Device.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Device.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Device.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Files.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Files.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Files.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Files.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Flags.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Flags.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Flags.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Flags.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Generate.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Generate.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Generate.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Generate.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Input.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Input.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Input.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Input.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Keyboard.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Keyboard.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Keyboard.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Keyboard.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Layout.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Layout.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Layout.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Layout.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Makefile
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Makefile?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Makefile (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Makefile Tue Jun 24 17:49:43 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)

Added: packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Merge.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Merge.c?rev=418&op=file
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Merge.c (added)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Merge.c Tue Jun 24 17:49:43 2008
@@ -1,0 +1,754 @@
+/* 
+ * 
+ * Copyright (c) 1997  Metro Link Incorporated
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"), 
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ * 
+ */
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+
+
+/*
+ * xconfigAddRemovedOptionComment() - Makes a note in the comment
+ * string "existing_comments" that a particular option has been
+ * removed.
+ *
+ */
+static void xconfigAddRemovedOptionComment(char **existing_comments,
+                                           XConfigOptionPtr option)
+{
+    int len;
+    char *str;
+    char *name, *value;
+
+    if (!option || !existing_comments)
+        return;
+
+    name = xconfigOptionName(option);
+    value = xconfigOptionValue(option);
+
+    if (!name) return;
+
+    if (value) {
+        len = 32 + strlen(name) + strlen(value);
+        str = malloc(len);
+        if (!str) return;
+        snprintf(str, len, "# Removed Option \"%s\" \"%s\"", name, value);
+    } else {
+        len = 32 + strlen(name);
+        str = malloc(len);
+        if (!str) return;
+        snprintf(str, len, "# Removed Option \"%s\"", name);
+    }
+
+    *existing_comments = xconfigAddComment(*existing_comments, str);
+
+} /* xconfigAddRemovedOptionComment() */
+
+
+
+/*
+ * xconfigRemoveNamedOption() - Removes the named option from an option
+ * list and (if specified) adds a comment to an existing comments string
+ *
+ */
+static void xconfigRemoveNamedOption(XConfigOptionPtr *head, char *name,
+                                     char **comments)
+{
+    XConfigOptionPtr option;
+
+    option = xconfigFindOption(*head, name);
+    if (option) {
+        if (comments) {
+            xconfigAddRemovedOptionComment(comments, option);
+        }
+        *head = xconfigRemoveOption(*head, option);
+    }
+
+} /* xconfigRemoveNamedOption() */
+
+
+
+/*
+ * xconfigOptionValuesDiffer() - return '1' if the option values for
+ * option0 and option1 are different; return '0' if the option values
+ * are the same.
+ */
+
+static int xconfigOptionValuesDiffer(XConfigOptionPtr option0,
+                                     XConfigOptionPtr option1)
+{
+    char *value0, *value1;
+
+    value0 = value1 = NULL;
+
+    if (!option0 && !option1) return 0;
+    if (!option0 &&  option1) return 1;
+    if ( option0 && !option1) return 1;
+
+    value0 = xconfigOptionValue(option0);
+    value1 = xconfigOptionValue(option1);
+
+    if (!value0 && !value1) return 0;
+    if (!value0 &&  value1) return 1;
+    if ( value0 && !value1) return 1;
+
+    return (strcmp(value0, value1) != 0);
+
+} /* xconfigOptionValuesDiffer() */
+
+
+
+/*
+ * xconfigMergeOption() - Merge option "name" from option source
+ * list "srcHead" to option destination list "dstHead".
+ *
+ * Merging here means:
+ *
+ * If the option is not in the source config, remove it from the dest
+ * config.
+ *
+ * If the option is in the source config, make sure the dest config
+ * contains the option with the same value as the source config.
+ *
+ * if "comments" is given, a comment will be added to note when
+ * an option has been removed/replaced.
+ *
+ */
+static void xconfigMergeOption(XConfigOptionPtr *dstHead,
+                               XConfigOptionPtr *srcHead,
+                               const char *name, char **comments)
+{
+    XConfigOptionPtr srcOption = xconfigFindOption(*srcHead, name);
+    XConfigOptionPtr dstOption = xconfigFindOption(*dstHead, name);
+
+    char *srcValue = NULL;
+
+    if (srcOption) srcValue = xconfigOptionValue(srcOption);
+
+    if (!srcOption && dstOption) {
+
+        /* option does not exist in src, but exists in dst: remove from dst */
+        *dstHead = xconfigRemoveOption(*dstHead, dstOption);
+
+    } else if (srcOption && !dstOption) {
+
+        /* option exists in src but not in dst: add to dst */
+        *dstHead = xconfigAddNewOption(*dstHead, name, srcValue);
+
+    } else if (srcOption && dstOption) {
+
+        /*
+         * option exists in src and in dst; if the option values are
+         * different, replace the dst's option value with src's option
+         * value; note that xconfigAddNewOption() will remove the old
+         * option first, if necessary
+         */
+
+        if (xconfigOptionValuesDiffer(srcOption, dstOption)) {
+            if (comments) {
+                xconfigAddRemovedOptionComment(comments, dstOption);
+            }
+            *dstHead = xconfigAddNewOption(*dstHead, name, srcValue);
+        }
+    }
+
+} /* xconfigMergeOption() */
+
+
+
+/*
+ * xconfigMergeFlags() - Updates the destination's list of server flag
+ * options with the options found in the source config.
+ *
+ * Optons in the destination are either added or updated.  Options that
+ * are found in the destination config and not in the source config are
+ * not modified.
+ *
+ * Returns 1 if the merge was successful and 0 if not.
+ */
+static int xconfigMergeFlags(XConfigPtr dstConfig, XConfigPtr srcConfig)
+{
+    if (srcConfig->flags) {
+        XConfigOptionPtr option;
+        
+        /* Flag section was not found, create a new one */
+        if (!dstConfig->flags) {
+            dstConfig->flags =
+                (XConfigFlagsPtr) calloc(1, sizeof(XConfigFlagsRec));
+            if (!dstConfig->flags) return 0;
+        }
+        
+        option = srcConfig->flags->options;
+        while (option) {
+            xconfigMergeOption(&(dstConfig->flags->options),
+                               &(srcConfig->flags->options),
+                               xconfigOptionName(option),
+                               &(dstConfig->flags->comment));
+            option = option->next;
+        }
+    }
+    
+    return 1;
+
+} /* xconfigMergeFlags() */
+
+
+
+/*
+ * xconfigMergeMonitors() - Updates information in the destination monitor
+ * with that of the source monitor.
+ *
+ */
+static void xconfigMergeMonitors(XConfigMonitorPtr dstMonitor,
+                                 XConfigMonitorPtr srcMonitor)
+{
+    int i;
+
+
+    /* Update vendor */
+    
+    free(dstMonitor->vendor);
+    dstMonitor->vendor = xconfigStrdup(srcMonitor->vendor);
+    
+    /* Update modelname */
+    
+    free(dstMonitor->modelname);
+    dstMonitor->modelname = xconfigStrdup(srcMonitor->modelname);
+    
+    /* Update horizontal sync */
+    
+    dstMonitor->n_hsync = srcMonitor->n_hsync;
+    for (i = 0; i < srcMonitor->n_hsync; i++) {
+        dstMonitor->hsync[i].lo = srcMonitor->hsync[i].lo;
+        dstMonitor->hsync[i].hi = srcMonitor->hsync[i].hi;
+    }
+    
+    /* Update vertical sync */
+    
+    dstMonitor->n_vrefresh = srcMonitor->n_vrefresh;
+    for (i = 0; i < srcMonitor->n_hsync; i++) {
+        dstMonitor->vrefresh[i].lo = srcMonitor->vrefresh[i].lo;
+        dstMonitor->vrefresh[i].hi = srcMonitor->vrefresh[i].hi;
+    }
+    
+    /* XXX Remove the destination monitor's "UseModes" references to
+     *     avoid having the wrong modelines tied to the new monitor.
+     */
+    xconfigFreeModesLinkList(dstMonitor->modes_sections);
+    dstMonitor->modes_sections = NULL;
+
+} /* xconfigMergeMonitors() */
+
+
+
+/*
+ * xconfigMergeAllMonitors() - This function ensures that all monitors in
+ * the source config appear in the destination config by adding and/or
+ * updating the "appropriate" destination monitor sections.
+ *
+ */
+static int xconfigMergeAllMonitors(XConfigPtr dstConfig, XConfigPtr srcConfig)
+{
+    XConfigMonitorPtr dstMonitor;
+    XConfigMonitorPtr srcMonitor;
+
+
+    /* Make sure all monitors in the src config are also in the dst config */
+
+    for (srcMonitor = srcConfig->monitors;
+         srcMonitor;
+         srcMonitor = srcMonitor->next) {
+
+        dstMonitor =
+            xconfigFindMonitor(srcMonitor->identifier, dstConfig->monitors);
+
+        /* Monitor section was not found, create a new one and add it */
+        if (!dstMonitor) {
+            dstMonitor =
+                (XConfigMonitorPtr) calloc(1, sizeof(XConfigMonitorRec));
+            if (!dstMonitor) return 0;
+
+            dstMonitor->identifier = xconfigStrdup(srcMonitor->identifier);
+
+            dstConfig->monitors = (XConfigMonitorPtr)
+                xconfigAddListItem((GenericListPtr)dstConfig->monitors,
+                                   (GenericListPtr)dstMonitor);
+        }
+
+        /* Do the merge */
+        xconfigMergeMonitors(dstMonitor, srcMonitor);
+    }
+
+    return 1;
+
+} /* xconfigMergeAllMonitors() */
+
+
+
+/*
+ * xconfigMergeDevices() - Updates information in the destination device
+ * with that of the source device.
+ *
+ */
+static void xconfigMergeDevices(XConfigDevicePtr dstDevice,
+                                XConfigDevicePtr srcDevice)
+{
+    // XXX Zero out the device section?
+
+    /* Update driver */
+    
+    free(dstDevice->driver);
+    dstDevice->driver = xconfigStrdup(srcDevice->driver);
+    
+    /* Update vendor */
+    
+    free(dstDevice->vendor);
+    dstDevice->vendor = xconfigStrdup(srcDevice->vendor);
+    
+    /* Update bus ID */
+    
+    free(dstDevice->busid);
+    dstDevice->busid = xconfigStrdup(srcDevice->busid);
+    
+    /* Update board */
+    
+    free(dstDevice->board);
+    dstDevice->board = xconfigStrdup(srcDevice->board);
+    
+    /* Update chip info */
+    
+    dstDevice->chipid = srcDevice->chipid;
+    dstDevice->chiprev = srcDevice->chiprev;
+
+    /* Update IRQ */
+
+    dstDevice->irq = srcDevice->irq;
+    
+    /* Update screen */
+    
+    dstDevice->screen = srcDevice->screen;
+
+} /* xconfigMergeDevices() */
+
+
+
+/*
+ * xconfigMergeAllDevices() - This function ensures that all devices in
+ * the source config appear in the destination config by adding and/or
+ * updating the "appropriate" destination device sections.
+ *
+ */
+static int xconfigMergeAllDevices(XConfigPtr dstConfig, XConfigPtr srcConfig)
+{
+    XConfigDevicePtr dstDevice;
+    XConfigDevicePtr srcDevice;
+
+
+    /* Make sure all monitors in the src config are also in the dst config */
+
+    for (srcDevice = srcConfig->devices;
+         srcDevice;
+         srcDevice = srcDevice->next) {
+
+        dstDevice =
+            xconfigFindDevice(srcDevice->identifier, dstConfig->devices);
+        
+        /* Device section was not found, create a new one and add it */
+        if (!dstDevice) {
+            dstDevice =
+                (XConfigDevicePtr) calloc(1, sizeof(XConfigDeviceRec));
+            if (!dstDevice) return 0;
+
+            dstDevice->identifier = xconfigStrdup(srcDevice->identifier);
+
+            dstConfig->devices = (XConfigDevicePtr)
+                xconfigAddListItem((GenericListPtr)dstConfig->devices,
+                                   (GenericListPtr)dstDevice);
+        }
+
+        /* Do the merge */
+        xconfigMergeDevices(dstDevice, srcDevice);
+    }
+
+    return 1;
+
+} /* xconfigMergeAllDevices() */
+
+
+
+/*
+ * xconfigMergeDriverOptions() - Update the (Screen) driver options
+ * of the destination config with information from the source config.
+ *
+ * - Assumes the source options are all found in the srcScreen->options.
+ * - Updates only those options listed in the srcScreen->options.
+ *
+ */
+static int xconfigMergeDriverOptions(XConfigScreenPtr dstScreen,
+                                     XConfigScreenPtr srcScreen)
+{
+    XConfigOptionPtr option;
+    XConfigDisplayPtr display;
+
+    option = srcScreen->options;
+    while (option) {
+        char *name = xconfigOptionName(option);
+
+        /* Remove the option from all non-screen option lists */
+        
+        if (dstScreen->device) {
+            xconfigRemoveNamedOption(&(dstScreen->device->options), name,
+                                     &(dstScreen->device->comment));
+        }
+        if (dstScreen->monitor) {
+            xconfigRemoveNamedOption(&(dstScreen->monitor->options), name,
+                                     &(dstScreen->monitor->comment));
+        }       
+        for (display = dstScreen->displays; display; display = display->next) {
+            xconfigRemoveNamedOption(&(display->options), name,
+                                     &(display->comment));
+        }
+
+        /* Update/Add the option to the screen's option list */
+        {
+            // XXX Only add a comment if the value changed.
+            XConfigOptionPtr old =
+                xconfigFindOption(dstScreen->options, name);
+
+            if (old && xconfigOptionValuesDiffer(option, old)) {
+                xconfigRemoveNamedOption(&(dstScreen->options), name,
+                                         &(dstScreen->comment));
+            } else {
+                xconfigRemoveNamedOption(&(dstScreen->options), name,
+                                         NULL);
+            }
+        }
+
+        /* Add the option to the screen->options list */
+
+        dstScreen->options =
+            xconfigAddNewOption(dstScreen->options,
+                                name, xconfigOptionValue(option));
+        
+        option = option->next;
+    }
+
+    return 1;
+
+} /* xconfigMergeDriverOptions() */
+
+
+
+/*
+ * xconfigMergeDisplays() - Duplicates display information from the
+ * source screen to the destination screen.
+ *
+ */
+static int xconfigMergeDisplays(XConfigScreenPtr dstScreen,
+                                XConfigScreenPtr srcScreen)
+{
+    XConfigDisplayPtr dstDisplay;
+    XConfigDisplayPtr srcDisplay;
+    XConfigModePtr srcMode, dstMode, lastDstMode;
+
+    /* Free all the displays in the destination screen */
+
+    xconfigFreeDisplayList(dstScreen->displays);
+
+    /* Copy all te displays */
+    
+    for (srcDisplay = srcScreen->displays;
+         srcDisplay;
+         srcDisplay = srcDisplay->next) {
+
+        /* Create a new display */
+
+        dstDisplay = xconfigAlloc(sizeof(XConfigDisplayRec));
+        if (!dstDisplay) return 0;
+
+        /* Copy display fields */
+
+        dstDisplay->frameX0 = srcDisplay->frameX0;
+        dstDisplay->frameY0 = srcDisplay->frameY0;
+        dstDisplay->virtualX = srcDisplay->virtualX;
+        dstDisplay->virtualY = srcDisplay->virtualY;
+        dstDisplay->depth = srcDisplay->depth;
+        dstDisplay->bpp = srcDisplay->bpp;
+        dstDisplay->visual = xconfigStrdup(srcDisplay->visual);
+        dstDisplay->weight = srcDisplay->weight;
+        dstDisplay->black = srcDisplay->black;
+        dstDisplay->white = srcDisplay->white;
+        dstDisplay->comment = xconfigStrdup(srcDisplay->comment);
+
+        /* Copy options over */
+
+        dstDisplay->options = xconfigOptionListDup(srcDisplay->options);
+
+        /* Copy modes over */
+
+        lastDstMode = NULL;
+        srcMode = srcDisplay->modes;
+        while (srcMode) {
+
+            /* Copy the mode */
+
+            dstMode = xconfigAddMode(NULL, srcMode->mode_name);
+
+            /* Add mode at the end of the list */
+
+            if ( !lastDstMode ) {
+                dstDisplay->modes = dstMode;
+            } else {
+                lastDstMode->next = dstMode;
+            }
+            lastDstMode = dstMode;
+
+            srcMode = srcMode->next;
+        }
+    }
+
+    return 1;
+
+} /* xconfigMergeDisplays() */
+
+
+
+/*
+ * xconfigMergeScreens() - Updates information in the destination screen
+ * with that of the source screen.
+ *
+ * NOTE: This assumes the Monitor and Device sections have already been
+ *       merged.
+ *
+ */
+static void xconfigMergeScreens(XConfigScreenPtr dstScreen,
+                                XConfigPtr dstConfig,
+                                XConfigScreenPtr srcScreen,
+                                XConfigPtr srcConfig)
+{
+    /* Use the right device */
+    
+    free(dstScreen->device_name);
+    dstScreen->device_name = xconfigStrdup(srcScreen->device_name);
+    dstScreen->device =
+        xconfigFindDevice(dstScreen->device_name, dstConfig->devices);
+    
+
+    /* Use the right monitor */
+    
+    free(dstScreen->monitor_name);
+    dstScreen->monitor_name = xconfigStrdup(srcScreen->monitor_name);
+    dstScreen->monitor =
+        xconfigFindMonitor(dstScreen->monitor_name, dstConfig->monitors);
+    
+
+    /* Update the right default depth */
+    
+    dstScreen->defaultdepth = srcScreen->defaultdepth;
+    
+
+    /* Copy over the display section */
+    
+    xconfigMergeDisplays(dstScreen, srcScreen);
+   
+
+    /* Update the screen's driver options */
+
+    xconfigMergeDriverOptions(dstScreen, srcScreen);
+
+} /* xconfigMergeScreens() */
+
+
+
+/*
+ * xconfigMergeAllScreens() - This function ensures that all screens in
+ * the source config appear in the destination config by adding and/or
+ * updating the "appropriate" destination screen sections.
+ *
+ */
+static int xconfigMergeAllScreens(XConfigPtr dstConfig, XConfigPtr srcConfig)
+{
+    XConfigScreenPtr srcScreen;
+    XConfigScreenPtr dstScreen;
+
+
+    /* Make sure all src screens are in the dst config */
+
+    for (srcScreen = srcConfig->screens;
+         srcScreen;
+         srcScreen = srcScreen->next) {
+
+        dstScreen =
+            xconfigFindScreen(srcScreen->identifier, dstConfig->screens);
+
+        /* Screen section was not found, create a new one and add it */
+        if (!dstScreen) {
+            dstScreen =
+                (XConfigScreenPtr) calloc(1, sizeof(XConfigScreenRec));
+            if (!dstScreen) return 0;
+
+            dstScreen->identifier = xconfigStrdup(srcScreen->identifier);
+
+            dstConfig->screens = (XConfigScreenPtr)
+                xconfigAddListItem((GenericListPtr)dstConfig->screens,
+                                   (GenericListPtr)dstScreen);
+        }
+
+        /* Do the merge */
+        xconfigMergeScreens(dstScreen, dstConfig, srcScreen, srcConfig);
+    }
+
+    return 1;
+
+} /* xconfigMergeAllScreens() */
+
+
+
+/*
+ * xconfigMergeLayout() - Updates information in the destination's first
+ * layout with that of the source's first layout.
+ *
+ */
+static int xconfigMergeLayout(XConfigPtr dstConfig, XConfigPtr srcConfig)
+{
+    XConfigLayoutPtr srcLayout = srcConfig->layouts;
+    XConfigLayoutPtr dstLayout = dstConfig->layouts;
+
+    XConfigAdjacencyPtr srcAdj;
+    XConfigAdjacencyPtr dstAdj;
+    XConfigAdjacencyPtr lastDstAdj;
+
+    /* Clear the destination's adjacency list */
+
+    xconfigFreeAdjacencyList(dstLayout->adjacencies);
+    
+    /* Copy adjacencies over */
+    
+    lastDstAdj = NULL;
+    srcAdj = srcLayout->adjacencies;
+    while (srcAdj) {
+        
+        /* Copy the adjacency */
+        
+        dstAdj =
+            (XConfigAdjacencyPtr) calloc(1, sizeof(XConfigAdjacencyRec));
+
+        dstAdj->scrnum = srcAdj->scrnum;
+        dstAdj->screen_name = xconfigStrdup(srcAdj->screen_name);
+        dstAdj->top_name = xconfigStrdup(srcAdj->top_name);
+        dstAdj->bottom_name = xconfigStrdup(srcAdj->bottom_name);
+        dstAdj->left_name = xconfigStrdup(srcAdj->left_name);
+        dstAdj->right_name = xconfigStrdup(srcAdj->right_name);
+        dstAdj->where = srcAdj->where;
+        dstAdj->x = srcAdj->x;
+        dstAdj->y = srcAdj->y;
+        dstAdj->refscreen = xconfigStrdup(srcAdj->refscreen);
+
+        dstAdj->screen =
+            xconfigFindScreen(dstAdj->screen_name, dstConfig->screens);
+        dstAdj->top =
+            xconfigFindScreen(dstAdj->top_name, dstConfig->screens);
+        dstAdj->bottom =
+            xconfigFindScreen(dstAdj->bottom_name, dstConfig->screens);
+        dstAdj->left =
+            xconfigFindScreen(dstAdj->left_name, dstConfig->screens);
+        dstAdj->right =
+            xconfigFindScreen(dstAdj->right_name, dstConfig->screens);
+
+        /* Add adjacency at the end of the list */
+        
+        if ( !lastDstAdj ) {
+            dstLayout->adjacencies = dstAdj;
+        } else {
+            lastDstAdj->next = dstAdj;
+        }
+        lastDstAdj = dstAdj;
+        
+        srcAdj = srcAdj->next;
+    }
+
+    return 1;
+
+} /* xconfigMergeLayout() */
+
+
+
+/*
+ * xconfigMergeConfigs() - Merges the source X configuration with the
+ * destination X configuration.
+ *
+ * NOTE: This function is currently only used for merging X config files
+ *       for display configuration reasons.  As such, the merge assumes
+ *       that the dst config file is the target config file and that
+ *       mostly, only new display configuration information should be
+ *       copied from the source X config to the destination X config.
+ *
+ */
+int xconfigMergeConfigs(XConfigPtr dstConfig, XConfigPtr srcConfig)
+{
+    /* Make sure the X config is falid */
+    // make_xconfig_usable(dstConfig);
+
+
+    /* Merge the server flag (Xinerama) section */
+
+    if (!xconfigMergeFlags(dstConfig, srcConfig)) {
+        return 0;
+    }
+
+
+    /* Merge the monitor sections */
+
+    if (!xconfigMergeAllMonitors(dstConfig, srcConfig)) {
+        return 0;
+    }
+
+
+    /* Merge the device sections */
+
+    if (!xconfigMergeAllDevices(dstConfig, srcConfig)) {
+        return 0;
+    }
+
+
+    /* Merge the screen sections */
+
+    if (!xconfigMergeAllScreens(dstConfig, srcConfig)) {
+        return 0;
+    }
+
+
+    /* Merge the first layout */
+    
+    if (!xconfigMergeLayout(dstConfig, srcConfig)) {
+        return 0;
+    }
+
+    return 1;
+
+} /* xconfigMergeConfigs() */

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

Modified: packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Monitor.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Monitor.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Monitor.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Monitor.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Pointer.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Pointer.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Pointer.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Pointer.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Read.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Read.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Read.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Read.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Scan.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Scan.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Scan.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Scan.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Screen.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Screen.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Screen.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Screen.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Vendor.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Vendor.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Vendor.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Vendor.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Video.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Video.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Video.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Video.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/Write.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Write.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Write.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/Write.c Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/configProcs.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/configProcs.h?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/configProcs.h (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/configProcs.h Tue Jun 24 17:49:43 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/branches/upstream/current/XF86Config-parser/xf86Parser.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/xf86Parser.h?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/xf86Parser.h (original)
+++ packages/nvidia-xconfig/branches/upstream/current/XF86Config-parser/xf86Parser.h Tue Jun 24 17:49:43 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_ */

Added: packages/nvidia-xconfig/branches/upstream/current/extract_edids.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/extract_edids.c?rev=418&op=file
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/extract_edids.c (added)
+++ packages/nvidia-xconfig/branches/upstream/current/extract_edids.c Tue Jun 24 17:49:43 2008
@@ -1,0 +1,1064 @@
+/*
+ * nvidia-xconfig: A tool for manipulating X config files,
+ * specifically for use by the NVIDIA Linux graphics driver.
+ *
+ * Copyright (C) 2006 NVIDIA Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the:
+ *
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ *
+ * extract-edids.c
+ *
+ * This source file gives us the means to extract EDIDs from verbose X
+ * log files or from .txt files. A verbose log will contain a raw EDID 
+ * byte dump like this:
+ *
+ * (--) NVIDIA(0): Raw EDID bytes:
+ * (--) NVIDIA(0):
+ * (--) NVIDIA(0):   00 ff ff ff ff ff ff 00  5a 63 47 4b fc 27 00 00
+ * (--) NVIDIA(0):   0f 0a 01 02 9e 1e 17 64  ee 04 85 a0 57 4a 9b 26
+ * (--) NVIDIA(0):   12 50 54 00 08 00 01 01  01 01 01 01 01 01 01 01
+ * (--) NVIDIA(0):   01 01 01 01 01 01 64 19  00 40 41 00 26 30 18 88
+ * (--) NVIDIA(0):   36 00 30 e4 10 00 00 18  00 00 00 ff 00 47 4b 30
+ * (--) NVIDIA(0):   31 35 31 30 32 33 36 0a  20 20 00 00 00 fc 00 56
+ * (--) NVIDIA(0):   69 65 77 53 6f 6e 69 63  20 56 50 44 00 00 00 fc
+ * (--) NVIDIA(0):   00 31 35 30 0a 20 20 20  20 20 20 20 20 20 00 ce
+ * (--) NVIDIA(0):
+ * (--) NVIDIA(0): --- End of EDID for ViewSonic VPD150 (DFP-1) ---
+ *
+ * A .txt file will contain a raw EDID byte dump like this:
+ *
+ * 00 FF FF FF FF FF FF 00-06 10 F4 01 01 01 01 01    ................
+ * 27 08 01 01 28 1F 17 96-E8 44 E4 A1 57 4A 97 23    '...(....D..WJ.#
+ * 19 4F 57 BF EE 00 01 01-01 01 01 01 01 01 01 01    .OW.............
+ * 01 01 01 01 01 01 64 19-00 40 41 00 26 30 18 88    ......d.. at A.&0..
+ * 36 00 33 E6 10 00 00 18-40 1F 00 30 41 00 24 30    6.3..... at ..0A.$0
+ * 20 60 33 00 33 E6 10 00-00 18 00 00 00 FD 00 38     `3.3..........8
+ * 4C 1F 3D 08 00 0A 20 20-20 20 20 20 00 00 00 FC    L.=...      ....
+ * 00 41 70 70 6C 65 53 74-75 64 69 6F 0A 20 00 88    .AppleStudio. ..
+ *
+ * EDID Version                : 1.1
+ *
+ * We read a log file or a .txt file, identify and read any EDID(s) contained 
+ * in the file, and then write the EDID bytes to edid.bin files (just
+ * like what nvidia-settings can capture for display devices running
+ * on the current X server).
+ *
+ * This is useful for NVIDIA engineers to simulate users' display
+ * environments, based on a verbose nvidia-bug-report.log or X log or a .txt
+ * file. This utility is included in nvidia-xconfig, since maybe users will
+ * find use for this, too.
+ */
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <pwd.h>
+#include <stdarg.h>
+#include <strings.h> /* bzero() */
+
+#include "nvidia-xconfig.h"
+
+
+#define NIBBLE_TO_HEX(n) (((n) <= 9) ? ('0' + (n)) : ('a' - 0xa + (n)))
+
+#define HEX_TO_NIBBLE(n)                                                \
+    ((((n) >= '0') && ((n) <= '9')) ? ((n) - '0') :                     \
+        ((((n) >= 'a') && ((n) <= 'f')) ? (((n) - 'a') + 10) :          \
+            ((((n) >= 'A') && ((n) <= 'F')) ? (((n) - 'A') + 10) : 0))) \
+
+#define IS_HEX(n) ((((n) >= '0') && ((n) <= '9')) || \
+                   (((n) >= 'a') && ((n) <= 'f')) || \
+                   (((n) >= 'A') && ((n) <= 'F')))
+
+#define TRUE 1
+#define FALSE 0
+
+#define EDID_OUTPUT_FILE_NAME "edid.bin"
+
+#define LOG_FILE 10
+#define TEXT_FILE 20
+#define UNKNOWN_FILE 30
+
+typedef struct {
+    int size;
+    unsigned char *bytes;
+    char *name;
+} EdidRec, *EdidPtr;
+
+typedef struct {
+    char *start;
+    size_t length;
+    char *current;
+} FileRec, *FilePtr;
+
+
+static int findFileType(FilePtr pFile);
+
+static EdidPtr findEdidforLogFile(FilePtr pFile);
+static EdidPtr findEdidforTextFile(FilePtr pFile);
+
+static int findEdidHeaderforLogFile(FilePtr pFile);
+static int readEdidDataforLogFile(FilePtr pFile, EdidPtr pEdid);
+static int readEdidFooterforLogFile(FilePtr pFile, EdidPtr pEdid);
+
+static int findEdidfooterforTextFile(FilePtr pFile);
+static int readEdidDataforTextFile(FilePtr pFile, EdidPtr pEdid);
+static int readMonitorNameforTextFile(FilePtr pFile, EdidPtr pEdid);
+
+static char *findFileName(char *option);
+static int writeEdidFile(EdidPtr pEdid, char *filename);
+
+static void freeEdid(EdidPtr pEdid);
+
+
+
+/*
+ * extract_edids() - see description at the top of this file
+ */
+
+int extract_edids(Options *op)
+{
+    int fd = -1, ret, fileType, funcRet = FALSE;
+    char *filename;
+    
+    struct stat stat_buf;
+ 
+    FileRec file;
+    EdidPtr pEdid, *pEdids;
+    int nEdids, i;
+    
+    nEdids = 0;
+    pEdid = NULL;
+    pEdids = NULL;
+    
+    memset(&file, 0, sizeof(FileRec));
+    file.start = (void *) -1;
+    
+    /* open the file and get its length */
+    
+    fd = open(op->extract_edids_from_file, O_RDONLY);
+    
+    if (fd == -1) {
+        fmterr("Unable to open file \"%s\".", op->extract_edids_from_file);
+        goto done;
+    }
+    
+    ret = fstat(fd, &stat_buf);
+
+    if (ret == -1) {
+        fmterr("Unable to get length of file \"%s\".",
+               op->extract_edids_from_file);
+        goto done;
+    }
+    
+    file.length = stat_buf.st_size;
+
+    if (file.length == 0) {
+        fmterr("File \"%s\" is empty.", op->extract_edids_from_file);
+        goto done;
+    }
+    
+    /* mmap the file */
+
+    file.start = mmap(0, file.length, PROT_READ,
+                      MAP_SHARED, fd, 0);
+
+    if (file.start == (void *) -1) {
+        fmterr("Unable to map file \"%s\".", op->extract_edids_from_file);
+        goto done;
+    }
+    
+    /* start parsing at the start of file */
+
+    file.current = file.start;
+    
+    /* check for the file type(log or .txt) */
+
+    fileType = findFileType(&file);
+    
+    /* if the file does not contain any edid information, goto done */
+  
+    if (fileType == UNKNOWN_FILE) {
+        funcRet = TRUE;
+        goto done;
+    } 
+
+    if (fileType == LOG_FILE) {
+        file.current = file.start;
+    }
+
+    /* scan through the whole file, and build a list of pEdids */
+    
+    while(1) {
+    
+        if (fileType == LOG_FILE) {
+    
+            pEdid = findEdidforLogFile(&file);
+    
+        }
+        
+        if (fileType == TEXT_FILE) {
+    
+            pEdid = findEdidforTextFile(&file);
+    
+        }
+   
+        if (!pEdid) break;
+        
+        pEdids = nvrealloc(pEdids, sizeof(pEdids) * (nEdids + 1));
+        
+        pEdids[nEdids] = pEdid;
+        nEdids++;
+
+        /* Only one edid in a .txt file */
+
+        if (fileType == TEXT_FILE) break;
+    }
+    
+    /* fall through to the 'done' label */
+    
+    funcRet = TRUE;
+
+ done:
+    
+    /* unmap and close the file */
+    
+    if (file.start != (void *) -1) {
+        munmap(file.start, file.length);
+    }
+
+    if (fd != -1) {
+        close(fd);
+    }
+    
+    
+    /* write the EDIDs to file */
+    
+    /*
+     * determine the base filename; this is what we pass to
+     * writeEdidFile; it will unique-ify from there
+     */
+
+    fmtout("");
+    fmtout("Found %d EDID%s in \"%s\".",
+           nEdids, (nEdids == 1) ? "": "s", op->extract_edids_from_file);
+
+    filename = findFileName(op->extract_edids_output_file);
+    
+    for (i = 0; i < nEdids; i++) {
+        
+        pEdid = pEdids[i];
+
+        funcRet = writeEdidFile(pEdid, filename);
+
+        freeEdid(pEdid);
+    }
+    
+    if (pEdids) nvfree(pEdids);
+
+    nvfree(filename);
+    
+    fmtout("");
+
+    return funcRet;
+
+} // extract_edids()
+
+/*
+ * findFileType() - scan through the pFile to determine the file type
+ * file type can be LOG_FILE, TEXT_FILE, UNKNOWN_FILE(file with no EDID) 
+ */
+
+static int findFileType(FilePtr pFile)
+{ 
+    if (findEdidHeaderforLogFile(pFile)) return LOG_FILE;
+   
+    if (findEdidfooterforTextFile(pFile)) return TEXT_FILE;
+
+    return UNKNOWN_FILE;
+
+} // findFileType()
+
+/*
+ * findEdid() - scan through pFile for an EDID header, if we find one,
+ * parse the EDID data and footer.  On success, return a newly
+ * allocated pEdid data structure.  On failure, return NULL.
+ */
+ 
+static EdidPtr findEdidforLogFile(FilePtr pFile)
+{
+    EdidPtr pEdid = nvalloc(sizeof(EdidRec));
+    
+    if (!findEdidHeaderforLogFile(pFile)) goto fail;
+    
+    if (!readEdidDataforLogFile(pFile, pEdid)) goto fail;
+
+    if (!readEdidFooterforLogFile(pFile, pEdid)) goto fail;
+    
+    return pEdid;
+    
+ fail:
+    
+    freeEdid(pEdid);
+    
+    return NULL;
+    
+} // findEdidforLogFile()
+
+/*
+ * scan through the pFile for EDID data and Monitor name.
+ */
+
+static EdidPtr findEdidforTextFile(FilePtr pFile)
+{
+    EdidPtr pEdid = nvalloc(sizeof(EdidRec));
+
+    if (!readEdidDataforTextFile(pFile,pEdid)) goto fail;
+    if (!readMonitorNameforTextFile(pFile, pEdid)) goto fail;
+
+    return pEdid;
+
+ fail:
+
+    freeEdid(pEdid);
+
+    return NULL;
+
+} // findEdidforTextFile()
+
+
+/*
+ * findEdidHeader() - scan the mmapped file, starting at
+ * 'pFile->current', for the string "Raw EDID bytes:".  If we find the
+ * string, return TRUE, and leave pFile->current pointing to the first
+ * character past the string.  If we reach the end of the mmapped
+ * file, return FALSE.
+ */
+
+static int findEdidHeaderforLogFile(FilePtr pFile)
+{
+    while (((pFile->current - pFile->start) + 15) <= pFile->length) {
+        
+        if ((pFile->current[0]  == 'R') &&
+            (pFile->current[1]  == 'a') &&
+            (pFile->current[2]  == 'w') &&
+            (pFile->current[3]  == ' ') &&
+            (pFile->current[4]  == 'E') &&
+            (pFile->current[5]  == 'D') &&
+            (pFile->current[6]  == 'I') &&
+            (pFile->current[7]  == 'D') &&
+            (pFile->current[8]  == ' ') &&
+            (pFile->current[9]  == 'b') &&
+            (pFile->current[10] == 'y') &&
+            (pFile->current[11] == 't') &&
+            (pFile->current[12] == 'e') &&
+            (pFile->current[13] == 's') &&
+            (pFile->current[14] == ':')) {
+            
+            pFile->current += 15;
+            return TRUE;
+        }
+        pFile->current++;
+    }
+
+    return FALSE;
+    
+} // findEdidHeaderforLogFile()
+
+
+
+/*
+ * readEdidData() - start parsing at pFile->current for the EDID
+ * string; it is assumed that pFile was advanced to the correct
+ * position by findEdidHeader() (i.e., we should be immediately after
+ * "Raw EDID bytes:").  We use a state machine to look for the lower
+ * and upper nibbles of each EDID byte, and to advance past the label,
+ * that looks something like "(--) NVIDIA(0):".
+ */
+
+#define STATE_LOOKING_FOR_TOP_NIBBLE    0
+#define STATE_LOOKING_FOR_BOTTOM_NIBBLE 1
+#define STATE_LOOKING_FOR_END_OF_LABEL 2
+
+#define MAX_EDID_SIZE 4096
+
+static int readEdidDataforLogFile(FilePtr pFile, EdidPtr pEdid)
+{
+    int state;
+    
+    unsigned char pData[MAX_EDID_SIZE];
+    int k;
+
+    char c;
+
+    /* clear the scratch EDID data */
+
+    bzero(pData, MAX_EDID_SIZE);
+
+    /*
+     * start the parsing state machine by looking for the upper nibble
+     * of the first byte in the EDID
+     */
+    
+    state = STATE_LOOKING_FOR_TOP_NIBBLE;
+    k = 0;
+    
+    while(1) {
+        
+        c = pFile->current[0];
+
+        switch (state) {
+            
+        case STATE_LOOKING_FOR_TOP_NIBBLE:
+            
+            /* if we hit a newline, transition to label parsing */
+            
+            if (c == '\n') {
+                state = STATE_LOOKING_FOR_END_OF_LABEL;
+                goto nextChar;
+            }
+            
+            /* skip white space; keep looking for top nibble */
+            
+            if (isspace(c)) {
+                state = STATE_LOOKING_FOR_TOP_NIBBLE;
+                goto nextChar;
+            }
+
+            /*
+             * if we found a hex value, treat it as upper nibble, then
+             * look for lower nibble
+             */
+
+            if (IS_HEX(c)) {
+                pData[k] |= ((HEX_TO_NIBBLE(c)) << 4);
+                state = STATE_LOOKING_FOR_BOTTOM_NIBBLE;
+                goto nextChar;
+            }
+            
+            /*
+             * if we find the text "--- End of EDID for ... ---", then
+             * we want to parse that to find out the name of the
+             * display device whose EDID we are reading; this is also
+             * our exit condition for the state machine
+             */
+            
+            if (c == '-') {
+                goto done;
+            }
+            
+            goto fail; /* anything else is an error */
+            
+            break;
+            
+        case STATE_LOOKING_FOR_BOTTOM_NIBBLE:
+
+            /*
+             * if we found a hex value, treat it as the lower nibble,
+             * then look for the upper nibble of the next byte
+             */
+            
+            if (IS_HEX(c)) {
+                pData[k] |= (HEX_TO_NIBBLE(c));
+                state = STATE_LOOKING_FOR_TOP_NIBBLE;
+                k++;
+                if (k >= MAX_EDID_SIZE) goto fail;
+                goto nextChar;
+            }
+            
+            goto fail; /* anything else is an error */
+            
+            break;
+            
+        case STATE_LOOKING_FOR_END_OF_LABEL:
+
+            /*
+             * if we find a colon, then we are at the end of the
+             * label; transition to looking for the upper nibble of
+             * the next EDID byte
+             */
+            
+            if (c == ':') {
+                state = STATE_LOOKING_FOR_TOP_NIBBLE;
+                goto nextChar;
+            }
+            
+            /*
+             * anything else is assumed to be text within the label,
+             * so just ignore it
+             */
+            
+            break;
+
+        default:
+            
+            goto fail; /* should never get here */
+            
+            break;
+        }
+   
+    nextChar:
+        
+        /*
+         * if we are at the end of the mapping without hitting our
+         * exit condition, fail
+         */
+        
+        if ((pFile->current - pFile->start) >= pFile->length) goto fail;
+        
+        /* move to the next character, and run the state machine again */
+
+        pFile->current++;
+        
+    } /* while(1) */
+    
+ done:
+    
+    /* we are done parsing the EDID, save what we have into pEdid */
+    
+    if (k <= 0) goto fail;
+    
+    pEdid->size = k;
+    pEdid->bytes = nvalloc(k);
+    
+    memcpy(pEdid->bytes, pData, k);
+    
+    return TRUE;
+
+ fail:
+    
+    return FALSE;
+
+} // readEdidDataforLogFile()
+
+/*
+ * read EDID data for the .txt file; pFile->current gives the starting 
+ * position of the EDID bytes, which is same as file starting position.
+ * We use a state machine to look for the lower and upper nibbles of each
+ * EDID byte, and to advance past the label.
+ */
+
+static int readEdidDataforTextFile(FilePtr pFile, EdidPtr pEdid)
+{
+    int state;
+
+    unsigned char pData[MAX_EDID_SIZE];
+    int k;
+
+    char c;
+
+    /* clear the scratch EDID data */
+
+    bzero(pData, MAX_EDID_SIZE);
+
+    /*
+     * start the parsing state machine by looking for the upper nibble
+     * of the first byte in the EDID
+     */
+
+    state = STATE_LOOKING_FOR_TOP_NIBBLE;
+    k = 0;
+
+    while(1) {
+
+    c = pFile->current[0];
+
+        switch (state) {
+
+        case STATE_LOOKING_FOR_TOP_NIBBLE:
+            
+            /*
+             * if we found a hex value, treat it as upper nibble, then
+             * look for lower nibble
+             */
+
+            if (IS_HEX(c)) {
+                pData[k] |= ((HEX_TO_NIBBLE(c)) << 4);
+                state = STATE_LOOKING_FOR_BOTTOM_NIBBLE;
+                goto nextChar;
+            }
+            
+            /* skip '-' and keep looking for top nibble */
+
+            if (c == '-') {
+                state = STATE_LOOKING_FOR_TOP_NIBBLE;
+                goto nextChar;
+            }
+           
+            /* 
+             * if two consecutive white space, change lebel.
+             * if one white space, skip it.
+             */
+  
+            if (isspace(c)) {
+                
+                if (isspace(pFile->current[1])) {
+                    state = STATE_LOOKING_FOR_END_OF_LABEL;
+                    goto nextChar;
+                } else {
+                    state = STATE_LOOKING_FOR_TOP_NIBBLE;
+                    goto nextChar;
+                }
+            }
+
+            goto fail; /* anything else is an error */
+
+            break;
+
+        case STATE_LOOKING_FOR_BOTTOM_NIBBLE:
+
+            /*
+             * if we found a hex value, treat it as the lower nibble,
+             * then look for the upper nibble of the next byte
+             */
+  
+            if (IS_HEX(c)) {
+                pData[k] |= (HEX_TO_NIBBLE(c));
+                state = STATE_LOOKING_FOR_TOP_NIBBLE;
+                k++;
+                if (k >= MAX_EDID_SIZE) goto fail;
+                goto nextChar;
+            }
+
+            goto fail; /* anything else is an error */
+
+            break;
+
+        case STATE_LOOKING_FOR_END_OF_LABEL:
+            
+            /* if we found two consecutive '\r\n', then the reding of EDID
+             * information is complete. if only one '\r\n', then change the
+             * state.
+             */
+
+            if (c == '\r' && pFile->current[1] == '\n') {
+                
+                if (pFile->current[2] == '\r' && pFile->current[3] == '\n') {
+                   goto done;
+                } else {
+                    state = STATE_LOOKING_FOR_TOP_NIBBLE;
+                    goto nextChar;
+                }
+            }
+            
+            /* skip the white space */
+ 
+            if (isspace(c)) {
+            
+                state = STATE_LOOKING_FOR_END_OF_LABEL;
+                goto nextChar;
+ 
+            }
+
+            break;
+
+        default:
+
+            goto fail;
+
+            break;
+        }
+
+    nextChar:
+
+        /*
+         * if we are at the end of the mapping without hitting our
+         * exit condition, fail
+         */
+
+        if ((pFile->current - pFile->start) >= pFile->length) goto fail;
+
+        pFile->current++;
+    } /* while(1) */
+
+ done:
+    
+    /* we are done parsing the EDID, save what we have into pEdid */
+   
+    if (k <= 0) goto fail;
+
+    pEdid->size = k;
+    pEdid->bytes = nvalloc(k);
+
+    memcpy(pEdid->bytes, pData, k);
+
+    return TRUE;
+     
+ fail:
+
+    return FALSE;
+
+} // readEdidDataforTextFile()
+
+/*
+ * readEdidFooter() - the EDID footer is in the form:
+ *
+ * --- End of EDID for [dpy name] ---
+ *
+ * Parse the footer to get the dpy name.  pFile->current is expected
+ * to point at the start of the footer.  On success, pEdid->name is
+ * assigned and TRUE is returned.  On failure, FALSE is returned.
+ */
+
+static int readEdidFooterforLogFile(FilePtr pFile, EdidPtr pEdid)
+{
+    char *begin;
+    int len;
+    
+    /* check that the mapping is large enough */
+
+    if (((pFile->current - pFile->start) + 20) > pFile->length) {
+        return FALSE;
+    }
+
+    /* make sure that the expected text is there */
+
+    if ((pFile->current[0]  != '-') ||
+        (pFile->current[1]  != '-') ||
+        (pFile->current[2]  != '-') ||
+        (pFile->current[3]  != ' ') ||
+        (pFile->current[4]  != 'E') ||
+        (pFile->current[5]  != 'n') ||
+        (pFile->current[6]  != 'd') ||
+        (pFile->current[7]  != ' ') ||
+        (pFile->current[8]  != 'o') ||
+        (pFile->current[9]  != 'f') ||
+        (pFile->current[10] != ' ') ||
+        (pFile->current[11] != 'E') ||
+        (pFile->current[12] != 'D') ||
+        (pFile->current[13] != 'I') ||
+        (pFile->current[14] != 'D') ||
+        (pFile->current[15] != ' ') ||
+        (pFile->current[16] != 'f') ||
+        (pFile->current[17] != 'o') ||
+        (pFile->current[18] != 'r') ||
+        (pFile->current[19] != ' ')) {
+        
+        return FALSE;
+    }
+    
+    /* skip past the start */
+
+    pFile->current += 20;
+    
+    begin = pFile->current;
+    
+    /* search for the end of the expected text */
+
+    while (((pFile->current - pFile->start) + 5) <= pFile->length) {
+
+        if ((pFile->current[0] == ' ') &&
+            (pFile->current[1] == '-') &&
+            (pFile->current[2] == '-') &&
+            (pFile->current[3] == '-')) {
+            
+            len = pFile->current - begin;
+
+            /* make sure the name length seems reasonable */
+
+            if ((len > 512) || (len < 1)) {
+                return FALSE;
+            }
+            
+            pEdid->name = nvalloc(len + 1);
+                
+            strncpy(pEdid->name, begin, len);
+            pEdid->name[len] = '\0';
+            
+            return TRUE;
+        }
+
+        pFile->current++;
+    }
+
+    return FALSE;
+    
+} // readEdidFooterforLogFile()
+
+/* 
+ * read Edid Footer i.e. "EDID Version".
+ * this information is used to check whether the .txt file contains
+ * any edid information or not
+ */
+ 
+static int findEdidfooterforTextFile(FilePtr pFile)
+{   
+    pFile->current = pFile->start;
+    while (((pFile->current - pFile->start) + 12) <= pFile->length) {
+
+        if ((pFile->current[0]  == 'E') &&
+            (pFile->current[1]  == 'D') &&
+            (pFile->current[2]  == 'I') &&
+            (pFile->current[3]  == 'D') && 
+            (pFile->current[4]  == ' ') &&
+            (pFile->current[5]  == 'V') &&
+            (pFile->current[6]  == 'e') &&
+            (pFile->current[7]  == 'r') &&
+            (pFile->current[8]  == 's') &&
+            (pFile->current[9]  == 'i') &&
+            (pFile->current[10] == 'o') &&
+            (pFile->current[11] == 'n')) {
+            
+            pFile->current = pFile->start;
+            return TRUE;
+        }
+        pFile->current++;
+    }
+    
+return FALSE;
+
+} // findEdidfooterforTextFile()
+
+/* read the monitor information */
+
+static int readMonitorNameforTextFile(FilePtr pFile, EdidPtr pEdid)
+{
+    char *begin;
+    int len;
+
+    while (((pFile->current - pFile->start) + 12) <= pFile->length) {
+
+        if ((pFile->current[0]  == 'M') &&
+            (pFile->current[1]  == 'o') &&
+            (pFile->current[2]  == 'n') &&
+            (pFile->current[3]  == 'i') &&
+            (pFile->current[4]  == 't') &&
+            (pFile->current[5]  == 'o') &&
+            (pFile->current[6]  == 'r') &&
+            (pFile->current[7]  == ' ') &&
+            (pFile->current[8]  == 'N') &&
+            (pFile->current[9]  == 'a') &&
+            (pFile->current[10] == 'm') &&
+            (pFile->current[11] == 'e')) {
+        
+            pFile->current += 12;
+            goto next;
+        }
+     
+        pFile->current++;
+
+    }
+    return FALSE;
+
+    next:
+
+       /* search for start of the expected text */
+
+       while (pFile->current[0] != ':') pFile->current++;
+       pFile->current += 2;
+
+       begin = pFile->current;
+
+       /* search for the end of expected text */
+  
+       while (((pFile->current - pFile->start) + 2) <= pFile->length) {
+
+           if ((pFile->current[0] == '\r') && (pFile->current[1] == '\n')) {
+
+               len = pFile->current - begin;
+               
+               if ((len > 512) || (len < 1)) {
+                   return FALSE;
+               }
+   
+               pEdid->name = nvalloc(len + 1);
+
+               strncpy(pEdid->name, begin, len);
+               pEdid->name[len] = '\0';
+
+               return TRUE;
+           }
+           pFile->current++;
+       }
+
+     return FALSE;
+
+} // readMonitorNameforTextFile() 
+
+/*
+ * findFileName() - determine the filename to use for writing out the
+ * EDID
+ */
+
+static char *findFileName(char *option)
+{
+    char *tmp;
+    struct passwd *pw;
+    
+    /* if the user gave an option, start by expanding '~' */
+    
+    if (option) {
+        return nvstrdup(tilde_expansion(option));
+    }
+
+    /* if we can write to the current directory, then use that */
+    
+    if (access(".", R_OK|W_OK|X_OK|F_OK) == 0) {
+        return nvstrcat("./", EDID_OUTPUT_FILE_NAME, NULL);
+    }
+
+    /*
+     * otherwise, if we can get the user's home directory, and have
+     * access to it, then use it
+     */
+
+    tmp = getenv("HOME");
+    
+    if (!tmp) {
+        pw = getpwuid(getuid());
+        if (pw) tmp = pw->pw_dir;
+    }
+    
+    if (tmp && (access(tmp, R_OK|W_OK|X_OK|F_OK) == 0)) {
+        return nvstrcat(tmp, "/", EDID_OUTPUT_FILE_NAME, NULL);
+    }
+    
+    /* finally, just give them /tmp/edid.bin */
+    
+    return nvstrcat("/tmp/", EDID_OUTPUT_FILE_NAME, NULL);
+    
+} // findFileName()
+
+
+
+/*
+ * writeEdidFile() - write the EDID to file
+ */
+
+static int writeEdidFile(EdidPtr pEdid, char *filename)
+{
+    int fd = -1, ret = FALSE;
+    char *dst = (void *) -1;
+    char *msg = "?";
+    char *working_filename;
+    char scratch[64];
+    int n;
+    
+    /*
+     * create a unique filename; if the given filename isn't already
+     * unique, append ".#" until it is unique.
+     *
+     * XXX there is a race between checking the existence of the file,
+     * here, and opening the file below
+     */
+    
+    n = 0;
+    working_filename = nvstrdup(filename);
+    
+    while (access(working_filename, F_OK) == 0) {
+        snprintf(scratch, 64, "%d", n++);
+        nvfree(working_filename);
+        working_filename = nvstrcat(filename, ".", scratch, NULL);
+    }
+
+    /* open the file */
+    
+    fd = open(working_filename, O_RDWR | O_CREAT | O_TRUNC,
+              S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+    
+    if (fd == -1) {
+        msg = "Unable to open file for writing";
+        goto done;
+    }
+    
+    /* set the size of the file */
+
+    if (lseek(fd, pEdid->size - 1, SEEK_SET) == -1) {
+        msg = "Unable to set file size";
+        goto done;
+    }
+    
+    if (write(fd, "", 1) != 1) {
+        msg = "Unable to write output file size";
+        goto done;
+    }
+    
+    /* mmap the file */
+
+    if ((dst = mmap(0, pEdid->size, PROT_READ | PROT_WRITE,
+                    MAP_SHARED, fd, 0)) == (void *) -1) {
+        msg = "Unable to map file for copying";
+        goto done;
+    }
+    
+    /* copy the data into the file */
+
+    memcpy(dst, pEdid->bytes, pEdid->size);
+    
+    /* record success and fall through into done */
+    
+    ret = TRUE;
+    
+ done:
+
+    /* unmap the file */
+    
+    if (dst != (void *) -1) {
+        if (munmap(dst, pEdid->size) != 0) {
+            msg = "Unable to unmap file";
+            ret = FALSE;
+        }
+    }
+
+    /* close the file */
+    
+    if (fd != -1) {
+        if (close(fd) != 0) {
+            msg = "Unable to close file";
+            ret = FALSE;
+        }
+    }
+    
+    /* report what happened */
+
+    if (ret) {
+        fmtout("  Wrote EDID for \"%s\" to \"%s\" (%d bytes).",
+               pEdid->name, working_filename, pEdid->size);
+    } else {
+        fmterr("Failed to write EDID for \"%s\" to \"%s\" (%s)",
+               pEdid->name, working_filename, msg);
+    }
+    
+    nvfree(working_filename);
+    
+    return ret;
+    
+} /* writeEdidFile() */
+
+
+
+/*
+ * freeEdid() - free the EDID data structure
+ */
+
+static void freeEdid(EdidPtr pEdid)
+{
+    if (pEdid->bytes) nvfree(pEdid->bytes);
+    if (pEdid->name) nvfree(pEdid->name);
+    
+    nvfree(pEdid);
+    
+} /* freeEdid() */

Modified: packages/nvidia-xconfig/branches/upstream/current/gen-manpage-opts.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/gen-manpage-opts.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/gen-manpage-opts.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/gen-manpage-opts.c Tue Jun 24 17:49:43 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/branches/upstream/current/lscf.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/lscf.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/lscf.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/lscf.c Tue Jun 24 17:49:43 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/branches/upstream/current/make_usable.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/make_usable.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/make_usable.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/make_usable.c Tue Jun 24 17:49:43 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/branches/upstream/current/multiple_screens.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/multiple_screens.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/multiple_screens.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/multiple_screens.c Tue Jun 24 17:49:43 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/branches/upstream/current/nvgetopt.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/nvgetopt.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/nvgetopt.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/nvgetopt.c Tue Jun 24 17:49:43 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/branches/upstream/current/nvgetopt.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/nvgetopt.h?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/nvgetopt.h (original)
+++ packages/nvidia-xconfig/branches/upstream/current/nvgetopt.h Tue Jun 24 17:49:43 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/branches/upstream/current/nvidia-cfg.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/nvidia-cfg.h?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/nvidia-cfg.h (original)
+++ packages/nvidia-xconfig/branches/upstream/current/nvidia-cfg.h Tue Jun 24 17:49:43 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/branches/upstream/current/nvidia-xconfig.1.m4
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/nvidia-xconfig.1.m4?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/nvidia-xconfig.1.m4 (original)
+++ packages/nvidia-xconfig/branches/upstream/current/nvidia-xconfig.1.m4 Tue Jun 24 17:49:43 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/branches/upstream/current/nvidia-xconfig.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/nvidia-xconfig.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/nvidia-xconfig.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/nvidia-xconfig.c Tue Jun 24 17:49:43 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/branches/upstream/current/nvidia-xconfig.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/nvidia-xconfig.h?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/nvidia-xconfig.h (original)
+++ packages/nvidia-xconfig/branches/upstream/current/nvidia-xconfig.h Tue Jun 24 17:49:43 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/branches/upstream/current/option_table.h
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/option_table.h?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/option_table.h (original)
+++ packages/nvidia-xconfig/branches/upstream/current/option_table.h Tue Jun 24 17:49:43 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/branches/upstream/current/options.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/options.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/options.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/options.c Tue Jun 24 17:49:43 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() */

Added: packages/nvidia-xconfig/branches/upstream/current/query_gpu_info.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/query_gpu_info.c?rev=418&op=file
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/query_gpu_info.c (added)
+++ packages/nvidia-xconfig/branches/upstream/current/query_gpu_info.c Tue Jun 24 17:49:43 2008
@@ -1,0 +1,232 @@
+/*
+ * nvidia-xconfig: A tool for manipulating X config files,
+ * specifically for use by the NVIDIA Linux graphics driver.
+ *
+ * Copyright (C) 2006 NVIDIA Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the:
+ *
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ *
+ * query_gpu_info.c
+ */
+
+#include "nvidia-xconfig.h"
+
+static char *display_device_mask_to_display_device_name(unsigned int mask);
+
+
+#define TAB    "  "
+#define BIGTAB "     "
+
+
+
+/*
+ * query_gpu_info() - query information about the GPU, and print it
+ * out
+ */
+
+int query_gpu_info(Options *op)
+{
+    DevicesPtr pDevices;
+    DisplayDevicePtr pDisplayDevice;
+    int i, j;
+    char *name;
+
+    /* query the GPU information */
+
+    pDevices = find_devices(op);
+    
+    if (!pDevices) {
+        fmterr("Unable to query GPU information");
+        return FALSE;
+    }
+    
+    /* print the GPU information */
+
+    fmtout("Number of GPUs: %d", pDevices->nDevices);
+
+    for (i = 0; i < pDevices->nDevices; i++) {
+        
+        fmtout("");
+        fmtout("GPU #%d:", i);
+        fmtoutp(TAB, "Name      : %s", pDevices->devices[i].name);
+        
+        fmtoutp(TAB, "PCI BusID : PCI:%d:%d:0",
+                pDevices->devices[i].dev.bus,
+                pDevices->devices[i].dev.slot);
+
+        fmtout("");
+        fmtoutp(TAB, "Number of Display Devices: %d",
+                pDevices->devices[i].nDisplayDevices);
+        fmtout("");
+
+        for (j = 0; j < pDevices->devices[i].nDisplayDevices; j++) {
+
+            pDisplayDevice = &pDevices->devices[i].displayDevices[j];
+
+            name = display_device_mask_to_display_device_name
+                (pDisplayDevice->mask);
+            
+            if (!name) name = nvstrdup("Unknown");
+
+            fmtoutp(TAB, "Display Device %d (%s):", j, name);
+        
+            nvfree(name);
+
+            /*
+             * convenience macro to first check that the value is
+             * non-zero
+             */
+            
+            #define PRT(_fmt, _val)                  \
+                if (_val) {                          \
+                    fmtoutp(BIGTAB, (_fmt), (_val)); \
+                }
+            
+            if (pDisplayDevice->info_valid) {
+                
+                PRT("EDID Name             : %s", 
+                    pDisplayDevice->info.monitor_name);
+                
+                PRT("Minimum HorizSync     : %.3f kHz",
+                    pDisplayDevice->info.min_horiz_sync/1000.0);
+                
+                PRT("Maximum HorizSync     : %.3f kHz",
+                    pDisplayDevice->info.max_horiz_sync/1000.0);
+                
+                PRT("Minimum VertRefresh   : %d Hz",
+                    pDisplayDevice->info.min_vert_refresh);
+                
+                PRT("Maximum VertRefresh   : %d Hz",
+                    pDisplayDevice->info.max_vert_refresh);
+                
+                PRT("Maximum PixelClock    : %.3f MHz",
+                    pDisplayDevice->info.max_pixel_clock/1000.0);
+                
+                PRT("Maximum Width         : %d pixels",
+                    pDisplayDevice->info.max_xres);
+                
+                PRT("Maximum Height        : %d pixels",
+                    pDisplayDevice->info.max_yres);
+                
+                PRT("Preferred Width       : %d pixels",
+                    pDisplayDevice->info.preferred_xres);
+                
+                PRT("Preferred Height      : %d pixels",
+                    pDisplayDevice->info.preferred_yres);
+                
+                PRT("Preferred VertRefresh : %d Hz",
+                    pDisplayDevice->info.preferred_refresh);
+                
+                PRT("Physical Width        : %d mm",
+                    pDisplayDevice->info.physical_width);
+                
+                PRT("Physical Height       : %d mm",
+                    pDisplayDevice->info.physical_height);
+                
+            } else {
+                fmtoutp(BIGTAB, "No EDID information available.");
+            }
+            
+            fmtout("");
+        }
+    }
+    
+    free_devices(pDevices);
+
+    return TRUE;
+    
+} /* query_gpu_info() */
+
+
+
+
+/*
+ * diaplay_mask/display_name conversions: the NV-CONTROL X extension
+ * identifies a display device by a bit in a display device mask.  The
+ * below function translates from a display mask to a string
+ * describing the display devices.
+ */
+
+#define BITSHIFT_CRT  0
+#define BITSHIFT_TV   8
+#define BITSHIFT_DFP 16
+
+#define BITMASK_ALL_CRT (0xff << BITSHIFT_CRT)
+#define BITMASK_ALL_TV  (0xff << BITSHIFT_TV)
+#define BITMASK_ALL_DFP (0xff << BITSHIFT_DFP)
+
+/*
+ * display_device_mask_to_display_name() - construct a string
+ * describing the given display device mask.
+ */
+
+#define DISPLAY_DEVICE_STRING_LEN 256
+
+static char *display_device_mask_to_display_device_name(unsigned int mask)
+{
+    char *s;
+    int first = TRUE;
+    unsigned int devcnt, devmask;
+    char *display_device_name_string;
+
+    display_device_name_string = nvalloc(DISPLAY_DEVICE_STRING_LEN);
+
+    s = display_device_name_string;
+
+    devmask = 1 << BITSHIFT_CRT;
+    devcnt = 0;
+    while (devmask & BITMASK_ALL_CRT) {
+        if (devmask & mask) {
+            if (first) first = FALSE;
+            else s += sprintf(s, ", ");
+            s += sprintf(s, "CRT-%X", devcnt);
+        }
+        devmask <<= 1;
+        devcnt++;
+    }
+
+    devmask = 1 << BITSHIFT_DFP;
+    devcnt = 0;
+    while (devmask & BITMASK_ALL_DFP) {
+        if (devmask & mask)  {
+            if (first) first = FALSE;
+            else s += sprintf(s, ", ");
+            s += sprintf(s, "DFP-%X", devcnt);
+        }
+        devmask <<= 1;
+        devcnt++;
+    }
+    
+    devmask = 1 << BITSHIFT_TV;
+    devcnt = 0;
+    while (devmask & BITMASK_ALL_TV) {
+        if (devmask & mask)  {
+            if (first) first = FALSE;
+            else s += sprintf(s, ", ");
+            s += sprintf(s, "TV-%X", devcnt);
+        }
+        devmask <<= 1;
+        devcnt++;
+    }
+    
+    *s = '\0';
+    
+    return (display_device_name_string);
+
+} /* display_device_mask_to_display_name() */

Modified: packages/nvidia-xconfig/branches/upstream/current/tree.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/tree.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/tree.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/tree.c Tue Jun 24 17:49:43 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/branches/upstream/current/util.c
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-xconfig/branches/upstream/current/util.c?rev=418&op=diff
==============================================================================
--- packages/nvidia-xconfig/branches/upstream/current/util.c (original)
+++ packages/nvidia-xconfig/branches/upstream/current/util.c Tue Jun 24 17:49:43 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