Merge lp:~dsiuchninski/ubuntu/precise/nvidia-settings/nvidia-settings into lp:ubuntu/precise/nvidia-settings

Proposed by Donald Siuchninski
Status: Merged
Merge reported by: Donald Siuchninski
Merged at revision: not available
Proposed branch: lp:~dsiuchninski/ubuntu/precise/nvidia-settings/nvidia-settings
Merge into: lp:ubuntu/precise/nvidia-settings
Diff against target: 25885 lines (+5586/-14793)
123 files modified
Makefile (+8/-199)
debian/changelog (+23/-0)
debian/control (+1/-1)
debian/patches/04_nvidia-settings_natty_ftbs.patch (+4/-5)
debian/patches/series (+0/-1)
debian/rules (+8/-5)
dist-files.mk (+0/-60)
doc/Makefile (+115/-0)
doc/src.mk (+2/-0)
doc/version.mk (+1/-0)
samples/Makefile (+7/-3)
samples/nv-control-dpy.c (+162/-21)
samples/nv-control-dvc.c (+1/-1)
samples/nv-control-events.c (+303/-337)
samples/nv-control-gvi.c (+8/-21)
samples/nv-control-info.c (+14/-7)
samples/nv-control-targets.c (+1/-1)
samples/src.mk (+2/-0)
samples/version.mk (+1/-0)
src/Makefile (+174/-0)
src/command-line.c (+9/-55)
src/command-line.h (+0/-2)
src/common-utils/common-utils.c (+337/-1)
src/common-utils/common-utils.h (+77/-1)
src/common-utils/gen-manpage-opts-helper.c (+181/-0)
src/common-utils/gen-manpage-opts-helper.h (+24/-0)
src/common-utils/nvgetopt.c (+125/-0)
src/common-utils/nvgetopt.h (+24/-0)
src/common-utils/src.mk (+6/-0)
src/config-file.c (+2/-2)
src/gen-manpage-opts.c (+5/-114)
src/glxinfo.c (+1/-0)
src/gtk+-2.x/ctk3dvisionpro.c (+1/-0)
src/gtk+-2.x/ctkbanner.c (+1/-2)
src/gtk+-2.x/ctkbanner.h (+0/-1)
src/gtk+-2.x/ctkclocks.c (+1/-0)
src/gtk+-2.x/ctkcolorcontrols.c (+94/-58)
src/gtk+-2.x/ctkcolorcontrols.h (+1/-5)
src/gtk+-2.x/ctkcolorcorrection.c (+13/-12)
src/gtk+-2.x/ctkconfig.c (+1/-0)
src/gtk+-2.x/ctkcursorshadow.c (+1/-0)
src/gtk+-2.x/ctkcurve.c (+1/-0)
src/gtk+-2.x/ctkdisplayconfig-utils.c (+481/-206)
src/gtk+-2.x/ctkdisplayconfig-utils.h (+3/-3)
src/gtk+-2.x/ctkdisplayconfig.c (+708/-557)
src/gtk+-2.x/ctkdisplayconfig.h (+26/-7)
src/gtk+-2.x/ctkdisplaydevice-crt.c (+0/-415)
src/gtk+-2.x/ctkdisplaydevice-crt.h (+0/-87)
src/gtk+-2.x/ctkdisplaydevice-dfp.c (+0/-1433)
src/gtk+-2.x/ctkdisplaydevice-dfp.h (+0/-106)
src/gtk+-2.x/ctkdisplaydevice-tv.c (+74/-114)
src/gtk+-2.x/ctkdisplaydevice-tv.h (+2/-4)
src/gtk+-2.x/ctkdisplaydevice.c (+717/-0)
src/gtk+-2.x/ctkdisplaydevice.h (+93/-0)
src/gtk+-2.x/ctkdisplaylayout.c (+37/-231)
src/gtk+-2.x/ctkdisplaylayout.h (+22/-5)
src/gtk+-2.x/ctkditheringcontrols.c (+174/-140)
src/gtk+-2.x/ctkditheringcontrols.h (+8/-8)
src/gtk+-2.x/ctkdropdownmenu.c (+1/-0)
src/gtk+-2.x/ctkecc.c (+1/-0)
src/gtk+-2.x/ctkedid.c (+23/-19)
src/gtk+-2.x/ctkedid.h (+3/-7)
src/gtk+-2.x/ctkevent.c (+26/-21)
src/gtk+-2.x/ctkframelock.c (+187/-265)
src/gtk+-2.x/ctkgauge.c (+1/-0)
src/gtk+-2.x/ctkglx.c (+1/-0)
src/gtk+-2.x/ctkgpu.c (+8/-61)
src/gtk+-2.x/ctkgvi.c (+3/-2)
src/gtk+-2.x/ctkgvo-banner.c (+1/-0)
src/gtk+-2.x/ctkgvo-csc.c (+1/-0)
src/gtk+-2.x/ctkgvo-sync.c (+1/-0)
src/gtk+-2.x/ctkgvo.c (+112/-1371)
src/gtk+-2.x/ctkgvo.h (+3/-33)
src/gtk+-2.x/ctkhelp.c (+2/-1)
src/gtk+-2.x/ctkimagesliders.c (+130/-157)
src/gtk+-2.x/ctkimagesliders.h (+3/-6)
src/gtk+-2.x/ctklicense.c (+1/-0)
src/gtk+-2.x/ctkmultisample.c (+33/-19)
src/gtk+-2.x/ctkopengl.c (+90/-0)
src/gtk+-2.x/ctkopengl.h (+1/-0)
src/gtk+-2.x/ctkpowermizer.c (+1/-0)
src/gtk+-2.x/ctkpowersavings.c (+1/-0)
src/gtk+-2.x/ctkrandr.c (+0/-644)
src/gtk+-2.x/ctkrandr.h (+0/-92)
src/gtk+-2.x/ctkscale.c (+1/-0)
src/gtk+-2.x/ctkscreen.c (+11/-79)
src/gtk+-2.x/ctkserver.c (+1/-0)
src/gtk+-2.x/ctkslimm.c (+2/-2)
src/gtk+-2.x/ctkthermal.c (+1/-0)
src/gtk+-2.x/ctkutils.c (+96/-16)
src/gtk+-2.x/ctkutils.h (+3/-2)
src/gtk+-2.x/ctkvcs.c (+2/-1)
src/gtk+-2.x/ctkwindow.c (+102/-103)
src/gtk+-2.x/ctkxvideo.c (+1/-0)
src/gtk+-2.x/src.mk (+0/-99)
src/image_data/rotate_left_off_pixdata.h (+0/-138)
src/image_data/rotate_left_on_pixdata.h (+0/-135)
src/image_data/rotate_right_off_pixdata.h (+0/-138)
src/image_data/rotate_right_on_pixdata.h (+0/-135)
src/image_data/rotation_orientation_horz_pixdata.h (+0/-2304)
src/image_data/rotation_orientation_vert_pixdata.h (+0/-2425)
src/image_data/rotation_pixdata.h (+0/-1347)
src/image_data/src.mk (+0/-99)
src/libXNVCtrl/Makefile (+1/-0)
src/libXNVCtrl/NVCtrl.h (+183/-156)
src/libXNVCtrl/nv_control.h (+4/-1)
src/libXNVCtrlAttributes/NvCtrlAttributes.c (+3/-32)
src/libXNVCtrlAttributes/NvCtrlAttributes.h (+1/-22)
src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h (+0/-14)
src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c (+0/-391)
src/libXNVCtrlAttributes/src.mk (+0/-14)
src/lscf.c (+3/-0)
src/msg.c (+3/-0)
src/msg.h (+0/-43)
src/option-table.h (+39/-35)
src/parse.c (+80/-45)
src/parse.h (+7/-3)
src/query-assign.c (+55/-48)
src/src.mk (+248/-0)
src/version.mk (+1/-0)
src/xpm_data/src.mk (+0/-24)
utils.mk (+18/-12)
version.mk (+1/-1)
To merge this branch: bzr merge lp:~dsiuchninski/ubuntu/precise/nvidia-settings/nvidia-settings
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+117213@code.launchpad.net

Description of the change

Fixed a typo in the short package description.

Originally: "Tool of configuring the NVIDIA graphics driver"
Changed: "Tool for configuring the NVIDIA graphics driver"

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2012-02-18 10:21:04 +0000
3+++ Makefile 2012-07-30 04:30:25 +0000
4@@ -2,7 +2,7 @@
5 # nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
6 # and Linux systems.
7 #
8-# Copyright (C) 2008 NVIDIA Corporation.
9+# Copyright (C) 2008-2012 NVIDIA Corporation.
10 #
11 # This program is free software; you can redistribute it and/or modify it
12 # under the terms and conditions of the GNU General Public License,
13@@ -17,201 +17,10 @@
14 # along with this program. If not, see <http://www.gnu.org/licenses>.
15 #
16
17-
18-##############################################################################
19-# include common variables and functions
20-##############################################################################
21-
22-include utils.mk
23-
24-
25-##############################################################################
26-# The calling Makefile may export any of the following variables; we
27-# assign default values if they are not exported by the caller
28-##############################################################################
29-
30-ifndef X_LDFLAGS
31- ifeq ($(TARGET_OS)-$(TARGET_ARCH),Linux-x86_64)
32- X_LDFLAGS = -L/usr/X11R6/lib64
33- else
34- X_LDFLAGS = -L/usr/X11R6/lib
35- endif
36-endif
37-
38-X_CFLAGS ?=
39-
40-GL_INCLUDE_PATH ?= /usr/include
41-
42-PKG_CONFIG ?= pkg-config
43-
44-ifndef GTK_CFLAGS
45- GTK_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-2.0)
46-endif
47-
48-ifndef GTK_LDFLAGS
49- GTK_LDFLAGS := $(shell $(PKG_CONFIG) --libs gtk+-2.0)
50-endif
51-
52-
53-##############################################################################
54-# The XF86Config-parser, libXNVCtrl, and common-utils directories may
55-# be in one of two places: either elsewhere in the driver source tree
56-# when building nvidia-settings as part of the NVIDIA driver build (in
57-# which case, XNVCTRL_DIR, XNVCTRL_ARCHIVE, XCONFIG_PARSER_DIR and
58-# COMMON_UTILS_DIR should be defined by the calling makefile), or
59-# directly in the source directory when building from the
60-# nvidia-settings source tarball (in which case, the below conditional
61-# assignments should be used)
62-##############################################################################
63-
64-XNVCTRL_DIR ?= src/libXNVCtrl
65-XNVCTRL_ARCHIVE ?= $(XNVCTRL_DIR)/libXNVCtrl.a
66-XCONFIG_PARSER_DIR ?= src/XF86Config-parser
67-COMMON_UTILS_DIR ?= src/common-utils
68-
69-##############################################################################
70-# assign variables
71-##############################################################################
72-
73-NVIDIA_SETTINGS = $(OUTPUTDIR)/nvidia-settings
74-
75-NVIDIA_SETTINGS_PROGRAM_NAME = "nvidia-settings"
76-
77-NVIDIA_SETTINGS_VERSION := $(NVIDIA_VERSION)
78-
79-CFLAGS += $(X_CFLAGS)
80-
81-ifeq ($(TARGET_OS),SunOS)
82- LDFLAGS += -Wl,-rpath=/usr/X11R6/lib
83-endif
84-
85-LDFLAGS += $(X_LDFLAGS)
86-
87-# Some older Linux distributions do not have the dynamic library
88-# libXxf86vm.so, though some newer Linux distributions do not have the
89-# static library libXxf86vm.a. Statically link against libXxf86vm
90-# when building nvidia-settings within the NVIDIA driver build, but
91-# dynamically link against libXxf86vm in the public builds.
92-ifdef NV_LINK_LIBXXF86VM_STATICALLY
93- LDFLAGS += -Wl,-Bstatic -lXxf86vm -Wl,-Bdynamic
94-else
95- LDFLAGS += -lXxf86vm
96-endif
97-
98-LDFLAGS += -lX11 -lXext -lm
99-LDFLAGS += $(GTK_LDFLAGS)
100-LDFLAGS += $(LIBDL_LDFLAGS)
101-
102-MANPAGE_GZIP ?= 1
103-
104-MANPAGE_gzipped = $(OUTPUTDIR)/nvidia-settings.1.gz
105-MANPAGE_not_gzipped = $(OUTPUTDIR)/nvidia-settings.1
106-ifeq ($(MANPAGE_GZIP),1)
107- MANPAGE = $(MANPAGE_gzipped)
108-else
109- MANPAGE = $(MANPAGE_not_gzipped)
110-endif
111-GEN_MANPAGE_OPTS = $(OUTPUTDIR)/gen-manpage-opts
112-OPTIONS_1_INC = $(OUTPUTDIR)/options.1.inc
113-
114-# Include all the source lists; dist-files.mk will define SRC
115-include dist-files.mk
116-
117-include $(XCONFIG_PARSER_DIR)/src.mk
118-SRC += $(addprefix $(XCONFIG_PARSER_DIR)/,$(XCONFIG_PARSER_SRC))
119-
120-include $(COMMON_UTILS_DIR)/src.mk
121-SRC += $(addprefix $(COMMON_UTILS_DIR)/,$(COMMON_UTILS_SRC))
122-
123-SRC += $(STAMP_C)
124-
125-OBJS = $(call BUILD_OBJECT_LIST,$(SRC))
126-
127-CFLAGS += -I src
128-CFLAGS += -I src/image_data
129-CFLAGS += -I $(XNVCTRL_DIR)
130-CFLAGS += -I $(XCONFIG_PARSER_DIR)/..
131-CFLAGS += -I src/libXNVCtrlAttributes
132-CFLAGS += -I src/xpm_data
133-CFLAGS += -I src/gtk+-2.x
134-CFLAGS += -I $(COMMON_UTILS_DIR)
135-CFLAGS += -I $(OUTPUTDIR)
136-CFLAGS += -DPROGRAM_NAME=\"nvidia-setttings\"
137-
138-$(call BUILD_OBJECT_LIST,$(GTK_SRC)): CFLAGS += $(GTK_CFLAGS)
139-
140-
141-##############################################################################
142-# build rules
143-##############################################################################
144-
145-.PNONY: all install NVIDIA_SETTINGS_install MANPAGE_install clean clobber
146-
147-all: $(NVIDIA_SETTINGS) $(MANPAGE)
148-
149-install: NVIDIA_SETTINGS_install MANPAGE_install
150-
151-NVIDIA_SETTINGS_install: $(NVIDIA_SETTINGS)
152- $(MKDIR) $(bindir)
153- $(INSTALL) $(INSTALL_BIN_ARGS) $< $(bindir)/$(notdir $<)
154-
155-MANPAGE_install: $(MANPAGE)
156- $(MKDIR) $(mandir)
157- $(INSTALL) $(INSTALL_BIN_ARGS) $< $(mandir)/$(notdir $<)
158-
159-$(NVIDIA_SETTINGS): $(OBJS) $(XNVCTRL_ARCHIVE)
160- $(call quiet_cmd,LINK) -o $@ $(OBJS) $(XNVCTRL_ARCHIVE) \
161- $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS)
162- $(call quiet_cmd,STRIP_CMD) $@
163-
164-# define the rule to build each object file
165-$(foreach src,$(SRC),$(eval $(call DEFINE_OBJECT_RULE,CC,$(src))))
166-
167-# define the rule to generate $(STAMP_C)
168-$(eval $(call DEFINE_STAMP_C_RULE, $(OBJS),$(NVIDIA_SETTINGS_PROGRAM_NAME)))
169-
170-clean clobber:
171- rm -rf $(NVIDIA_SETTINGS) $(MANPAGE) *~ $(STAMP_C) \
172- $(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d \
173- $(GEN_MANPAGE_OPTS) $(OPTIONS_1_INC)
174-
175-
176-##############################################################################
177-# Documentation
178-##############################################################################
179-
180-AUTO_TEXT = ".\\\" WARNING: THIS FILE IS AUTO-GENERATED! Edit $< instead."
181-
182-doc: $(MANPAGE)
183-
184-GEN_MANPAGE_OPTS_SRC = src/gen-manpage-opts.c
185-
186-BUILD_MANPAGE_OBJECT_LIST = \
187- $(patsubst %.o,%.manpage.o,$(call BUILD_OBJECT_LIST,$(1)))
188-
189-GEN_MANPAGE_OPTS_OBJS = \
190- $(call BUILD_MANPAGE_OBJECT_LIST,$(GEN_MANPAGE_OPTS_SRC))
191-
192-$(GEN_MANPAGE_OPTS): $(GEN_MANPAGE_OPTS_OBJS)
193- $(call quiet_cmd,HOST_LINK) $(GEN_MANPAGE_OPTS_OBJS) -o $@ \
194- $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_BIN_LDFLAGS)
195-
196-# define a rule to build each GEN_MANPAGE_OPTS object file
197-$(foreach src,$(GEN_MANPAGE_OPTS_SRC),\
198- $(eval $(call DEFINE_OBJECT_RULE_WITH_OBJECT_NAME,HOST_CC,$(src),\
199- $(call BUILD_MANPAGE_OBJECT_LIST,$(src)))))
200-
201-$(OPTIONS_1_INC): $(GEN_MANPAGE_OPTS)
202- @./$< > $@
203-
204-$(MANPAGE_not_gzipped): doc/nvidia-settings.1.m4 $(OPTIONS_1_INC)
205- $(call quiet_cmd,M4) \
206- -D__HEADER__=$(AUTO_TEXT) \
207- -D__BUILD_OS__=$(TARGET_OS) \
208- -D__VERSION__=$(NVIDIA_VERSION) \
209- -D__DATE__="`$(DATE) +%F`" \
210- -I $(OUTPUTDIR) \
211- $< > $@
212-
213-$(MANPAGE_gzipped): $(MANPAGE_not_gzipped)
214- $(GZIP_CMD) -9f < $< > $@
215+.PHONY: all clean clobber install
216+
217+all clean clobber install:
218+ @$(MAKE) -C src $@
219+ @$(MAKE) -C samples $@
220+ @$(MAKE) -C doc $@
221+
222
223=== modified file 'debian/changelog'
224--- debian/changelog 2012-03-30 14:23:10 +0000
225+++ debian/changelog 2012-07-30 04:30:25 +0000
226@@ -1,3 +1,26 @@
227+nvidia-settings (302.17-0ubuntu3) precise; urgency=low
228+
229+ * debian/control: Changed a typo in the package description; changed 'of' to 'for' (LP: #306178)
230+
231+ -- Donald Siuchninski <dsiuchninski@gmail.com> Sun, 29 Jul 2012 22:19:32 -0500
232+
233+nvidia-settings (302.17-0ubuntu2) quantal; urgency=low
234+
235+ * Rename build to build-arch and make build depend on build-arch.
236+
237+ -- Adam Conrad <adconrad@ubuntu.com> Mon, 02 Jul 2012 17:18:24 -0600
238+
239+nvidia-settings (302.17-0ubuntu1) quantal; urgency=low
240+
241+ * New upstream release.
242+ * Refresh 04_nvidia-settings_natty_ftbs.patch.
243+ * Drop 02_nvidia-settings-format-string.patch which
244+ is now upstream.
245+ * debian/rules:
246+ - Make sure to install the new sources correctly.
247+
248+ -- Alberto Milone <alberto.milone@canonical.com> Mon, 25 Jun 2012 16:31:12 +0200
249+
250 nvidia-settings (295.33-0ubuntu1) precise; urgency=low
251
252 * New upstream release.
253
254=== modified file 'debian/control'
255--- debian/control 2011-10-17 17:35:57 +0000
256+++ debian/control 2012-07-30 04:30:25 +0000
257@@ -15,7 +15,7 @@
258 Depends: python-gtk2, pkg-config, screen-resolution-extra (>= 0.12), ${shlibs:Depends}
259 Conflicts: libxnvctrl-dev
260 Replaces: libxnvctrl-dev
261-Description: Tool of configuring the NVIDIA graphics driver
262+Description: Tool for configuring the NVIDIA graphics driver
263 The nvidia-settings utility is a tool for configuring the NVIDIA
264 Linux graphics driver. It operates by communicating with the NVIDIA
265 X driver, querying and updating state as appropriate. This
266
267=== modified file 'debian/patches/04_nvidia-settings_natty_ftbs.patch'
268--- debian/patches/04_nvidia-settings_natty_ftbs.patch 2010-11-21 13:02:24 +0000
269+++ debian/patches/04_nvidia-settings_natty_ftbs.patch 2012-07-30 04:30:25 +0000
270@@ -1,8 +1,7 @@
271-diff --git a/Makefile b/Makefile
272-index 0b4d202..bb9781f 100644
273---- a/Makefile
274-+++ b/Makefile
275-@@ -53,7 +53,7 @@ ifndef GTK_CFLAGS
276+diff -Nurp nvidia-settings.orig/src/Makefile nvidia-settings/src/Makefile
277+--- nvidia-settings.orig/src/Makefile 2012-05-02 17:06:02.000000000 +0200
278++++ nvidia-settings/src/Makefile 2012-05-17 09:09:32.341638054 +0200
279+@@ -51,7 +51,7 @@ ifndef GTK_CFLAGS
280 endif
281
282 ifndef GTK_LDFLAGS
283
284=== modified file 'debian/patches/series'
285--- debian/patches/series 2011-08-04 17:43:17 +0000
286+++ debian/patches/series 2012-07-30 04:30:25 +0000
287@@ -1,4 +1,3 @@
288 01_allow_dark_themes.dpatch
289-02_nvidia-settings-format-string.patch
290 04_nvidia-settings_natty_ftbs.patch
291 05_add_polkit_support.patch
292
293=== modified file 'debian/rules'
294--- debian/rules 2011-08-05 14:19:18 +0000
295+++ debian/rules 2012-07-30 04:30:25 +0000
296@@ -58,12 +58,12 @@
297 debian/$$i.in > debian/$$i; \
298 done
299
300-
301-build: regen-from-templates
302+build: build-arch
303+build-arch: regen-from-templates
304 dh_quilt_patch
305
306 $(MAKE) -C src/libXNVCtrl EXTINCSRC=/usr/include/X11/extensions \
307- CFLAGS="$(CFLAGS) -fPIC"
308+ CFLAGS="$(CFLAGS) -fPIC" PREFIX=$(PKG_libdir)
309 $(MAKE)
310 dh build
311
312@@ -82,8 +82,8 @@
313 dh clean
314
315 binary-arch:
316- dh_auto_install -- prefix=$(CURDIR)/debian/$(PKG_name)$(PKG_libdir)
317- #$(MAKE) prefix=$(CURDIR)/debian/$(PKG_name)$(PKG_libdir) install
318+ #dh_auto_install -- prefix=$(CURDIR)/debian/$(PKG_name)$(PKG_libdir)
319+ $(MAKE) PREFIX=$(CURDIR)/debian/$(PKG_name)$(PKG_libdir) install
320 dh_install -p$(PKG_name) src/libXNVCtrl/libXNVCtrl.a "$(PKG_libdir)"
321 dh_install -p$(PKG_name) src/libXNVCtrl/NVCtrl.h "$(PKG_includedir)/NVCtrl"
322 dh_install -p$(PKG_name) src/libXNVCtrl/NVCtrlLib.h "$(PKG_includedir)/NVCtrl"
323@@ -109,5 +109,8 @@
324 mv $(CURDIR)/debian/$(PKG_name)$(PKG_libdir)/share/man/man1/nvidia-settings.1.gz \
325 $(CURDIR)/debian/$(PKG_name)$(PKG_libdir)/share/man/man1/alt-$(PKG_name).1.gz
326
327+override_dh_usrlocal:
328+ rm -Rf $(CURDIR)/debian/$(PKG_name)/usr/local
329+
330 %:
331 dh $@ --with quilt
332
333=== removed file 'dist-files.mk'
334--- dist-files.mk 2012-02-18 10:21:04 +0000
335+++ dist-files.mk 1970-01-01 00:00:00 +0000
336@@ -1,60 +0,0 @@
337-#
338-# nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
339-# and Linux systems.
340-#
341-# Copyright (C) 2008 NVIDIA Corporation.
342-#
343-# This program is free software; you can redistribute it and/or modify it
344-# under the terms and conditions of the GNU General Public License,
345-# version 2, as published by the Free Software Foundation.
346-#
347-# This program is distributed in the hope that it will be useful, but WITHOUT
348-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
349-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
350-# more details.
351-#
352-# You should have received a copy of the GNU General Public License
353-# along with this program. If not, see <http://www.gnu.org/licenses>.
354-#
355-
356-##############################################################################
357-# define the list of files that should be distributed in the
358-# nvidia-settings tarball; this is used by the NVIDIA driver build
359-# when packaging the tarball, and by the nvidia-settings makefile when
360-# building nvidia-settings.
361-#
362-# Defines SRC, EXTRA_DIST, and DIST_FILES
363-##############################################################################
364-
365-SRC :=
366-EXTRA_DIST := COPYING dist-files.mk
367-
368-include src/src.mk
369-SRC += $(addprefix src/,$(SRC_SRC))
370-EXTRA_DIST += $(addprefix src/,$(SRC_EXTRA_DIST))
371-
372-include src/image_data/src.mk
373-SRC += $(addprefix src/image_data/,$(IMAGE_DATA_SRC))
374-EXTRA_DIST += $(addprefix src/image_data/,$(IMAGE_DATA_EXTRA_DIST))
375-
376-include src/libXNVCtrlAttributes/src.mk
377-SRC += $(addprefix src/libXNVCtrlAttributes/,$(LIB_XNVCTRL_ATTRIBUTES_SRC))
378-EXTRA_DIST += $(addprefix src/libXNVCtrlAttributes/,$(LIB_XNVCTRL_ATTRIBUTES_EXTRA_DIST))
379-
380-include src/xpm_data/src.mk
381-SRC += $(addprefix src/xpm_data/,$(LIB_XPM_DATA_SRC))
382-EXTRA_DIST += $(addprefix src/xpm_data/,$(LIB_XPM_DATA_EXTRA_DIST))
383-
384-include src/gtk+-2.x/src.mk
385-SRC += $(addprefix src/gtk+-2.x/,$(GTK_SRC))
386-EXTRA_DIST += $(addprefix src/gtk+-2.x/,$(GTK_EXTRA_DIST))
387-
388-include doc/src.mk
389-SRC += $(addprefix doc/,$(DOC_SRC))
390-EXTRA_DIST += $(addprefix doc/,$(DOC_EXTRA_DIST))
391-
392-include samples/src.mk
393-SRC += $(addprefix samples/,$(SAMPLES_SRC))
394-EXTRA_DIST += $(addprefix samples/,$(SAMPLES_EXTRA_DIST))
395-
396-DIST_FILES := $(SRC) $(EXTRA_DIST)
397
398=== added file 'doc/Makefile'
399--- doc/Makefile 1970-01-01 00:00:00 +0000
400+++ doc/Makefile 2012-07-30 04:30:25 +0000
401@@ -0,0 +1,115 @@
402+#
403+# nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
404+# and Linux systems.
405+#
406+# Copyright (C) 2008-2012 NVIDIA Corporation.
407+#
408+# This program is free software; you can redistribute it and/or modify it
409+# under the terms and conditions of the GNU General Public License,
410+# version 2, as published by the Free Software Foundation.
411+#
412+# This program is distributed in the hope that it will be useful, but WITHOUT
413+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
414+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
415+# more details.
416+#
417+# You should have received a copy of the GNU General Public License
418+# along with this program. If not, see <http://www.gnu.org/licenses>.
419+#
420+
421+
422+##############################################################################
423+# include common variables and functions
424+##############################################################################
425+
426+UTILS_MK_DIR ?= ..
427+
428+include $(UTILS_MK_DIR)/utils.mk
429+
430+
431+##############################################################################
432+# The common-utils directory may be in one of two places: either
433+# elsewhere in the driver source tree when building nvidia-settings as
434+# part of the NVIDIA driver build (in which case, COMMON_UTILS_DIR
435+# should be defined by the calling makefile), or directly in the
436+# source directory when building from the nvidia-settings source
437+# tarball (in which case, the below conditional assignments should be
438+# used)
439+##############################################################################
440+
441+COMMON_UTILS_DIR ?= ../src/common-utils
442+
443+
444+##############################################################################
445+# assign variables
446+##############################################################################
447+
448+MANPAGE_GZIP ?= 1
449+
450+MANPAGE_gzipped = $(OUTPUTDIR)/nvidia-settings.1.gz
451+MANPAGE_not_gzipped = $(OUTPUTDIR)/nvidia-settings.1
452+ifeq ($(MANPAGE_GZIP),1)
453+ MANPAGE = $(MANPAGE_gzipped)
454+else
455+ MANPAGE = $(MANPAGE_not_gzipped)
456+endif
457+GEN_MANPAGE_OPTS = $(OUTPUTDIR)/gen-manpage-opts
458+OPTIONS_1_INC = $(OUTPUTDIR)/options.1.inc
459+
460+CFLAGS += -I $(COMMON_UTILS_DIR)
461+CFLAGS += -I ../src/libXNVCtrlAttributes
462+
463+
464+##############################################################################
465+# build rules
466+##############################################################################
467+
468+.PNONY: all install MANPAGE_install clean clobber
469+
470+all: $(MANPAGE)
471+
472+install: MANPAGE_install
473+
474+MANPAGE_install: $(MANPAGE)
475+ $(MKDIR) $(MANDIR)
476+ $(INSTALL) $(INSTALL_BIN_ARGS) $< $(MANDIR)/$(notdir $<)
477+
478+clean clobber:
479+ rm -rf $(MANPAGE) *~ $(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d \
480+ $(GEN_MANPAGE_OPTS) $(OPTIONS_1_INC)
481+
482+
483+##############################################################################
484+# Documentation
485+##############################################################################
486+
487+AUTO_TEXT = ".\\\" WARNING: THIS FILE IS AUTO-GENERATED! Edit $< instead."
488+
489+doc: $(MANPAGE)
490+
491+GEN_MANPAGE_OPTS_SRC = ../src/gen-manpage-opts.c
492+GEN_MANPAGE_OPTS_SRC += $(COMMON_UTILS_DIR)/gen-manpage-opts-helper.c
493+
494+GEN_MANPAGE_OPTS_OBJS = $(call BUILD_OBJECT_LIST,$(GEN_MANPAGE_OPTS_SRC))
495+
496+$(foreach src, $(GEN_MANPAGE_OPTS_SRC), \
497+ $(eval $(call DEFINE_OBJECT_RULE,HOST_CC,$(src))))
498+
499+$(GEN_MANPAGE_OPTS): $(GEN_MANPAGE_OPTS_OBJS)
500+ $(call quiet_cmd,HOST_LINK) \
501+ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_BIN_LDFLAGS) $^ -o $@
502+
503+$(OPTIONS_1_INC): $(GEN_MANPAGE_OPTS)
504+ @./$< > $@
505+
506+$(MANPAGE_not_gzipped): nvidia-settings.1.m4 $(OPTIONS_1_INC) $(VERSION_MK)
507+ $(call quiet_cmd,M4) \
508+ -D__HEADER__=$(AUTO_TEXT) \
509+ -D__BUILD_OS__=$(TARGET_OS) \
510+ -D__VERSION__=$(NVIDIA_VERSION) \
511+ -D__DATE__="`$(DATE) +%F`" \
512+ -I $(OUTPUTDIR) \
513+ $< > $@
514+
515+$(MANPAGE_gzipped): $(MANPAGE_not_gzipped)
516+ $(GZIP_CMD) -9f < $< > $@
517
518=== modified file 'doc/nvidia-settings.png'
519Binary files doc/nvidia-settings.png 2010-06-27 18:59:46 +0000 and doc/nvidia-settings.png 2012-07-30 04:30:25 +0000 differ
520=== modified file 'doc/src.mk'
521--- doc/src.mk 2010-06-27 18:59:46 +0000
522+++ doc/src.mk 2012-07-30 04:30:25 +0000
523@@ -10,3 +10,5 @@
524 DOC_EXTRA_DIST += nvidia-settings.desktop
525 DOC_EXTRA_DIST += nvidia-settings.png
526 DOC_EXTRA_DIST += src.mk
527+
528+DOC_DIST_FILES := $(DOC_SRC) $(DOC_EXTRA_DIST)
529\ No newline at end of file
530
531=== added file 'doc/version.mk'
532--- doc/version.mk 1970-01-01 00:00:00 +0000
533+++ doc/version.mk 2012-07-30 04:30:25 +0000
534@@ -0,0 +1,1 @@
535+NVIDIA_VERSION = 302.17
536
537=== modified file 'samples/Makefile'
538--- samples/Makefile 2012-02-18 10:21:04 +0000
539+++ samples/Makefile 2012-07-30 04:30:25 +0000
540@@ -55,7 +55,7 @@
541
542 LDFLAGS += $(X_LDFLAGS)
543 LDFLAGS += -L $(LIBXNVCTRL_DIR)
544-LDFLAGS += -lXNVCtrl -lXext -lX11
545+LIBS += -lXNVCtrl -lXext -lX11
546
547
548 ##############################################################################
549@@ -76,7 +76,7 @@
550 # build rules
551 ##############################################################################
552
553-.PHONY: all clean clobber
554+.PHONY: all clean clobber install
555
556 # define the rule to build each object file
557 $(foreach src, $(SAMPLE_SOURCES), $(eval $(call DEFINE_OBJECT_RULE,CC,$(src))))
558@@ -84,7 +84,7 @@
559 # define the rule to link each sample app from its corresponding object file
560 define link_sample_from_object
561 $$(OUTPUTDIR)/$(1:.c=): $$(call BUILD_OBJECT_LIST,$(1))
562- $$(call quiet_cmd,LINK) $$(CFLAGS) -o $$@ $$< $$(LDFLAGS) $$(BIN_LDFLAGS)
563+ $$(call quiet_cmd,LINK) $$(CFLAGS) $$(LDFLAGS) $$(BIN_LDFLAGS) -o $$@ $$< $$(LIBS)
564 all:: $$(OUTPUTDIR)/$(1:.c=)
565 SAMPLES += $$(OUTPUTDIR)/$(1:.c=)
566 endef
567@@ -93,3 +93,7 @@
568
569 clean clobber:
570 rm -rf *~ $(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d $(SAMPLES)
571+
572+install:
573+ @# don't install samples, this is just to satisfy the top-level
574+ @# recursion rule
575
576=== modified file 'samples/nv-control-dpy.c'
577--- samples/nv-control-dpy.c 2010-06-27 18:59:46 +0000
578+++ samples/nv-control-dpy.c 2012-07-30 04:30:25 +0000
579@@ -53,6 +53,28 @@
580
581
582
583+static void print_display_name(Display *dpy, int target_id, int attr,
584+ char *name)
585+{
586+ Bool ret;
587+ char *str;
588+
589+ ret = XNVCTRLQueryTargetStringAttribute(dpy,
590+ NV_CTRL_TARGET_TYPE_DISPLAY,
591+ target_id, 0,
592+ attr,
593+ &str);
594+ if (!ret) {
595+ printf(" %18s : N/A\n", name);
596+ return;
597+ }
598+
599+ printf(" %18s : %s\n", name, str);
600+ XFree(str);
601+}
602+
603+
604+
605
606 int main(int argc, char *argv[])
607 {
608@@ -363,8 +385,48 @@
609
610 XFree(str);
611 }
612-
613-
614+
615+
616+ /*
617+ * query the MetaModes for the X screen, using
618+ * NV_CTRL_BINARY_DATA_METAMODES_VERSION_2.
619+ */
620+
621+ else if (strcmp(argv[1], "--print-metamodes-version2") == 0) {
622+
623+ /* get list of metamodes */
624+
625+ ret = XNVCTRLQueryBinaryData(dpy, screen, 0, // n/a
626+ NV_CTRL_BINARY_DATA_METAMODES_VERSION_2,
627+ (void *) &str, &len);
628+
629+ if (!ret) {
630+ fprintf(stderr, "Failed to query MetaModes.\n\n");
631+ return 1;
632+ }
633+
634+ /*
635+ * the returned data is in the form:
636+ *
637+ * "MetaMode 1\0MetaMode 2\0MetaMode 3\0Last MetaMode\0\0"
638+ *
639+ * so walk from one "\0" to the next to print each MetaMode.
640+ */
641+
642+ printf("MetaModes:\n");
643+
644+ start = str;
645+ for (j = 0; j < len; j++) {
646+ if (str[j] == '\0') {
647+ printf(" %s\n", start);
648+ start = &str[j+1];
649+ }
650+ }
651+
652+ XFree(str);
653+ }
654+
655+
656 /*
657 * query the currently in use MetaMode. Note that an alternative
658 * way to accomplish this is to use XRandR to query the current
659@@ -387,8 +449,32 @@
660
661 XFree(str);
662 }
663-
664-
665+
666+
667+ /*
668+ * query the currently in use MetaMode. Note that an alternative
669+ * way to accomplish this is to use XRandR to query the current
670+ * mode's refresh rate, and then match the refresh rate to the id
671+ * reported in the returned NV_CTRL_BINARY_DATA_METAMODES_VERSION_2 data.
672+ */
673+
674+ else if (strcmp(argv[1], "--print-current-metamode-version2") == 0) {
675+
676+ ret = XNVCTRLQueryStringAttribute(dpy, screen, mask,
677+ NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2,
678+ &str);
679+
680+ if (!ret) {
681+ fprintf(stderr, "Failed to query the current MetaMode.\n\n");
682+ return 1;
683+ }
684+
685+ printf("current metamode: \"%s\"\n\n", str);
686+
687+ XFree(str);
688+ }
689+
690+
691 /*
692 * add the given MetaMode to X screen's list of MetaModes, using
693 * NV_CTRL_STRING_OPERATION_ADD_METAMODE; example MetaMode string:
694@@ -791,46 +877,45 @@
695
696
697 /*
698- * query the TwinViewXineramaInfoOrder
699+ * query the nvidiaXineramaInfoOrder
700 */
701
702- else if (strcmp(argv[1], "--query-twinview-xinerama-info-order") == 0) {
703+ else if (strcmp(argv[1], "--query-nvidia-xinerama-info-order") == 0) {
704
705 ret = XNVCTRLQueryTargetStringAttribute
706 (dpy, NV_CTRL_TARGET_TYPE_X_SCREEN, screen, 0,
707- NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER, &str);
708+ NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER, &str);
709
710 if (!ret) {
711- fprintf(stderr, "Failed to query "
712- "TwinViewXineramaInfoOrder.\n\n");
713+ fprintf(stderr, "Failed to query nvidiaXineramaInfoOrder.\n\n");
714 return 1;
715 }
716
717- printf("TwinViewXineramaInfoOrder: %s\n\n", str);
718+ printf("nvidiaXineramaInfoOrder: %s\n\n", str);
719 }
720
721
722 /*
723- * assign the TwinViewXineramaInfoOrder
724+ * assign the nvidiaXineramaInfoOrder
725 */
726
727- else if ((strcmp(argv[1], "--assign-twinview-xinerama-info-order")== 0)
728+ else if ((strcmp(argv[1], "--assign-nvidia-xinerama-info-order")== 0)
729 && argv[2]) {
730
731 ret = XNVCTRLSetStringAttribute
732 (dpy,
733 screen,
734 0,
735- NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER,
736+ NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER,
737 argv[2]);
738
739 if (!ret) {
740 fprintf(stderr, "Failed to assign "
741- "TwinViewXineramaInfoOrder = \"%s\".\n\n", argv[2]);
742+ "nvidiaXineramaInfoOrder = \"%s\".\n\n", argv[2]);
743 return 1;
744 }
745
746- printf("assigned TwinViewXineramaInfoOrder: \"%s\"\n\n",
747+ printf("assigned nvidiaXineramaInfoOrder: \"%s\"\n\n",
748 argv[2]);
749 }
750
751@@ -1163,7 +1248,54 @@
752 printf("The id of the new MetaMode is %d; use xrandr to "
753 "switch to it.\n\n", id);
754 }
755-
756+
757+
758+ /* Display all names each display device goes by
759+ */
760+ else if (strcmp(argv[1], "--print-display-names") == 0) {
761+ unsigned int *pData;
762+ int len, i;
763+
764+ printf("Display Device Information:\n");
765+
766+ ret = XNVCTRLQueryTargetBinaryData(dpy,
767+ NV_CTRL_TARGET_TYPE_GPU,
768+ 0,
769+ 0,
770+ NV_CTRL_BINARY_DATA_DISPLAY_TARGETS,
771+ (unsigned char **) &pData,
772+ &len);
773+ if (!ret) {
774+ fprintf(stderr, "Failed to query number of display devices.\n\n");
775+ return 1;
776+ }
777+
778+ printf(" number of display devices: %d\n", pData[0]);
779+
780+ for (i = 1; i <= pData[0]; i++) {
781+
782+ printf("\n Display Device: %d\n", pData[i]);
783+
784+ print_display_name(dpy, pData[i],
785+ NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME,
786+ "Type Basename");
787+ print_display_name(dpy, pData[i],
788+ NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID,
789+ "Type ID");
790+ print_display_name(dpy, pData[i],
791+ NV_CTRL_STRING_DISPLAY_NAME_DP_GUID,
792+ "DP GUID");
793+ print_display_name(dpy, pData[i],
794+ NV_CTRL_STRING_DISPLAY_NAME_EDID_HASH,
795+ "EDID HASH");
796+ print_display_name(dpy, pData[i],
797+ NV_CTRL_STRING_DISPLAY_NAME_TARGET_INDEX,
798+ "Target Index");
799+ print_display_name(dpy, pData[i],
800+ NV_CTRL_STRING_DISPLAY_NAME_RANDR,
801+ "RANDR");
802+ }
803+ }
804
805 /*
806 * print help information
807@@ -1204,6 +1336,9 @@
808 printf(" --print-metamodes: print the current MetaModes for the "
809 "X screen\n\n");
810
811+ printf(" --print-metamodes-version2: print the current MetaModes for "
812+ "the X screen with extended information\n\n");
813+
814 printf(" --add-metamode [metamode]: add the specified "
815 "MetaMode to the X screen's list of MetaModes.\n\n");
816
817@@ -1212,7 +1347,10 @@
818
819 printf(" --print-current-metamode: print the current MetaMode.\n\n");
820
821-
822+ printf(" --print-current-metamode-version2: print the current "
823+ "MetaMode with extended information.\n\n");
824+
825+
826 printf(" Misc options:\n\n");
827
828 printf(" --get-valid-freq-ranges: query the valid frequency "
829@@ -1232,11 +1370,11 @@
830
831 printf(" --probe-dpys: probe GPUs for new display devices\n\n");
832
833- printf(" --query-twinview-xinerama-info-order: query the "
834- "TwinViewXineramaInfoOrder.\n\n");
835+ printf(" --query-nvidia-xinerama-info-order: query the "
836+ "nvidiaXineramaInfoOrder.\n\n");
837
838- printf(" --assign-twinview-xinerama-info-order [order]: assign the "
839- "TwinViewXineramaInfoOrder.\n\n");
840+ printf(" --assign-nvidia-xinerama-info-order [order]: assign the "
841+ "nvidiaXineramaInfoOrder.\n\n");
842
843 printf(" --max-screen-size: query the maximum screen size "
844 "on all GPUs in the system\n\n");
845@@ -1246,6 +1384,9 @@
846
847 printf(" --dynamic-twinview: demonstrates the process of "
848 "dynamically transitioning into TwinView.\n\n");
849+
850+ printf(" --print-display-names: print all the names associated with "
851+ "each display device on the server\n\n");
852 }
853
854 return 0;
855
856=== modified file 'samples/nv-control-dvc.c'
857--- samples/nv-control-dvc.c 2010-06-27 18:59:46 +0000
858+++ samples/nv-control-dvc.c 2012-07-30 04:30:25 +0000
859@@ -52,7 +52,7 @@
860 * to the display device mask.
861 */
862
863-char *display_device_name(int mask)
864+static char *display_device_name(int mask)
865 {
866 switch (mask) {
867 case (1 << 0): return "CRT-0"; break;
868
869=== modified file 'samples/nv-control-events.c'
870--- samples/nv-control-events.c 2011-02-25 15:18:56 +0000
871+++ samples/nv-control-events.c 2012-07-30 04:30:25 +0000
872@@ -30,6 +30,7 @@
873 #include <stdlib.h>
874 #include <string.h>
875 #include <ctype.h>
876+#include <unistd.h>
877
878
879 #include <X11/Xlib.h>
880@@ -37,30 +38,119 @@
881 #include "NVCtrl.h"
882 #include "NVCtrlLib.h"
883
884+#define EVENT_TYPE_START TARGET_ATTRIBUTE_CHANGED_EVENT
885+#define EVENT_TYPE_END TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT
886+
887+
888 static const char *attr2str(int n);
889 static const char *target2str(int n);
890-
891-int main(void)
892+static const char *targetTypeAndId2Str(int targetType, int targetId);
893+
894+struct target_info {
895+ int type;
896+ int count;
897+ unsigned int *pIds; // If Non-NULL, is list of target ids.
898+};
899+
900+static void print_usage(char **argv)
901+{
902+ printf("Usage:\n");
903+ printf("%s [-d <dpy>] [-a] [-c] [-b] [-s]\n", argv[0]);
904+ printf("\n");
905+ printf("-d <dpy>: X server display to connect to\n");
906+ printf("-a: Listen for attribute availability events\n");
907+ printf("-c: Listen for attribute changed events\n");
908+ printf("-b: Listen for binary attribute changed events\n");
909+ printf("-s: Listen for string attribute changed events\n");
910+ printf("\n");
911+ printf("By default (i.e., if none of -a, -c, -b, or -s are requested),\n"
912+ "all event types are enabled.\n");
913+}
914+
915+int main(int argc, char **argv)
916 {
917 Display *dpy;
918 Bool ret;
919 int event_base, error_base;
920- int num_screens, num_gpus, num_framelocks, num_vcs, i;
921- int num_gvis, num_coolers, num_thermal_sensors;
922- int num_3d_vision_pro_transceivers;
923- int sources;
924- XEvent event;
925- XNVCtrlAttributeChangedEvent *nvevent;
926- XNVCtrlAttributeChangedEventTarget *nveventtarget;
927+ int i, j, k;
928+ int sources = 0;
929+ struct target_info info[] = {
930+ { .type = NV_CTRL_TARGET_TYPE_X_SCREEN },
931+ { .type = NV_CTRL_TARGET_TYPE_GPU },
932+ { .type = NV_CTRL_TARGET_TYPE_DISPLAY },
933+ { .type = NV_CTRL_TARGET_TYPE_FRAMELOCK },
934+ { .type = NV_CTRL_TARGET_TYPE_VCSC },
935+ { .type = NV_CTRL_TARGET_TYPE_GVI },
936+ { .type = NV_CTRL_TARGET_TYPE_COOLER },
937+ { .type = NV_CTRL_TARGET_TYPE_THERMAL_SENSOR },
938+ { .type = NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER },
939+ };
940+ static const int num_target_types = sizeof(info) / sizeof(*info);
941+
942+ int c;
943+ char *dpy_name = NULL;
944+ Bool anythingEnabled;
945+
946+#define EVENT_TYPE_ENTRY(_x) [_x] = { False, #_x }
947+
948+ struct {
949+ Bool enabled;
950+ char *description;
951+ } eventTypes[] = {
952+ EVENT_TYPE_ENTRY(TARGET_ATTRIBUTE_CHANGED_EVENT),
953+ EVENT_TYPE_ENTRY(TARGET_ATTRIBUTE_AVAILABILITY_CHANGED_EVENT),
954+ EVENT_TYPE_ENTRY(TARGET_STRING_ATTRIBUTE_CHANGED_EVENT),
955+ EVENT_TYPE_ENTRY(TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT),
956+ };
957+
958+ while ((c = getopt(argc, argv, "d:acbsh")) >= 0) {
959+ switch (c) {
960+ case 'd':
961+ dpy_name = optarg;
962+ break;
963+ case 'a':
964+ eventTypes[TARGET_ATTRIBUTE_AVAILABILITY_CHANGED_EVENT].enabled = True;
965+ break;
966+ case 'c':
967+ eventTypes[TARGET_ATTRIBUTE_CHANGED_EVENT].enabled = True;
968+ break;
969+ case 'b':
970+ eventTypes[TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT].enabled = True;
971+ break;
972+ case 's':
973+ eventTypes[TARGET_STRING_ATTRIBUTE_CHANGED_EVENT].enabled = True;
974+ break;
975+ case '?':
976+ fprintf(stderr, "%s: Unknown argument '%c'\n", argv[0], optopt);
977+ /* fallthrough */
978+ case 'h':
979+ print_usage(argv);
980+ return 1;
981+ }
982+ }
983+
984+ anythingEnabled = False;
985+ for (i = EVENT_TYPE_START; i <= EVENT_TYPE_END; i++) {
986+ if (eventTypes[i].enabled) {
987+ anythingEnabled = True;
988+ break;
989+ }
990+ }
991+
992+ if (!anythingEnabled) {
993+ for (i = EVENT_TYPE_START; i <= EVENT_TYPE_END; i++) {
994+ eventTypes[i].enabled = True;
995+ }
996+ }
997
998 /*
999 * Open a display connection, and make sure the NV-CONTROL X
1000 * extension is present on the screen we want to use.
1001 */
1002-
1003- dpy = XOpenDisplay(NULL);
1004+
1005+ dpy = XOpenDisplay(dpy_name);
1006 if (!dpy) {
1007- fprintf(stderr, "Cannot open display '%s'.\n", XDisplayName(NULL));
1008+ fprintf(stderr, "Cannot open display '%s'.\n", XDisplayName(dpy_name));
1009 return 1;
1010 }
1011
1012@@ -71,305 +161,119 @@
1013 ret = XNVCTRLQueryExtension(dpy, &event_base, &error_base);
1014 if (ret != True) {
1015 fprintf(stderr, "The NV-CONTROL X extension does not exist on '%s'.\n",
1016- XDisplayName(NULL));
1017- return 1;
1018- }
1019-
1020- /* Query number of X Screens */
1021-
1022- ret = XNVCTRLQueryTargetCount(dpy, NV_CTRL_TARGET_TYPE_X_SCREEN,
1023- &num_screens);
1024- if (ret != True) {
1025- fprintf(stderr, "Failed to query the number of X Screens on '%s'.\n",
1026- XDisplayName(NULL));
1027- return 1;
1028- }
1029-
1030- /* Query number of GPUs */
1031-
1032- ret = XNVCTRLQueryTargetCount(dpy, NV_CTRL_TARGET_TYPE_GPU,
1033- &num_gpus);
1034- if (ret != True) {
1035- fprintf(stderr, "Failed to query the number of GPUs on '%s'.\n",
1036- XDisplayName(NULL));
1037- return 1;
1038- }
1039-
1040- /* Query number of Frame Lock (G-Sync) devices */
1041-
1042- ret = XNVCTRLQueryTargetCount(dpy, NV_CTRL_TARGET_TYPE_FRAMELOCK,
1043- &num_framelocks);
1044- if (ret != True) {
1045- fprintf(stderr, "Failed to query the number of G-Sync devices on "
1046- "'%s'.\n",
1047- XDisplayName(NULL));
1048- return 1;
1049- }
1050-
1051- /* Query number of VCS (Visual Computing System) devices */
1052-
1053- ret = XNVCTRLQueryTargetCount(dpy, NV_CTRL_TARGET_TYPE_VCSC,
1054- &num_vcs);
1055- if (ret != True) {
1056- fprintf(stderr, "Failed to query the number of Visual Computing "
1057- "System devices on '%s'.\n",
1058- XDisplayName(NULL));
1059- return 1;
1060- }
1061-
1062- /* Query number of GVI (Graphics Video Input) devices */
1063-
1064- ret = XNVCTRLQueryTargetCount(dpy, NV_CTRL_TARGET_TYPE_GVI,
1065- &num_gvis);
1066- if (ret != True) {
1067- fprintf(stderr, "Failed to query the number of Graphics Video "
1068- "Input devices on '%s'.\n",
1069- XDisplayName(NULL));
1070- return 1;
1071- }
1072-
1073- /* Query number of Cooler devices */
1074-
1075- ret = XNVCTRLQueryTargetCount(dpy, NV_CTRL_TARGET_TYPE_COOLER,
1076- &num_coolers);
1077- if (ret != True) {
1078- fprintf(stderr, "Failed to query the number of Cooler devices "
1079- "on '%s'.\n",
1080- XDisplayName(NULL));
1081- return 1;
1082- }
1083-
1084- /* Query number of Thermal Sensor devices */
1085-
1086- ret = XNVCTRLQueryTargetCount(dpy, NV_CTRL_TARGET_TYPE_THERMAL_SENSOR,
1087- &num_thermal_sensors);
1088- if (ret != True) {
1089- fprintf(stderr, "Failed to query the number of Thermal Sensor "
1090- "devices on '%s'.\n",
1091- XDisplayName(NULL));
1092- return 1;
1093- }
1094-
1095- /* Query number of 3d Vision Pro Transceivers */
1096-
1097- ret = XNVCTRLQueryTargetCount(dpy, NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER,
1098- &num_3d_vision_pro_transceivers);
1099- if (ret != True) {
1100- fprintf(stderr, "Failed to query the number of 3D Vision Pro "
1101- "Transceiver devices on '%s'.\n",
1102- XDisplayName(NULL));
1103- return 1;
1104- }
1105-
1106- /*
1107- * register to receive NV-CONTROL events: whenever any NV-CONTROL
1108- * attribute is changed by an NV-CONTROL client, any other client
1109- * can receive notification of the change.
1110- */
1111-
1112- sources = 0;
1113-
1114- /*
1115- * - Register to receive ATTRIBUTE_CHANGE_EVENT events. These events
1116- * are specific to attributes set on X Screens.
1117- */
1118-
1119- printf("Registering to receive ATTRIBUTE_CHANGED_EVENT events...\n");
1120- fflush(stdout);
1121-
1122- for (i = 0; i < num_screens; i++ ) {
1123-
1124- /* Only register to receive events if this screen is controlled by
1125- * the NVIDIA driver.
1126- */
1127- if (!XNVCTRLIsNvScreen(dpy, i)) {
1128- printf("- The NV-CONTROL X not available on X screen "
1129- "%d of '%s'.\n", i, XDisplayName(NULL));
1130- continue;
1131- }
1132-
1133- ret = XNVCtrlSelectNotify(dpy, i, ATTRIBUTE_CHANGED_EVENT, True);
1134- if (ret != True) {
1135- printf("- Unable to register to receive NV-CONTROL events on '%s'."
1136- "\n", XDisplayName(NULL));
1137- continue;
1138- }
1139-
1140- printf("+ Listening to ATTRIBUTE_CHANGE_EVENTs on X screen %d.\n", i);
1141- sources++;
1142- }
1143- printf("\n");
1144-
1145- /*
1146- * - Register to receive TARGET_ATTRIBUTE_CHANGED_EVENT events. These
1147- * events are specific to attributes set on various devices and
1148- * structures controlled by the NVIDIA driver. Some possible targets
1149- * include X Screens, GPUs, and Frame Lock boards.
1150- */
1151-
1152- printf("Registering to receive TARGET_ATTRIBUTE_CHANGED_EVENT "
1153- "events...\n");
1154- fflush(stdout);
1155-
1156- /* Register to receive on all X Screen targets */
1157-
1158- for (i = 0; i < num_screens; i++ ) {
1159-
1160- /* Only register to receive events if this screen is controlled by
1161- * the NVIDIA driver.
1162- */
1163- if (!XNVCTRLIsNvScreen(dpy, i)) {
1164- printf("- The NV-CONTROL X not available on X screen "
1165- "%d of '%s'.\n", i, XDisplayName(NULL));
1166- continue;
1167- }
1168-
1169- ret = XNVCtrlSelectTargetNotify(dpy, NV_CTRL_TARGET_TYPE_X_SCREEN,
1170- i, TARGET_ATTRIBUTE_CHANGED_EVENT,
1171- True);
1172- if (ret != True) {
1173- printf("- Unable to register to receive NV-CONTROL "
1174- "target events for X screen %d on '%s'.\n",
1175- i, XDisplayName(NULL));
1176- continue;
1177- }
1178-
1179- printf("+ Listening to TARGET_ATTRIBUTE_CHANGE_EVENTs on X screen "
1180- "%d.\n", i);
1181- sources++;
1182- }
1183-
1184- /* Register to receive on all GPU targets */
1185-
1186- for (i = 0; i < num_gpus; i++ ) {
1187-
1188- ret = XNVCtrlSelectTargetNotify(dpy, NV_CTRL_TARGET_TYPE_GPU,
1189- i, TARGET_ATTRIBUTE_CHANGED_EVENT,
1190- True);
1191- if (ret != True) {
1192- printf("- Unable to register to receive NV-CONTROL "
1193- "target events for GPU %d on '%s'.\n",
1194- i, XDisplayName(NULL));
1195- continue;
1196- }
1197-
1198- printf("+ Listening to TARGET_ATTRIBUTE_CHANGE_EVENTs on GPU "
1199- "%d.\n", i);
1200- sources++;
1201- }
1202-
1203- /* Register to receive on all Frame Lock (G-Sync) targets */
1204-
1205- for (i = 0; i < num_framelocks; i++ ) {
1206-
1207- ret = XNVCtrlSelectTargetNotify(dpy, NV_CTRL_TARGET_TYPE_FRAMELOCK,
1208- i, TARGET_ATTRIBUTE_CHANGED_EVENT,
1209- True);
1210- if (ret != True) {
1211- printf("- Unable to register to receive NV-CONTROL "
1212- "target events for Frame Lock %d on '%s'.\n",
1213- i, XDisplayName(NULL));
1214- continue;
1215- }
1216-
1217- printf("+ Listening to TARGET_ATTRIBUTE_CHANGE_EVENTs on Frame Lock "
1218- "%d.\n", i);
1219- sources++;
1220- }
1221-
1222- /* Register to receive on all VCS targets */
1223-
1224- for (i = 0; i < num_vcs; i++ ) {
1225-
1226- ret = XNVCtrlSelectTargetNotify(dpy, NV_CTRL_TARGET_TYPE_VCSC,
1227- i, TARGET_ATTRIBUTE_CHANGED_EVENT,
1228- True);
1229- if (ret != True) {
1230- printf("- Unable to register to receive NV-CONTROL "
1231- "target events for VCS %d on '%s'.\n",
1232- i, XDisplayName(NULL));
1233- continue;
1234- }
1235-
1236- printf("+ Listening to TARGET_ATTRIBUTE_CHANGE_EVENTs on VCS "
1237- "%d.\n", i);
1238- sources++;
1239- }
1240-
1241- /* Register to receive on all GVI targets */
1242-
1243- for (i = 0; i < num_gvis; i++ ) {
1244-
1245- ret = XNVCtrlSelectTargetNotify(dpy, NV_CTRL_TARGET_TYPE_GVI,
1246- i, TARGET_ATTRIBUTE_CHANGED_EVENT,
1247- True);
1248- if (ret != True) {
1249- printf("- Unable to register to receive NV-CONTROL "
1250- "target events for GVI %d on '%s'.\n",
1251- i, XDisplayName(NULL));
1252- continue;
1253- }
1254-
1255- printf("+ Listening to TARGET_ATTRIBUTE_CHANGE_EVENTs on GVI "
1256- "%d.\n", i);
1257- sources++;
1258- }
1259-
1260- /* Register to receive on all Cooler targets */
1261-
1262- for (i = 0; i < num_coolers; i++ ) {
1263-
1264- ret = XNVCtrlSelectTargetNotify(dpy, NV_CTRL_TARGET_TYPE_COOLER,
1265- i, TARGET_ATTRIBUTE_CHANGED_EVENT,
1266- True);
1267- if (ret != True) {
1268- printf("- Unable to register to receive NV-CONTROL "
1269- "target events for Cooler %d on '%s'.\n",
1270- i, XDisplayName(NULL));
1271- continue;
1272- }
1273-
1274- printf("+ Listening to TARGET_ATTRIBUTE_CHANGE_EVENTs on Cooler "
1275- "%d.\n", i);
1276- sources++;
1277- }
1278-
1279- /* Register to receive on all Thermal Sensor targets */
1280-
1281- for (i = 0; i < num_thermal_sensors; i++ ) {
1282-
1283- ret = XNVCtrlSelectTargetNotify(dpy, NV_CTRL_TARGET_TYPE_THERMAL_SENSOR,
1284- i, TARGET_ATTRIBUTE_CHANGED_EVENT,
1285- True);
1286- if (ret != True) {
1287- printf("- Unable to register to receive NV-CONTROL "
1288- "target events for Thermal Sensor %d on '%s'.\n",
1289- i, XDisplayName(NULL));
1290- continue;
1291- }
1292-
1293- printf("+ Listening to TARGET_ATTRIBUTE_CHANGE_EVENTs on Thermal "
1294- "Sensor %d.\n", i);
1295- sources++;
1296- }
1297-
1298- /* Register to receive on all 3D Vision Pro Transceiver targets */
1299-
1300- for (i = 0; i < num_3d_vision_pro_transceivers; i++ ) {
1301-
1302- ret = XNVCtrlSelectTargetNotify(dpy, NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER,
1303- i, TARGET_ATTRIBUTE_CHANGED_EVENT,
1304- True);
1305- if (ret != True) {
1306- printf("- Unable to register to receive NV-CONTROL "
1307- "target events for 3D Vision Pro Transceiver %d on '%s'.\n",
1308- i, XDisplayName(NULL));
1309- continue;
1310- }
1311-
1312- printf("+ Listening to TARGET_ATTRIBUTE_CHANGE_EVENTs on 3d Vision "
1313- "Pro Transceiver %d.\n", i);
1314- sources++;
1315+ XDisplayName(dpy_name));
1316+ return 1;
1317+ }
1318+
1319+ /* Query target counts */
1320+ for (i = 0; i < num_target_types; i++) {
1321+
1322+ struct target_info *tinfo = &info[i];
1323+
1324+
1325+ if (tinfo->type == NV_CTRL_TARGET_TYPE_DISPLAY) {
1326+ ret = XNVCTRLQueryTargetBinaryData(dpy, NV_CTRL_TARGET_TYPE_X_SCREEN,
1327+ 0, 0,
1328+ NV_CTRL_BINARY_DATA_DISPLAY_TARGETS,
1329+ (unsigned char **)&(tinfo->pIds),
1330+ &(tinfo->count));
1331+ if (ret != True) {
1332+ fprintf(stderr, "Failed to query %s target count on '%s'.\n",
1333+ target2str(tinfo->type), XDisplayName(dpy_name));
1334+ return 1;
1335+ }
1336+ tinfo->count = tinfo->pIds[0];
1337+ } else {
1338+ ret = XNVCTRLQueryTargetCount(dpy, tinfo->type, &tinfo->count);
1339+ if (ret != True) {
1340+ fprintf(stderr, "Failed to query %s target count on '%s'.\n",
1341+ target2str(tinfo->type), XDisplayName(dpy_name));
1342+ return 1;
1343+ }
1344+ }
1345+ }
1346+
1347+ printf("Registering to receive events...\n");
1348+ fflush(stdout);
1349+
1350+ /* Register to receive events on all targets */
1351+
1352+ for (i = 0; i < num_target_types; i++) {
1353+ struct target_info *tinfo = &info[i];
1354+
1355+ for (j = 0; j < tinfo->count; j++) {
1356+ int target_id;
1357+
1358+ if (tinfo->pIds) {
1359+ target_id = tinfo->pIds[1+j];
1360+ } else {
1361+ target_id = j;
1362+ }
1363+
1364+ for (k = EVENT_TYPE_START; k <= EVENT_TYPE_END; k++) {
1365+ if (!eventTypes[k].enabled) {
1366+ continue;
1367+ }
1368+
1369+ if ((k == TARGET_ATTRIBUTE_CHANGED_EVENT) &&
1370+ (tinfo->type == NV_CTRL_TARGET_TYPE_X_SCREEN)) {
1371+
1372+ /*
1373+ * Only register to receive events if this screen is
1374+ * controlled by the NVIDIA driver.
1375+ */
1376+ if (!XNVCTRLIsNvScreen(dpy, target_id)) {
1377+ printf("- The NV-CONTROL X not available on X screen "
1378+ "%d of '%s'.\n", i, XDisplayName(dpy_name));
1379+ continue;
1380+ }
1381+
1382+ /*
1383+ * - Register to receive ATTRIBUTE_CHANGE_EVENT events.
1384+ * These events are specific to attributes set on X
1385+ * Screens.
1386+ */
1387+
1388+
1389+ ret = XNVCtrlSelectNotify(dpy, target_id, ATTRIBUTE_CHANGED_EVENT,
1390+ True);
1391+ if (ret != True) {
1392+ printf("- Unable to register to receive NV-CONTROL"
1393+ "events on '%s'.\n", XDisplayName(dpy_name));
1394+ continue;
1395+ }
1396+
1397+ printf("+ Listening on X screen %d for "
1398+ "ATTRIBUTE_CHANGED_EVENTs.\n", target_id);
1399+ sources++;
1400+ }
1401+
1402+ /*
1403+ * - Register to receive TARGET_ATTRIBUTE_CHANGED_EVENT events.
1404+ * These events are specific to attributes set on various
1405+ * devices and structures controlled by the NVIDIA driver.
1406+ * Some possible targets include X Screens, GPUs, and Frame
1407+ * Lock boards.
1408+ */
1409+
1410+ ret = XNVCtrlSelectTargetNotify(dpy,
1411+ tinfo->type, /* target type */
1412+ target_id, /* target ID */
1413+ k, /* eventType */
1414+ True);
1415+ if (ret != True) {
1416+ printf("- Unable to register on %s %d for %ss.\n",
1417+ target2str(tinfo->type), target_id,
1418+ eventTypes[k].description);
1419+ continue;
1420+ }
1421+
1422+ printf("+ Listening on %s %d for %ss.\n",
1423+ target2str(tinfo->type), target_id, eventTypes[k].description);
1424+
1425+ sources++;
1426+ }
1427+ }
1428 }
1429
1430 /*
1431@@ -386,31 +290,25 @@
1432 */
1433
1434 while (True) {
1435- char target_str[256];
1436+ XEvent event;
1437+ const char *target_str;
1438
1439 /* block for the next event */
1440
1441 XNextEvent(dpy, &event);
1442
1443- /* if this is not one of our events, then bail out of this iteration */
1444-
1445- if ((event.type != (event_base + ATTRIBUTE_CHANGED_EVENT)) &&
1446- (event.type != (event_base + TARGET_ATTRIBUTE_CHANGED_EVENT)))
1447- continue;
1448-
1449 /* Handle ATTRIBUTE_CHANGED_EVENTS */
1450 if (event.type == (event_base + ATTRIBUTE_CHANGED_EVENT)) {
1451
1452 /* cast the X event as an XNVCtrlAttributeChangedEvent */
1453-
1454- nvevent = (XNVCtrlAttributeChangedEvent *) &event;
1455-
1456+ XNVCtrlAttributeChangedEvent *nvevent =
1457+ (XNVCtrlAttributeChangedEvent *) &event;
1458+
1459+ target_str = targetTypeAndId2Str(NV_CTRL_TARGET_TYPE_X_SCREEN,
1460+ nvevent->screen);
1461+
1462 /* print out the event information */
1463- snprintf(target_str, 256, "%s-%-3d",
1464- target2str(NV_CTRL_TARGET_TYPE_X_SCREEN),
1465- nvevent->screen);
1466-
1467- printf("ATTRIBUTE_CHANGED_EVENTS: Target: %15s "
1468+ printf("ATTRIBUTE_CHANGED_EVENTS: Target: %15s "
1469 "Display Mask: 0x%08x "
1470 "Attribute: (%3d) %-32s Value: %d (0x%08x)\n",
1471 target_str,
1472@@ -424,16 +322,16 @@
1473 /* Handle TARGET_ATTRIBUTE_CHANGED_EVENTS */
1474 } else if (event.type ==
1475 (event_base + TARGET_ATTRIBUTE_CHANGED_EVENT)) {
1476+
1477 /* cast the X event as an XNVCtrlAttributeChangedEventTarget */
1478-
1479- nveventtarget = (XNVCtrlAttributeChangedEventTarget *) &event;
1480-
1481+ XNVCtrlAttributeChangedEventTarget *nveventtarget =
1482+ (XNVCtrlAttributeChangedEventTarget *) &event;
1483+
1484+ target_str = targetTypeAndId2Str(nveventtarget->target_type,
1485+ nveventtarget->target_id);
1486+
1487 /* print out the event information */
1488- snprintf(target_str, 256, "%s-%-3d",
1489- target2str(nveventtarget->target_type),
1490- nveventtarget->target_id);
1491-
1492- printf("TARGET_ATTRIBUTE_CHANGED_EVENTS: Target: %15s "
1493+ printf("TARGET_ATTRIBUTE_CHANGED_EVENT: Target: %15s "
1494 "Display Mask: 0x%08x "
1495 "Attribute: (%3d) %-32s Value: %d (0x%08x)\n",
1496 target_str,
1497@@ -443,6 +341,66 @@
1498 nveventtarget->value,
1499 nveventtarget->value
1500 );
1501+
1502+ /* Handle TARGET_ATTRIBUTE_AVAILABILITY_CHANGED_EVENTS */
1503+ } else if (event.type ==
1504+ (event_base + TARGET_ATTRIBUTE_AVAILABILITY_CHANGED_EVENT)) {
1505+
1506+ /* cast the X event as an XNVCtrlAttributeChangedEventTargetAvailability */
1507+ XNVCtrlAttributeChangedEventTargetAvailability *nveventavail =
1508+ (XNVCtrlAttributeChangedEventTargetAvailability *) &event;
1509+
1510+ target_str = targetTypeAndId2Str(nveventavail->target_type,
1511+ nveventavail->target_id);
1512+
1513+ /* print out the event information */
1514+ printf("TARGET_ATTRIBUTE_AVAILABILITY_CHANGED_EVENT: Target: %15s "
1515+ "Display Mask: 0x%08x "
1516+ "Attribute: (%3d) %-32s Available: %s\n",
1517+ target_str,
1518+ nveventavail->display_mask,
1519+ nveventavail->attribute,
1520+ attr2str(nveventavail->attribute),
1521+ nveventavail->availability ? "Yes" : "No"
1522+ );
1523+ } else if (event.type ==
1524+ (event_base + TARGET_STRING_ATTRIBUTE_CHANGED_EVENT)) {
1525+
1526+ XNVCtrlStringAttributeChangedEventTarget *nveventstring =
1527+ (XNVCtrlStringAttributeChangedEventTarget*) &event;
1528+
1529+ target_str = targetTypeAndId2Str(nveventstring->target_type,
1530+ nveventstring->target_id);
1531+
1532+ /* print out the event information */
1533+ printf("TARGET_STRING_ATTRIBUTE_CHANGED_EVENT: Target: %15s "
1534+ "Display Mask: 0x%08x "
1535+ "Attribute: %3d\n",
1536+ target_str,
1537+ nveventstring->display_mask,
1538+ nveventstring->attribute
1539+ );
1540+
1541+ } else if (event.type ==
1542+ (event_base + TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT)) {
1543+
1544+ XNVCtrlBinaryAttributeChangedEventTarget *nveventbinary =
1545+ (XNVCtrlBinaryAttributeChangedEventTarget *) &event;
1546+
1547+ target_str = targetTypeAndId2Str(nveventbinary->target_type,
1548+ nveventbinary->target_id);
1549+
1550+ /* print out the event information */
1551+ printf("TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT: Target: %15s "
1552+ "Display Mask: 0x%08x "
1553+ "Attribute: %3d\n",
1554+ target_str,
1555+ nveventbinary->display_mask,
1556+ nveventbinary->attribute
1557+ );
1558+
1559+ } else {
1560+ printf("ERROR: unrecognized event type %d\n", event.type);
1561 }
1562 }
1563
1564@@ -463,6 +421,8 @@
1565 return "X Screen";
1566 case NV_CTRL_TARGET_TYPE_GPU:
1567 return "GPU";
1568+ case NV_CTRL_TARGET_TYPE_DISPLAY:
1569+ return "Display";
1570 case NV_CTRL_TARGET_TYPE_FRAMELOCK:
1571 return "Frame Lock";
1572 case NV_CTRL_TARGET_TYPE_VCSC:
1573@@ -481,6 +441,15 @@
1574 }
1575 }
1576
1577+static const char *targetTypeAndId2Str(int targetType, int targetId)
1578+{
1579+ static char tmp[256];
1580+
1581+ snprintf(tmp, sizeof(tmp), "%s-%-3d", target2str(targetType), targetId);
1582+
1583+ return tmp;
1584+}
1585+
1586
1587 // Used to convert the NV-CONTROL #defines to human readable text.
1588 #define MAKE_ENTRY(ATTRIBUTE) { ATTRIBUTE, #ATTRIBUTE, NULL }
1589@@ -590,7 +559,6 @@
1590 MAKE_ENTRY(NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT),
1591 MAKE_ENTRY(NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT),
1592 MAKE_ENTRY(NV_CTRL_GVO_DATA_FORMAT),
1593- MAKE_ENTRY(NV_CTRL_GVO_DISPLAY_X_SCREEN),
1594 MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED),
1595 MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE),
1596 MAKE_ENTRY(NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED),
1597@@ -603,8 +571,6 @@
1598 MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH),
1599 MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_HEIGHT),
1600 MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE),
1601- MAKE_ENTRY(NV_CTRL_GVO_X_SCREEN_PAN_X),
1602- MAKE_ENTRY(NV_CTRL_GVO_X_SCREEN_PAN_Y),
1603 MAKE_ENTRY(NV_CTRL_GPU_OVERCLOCKING_STATE),
1604 MAKE_ENTRY(NV_CTRL_GPU_2D_CLOCK_FREQS),
1605 MAKE_ENTRY(NV_CTRL_GPU_3D_CLOCK_FREQS),
1606
1607=== modified file 'samples/nv-control-gvi.c'
1608--- samples/nv-control-gvi.c 2010-09-29 11:46:29 +0000
1609+++ samples/nv-control-gvi.c 2012-07-30 04:30:25 +0000
1610@@ -46,24 +46,10 @@
1611
1612
1613 /*
1614- * Decode SDI input value returned.
1615- */
1616-char *SyncTypeName(int value)
1617-{
1618- switch (value) {
1619- ADD_NVCTRL_CASE(NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_HD);
1620- ADD_NVCTRL_CASE(NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_SD);
1621- ADD_NVCTRL_CASE(NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_NONE);
1622- default:
1623- return "Invalid Value";
1624- }
1625-}
1626-
1627-/*
1628 * Decode provided signal format.
1629 */
1630
1631-char *VideoFormatName(int value)
1632+static char *VideoFormatName(int value)
1633 {
1634 switch(value) {
1635 ADD_NVCTRL_CASE(NV_CTRL_GVIO_VIDEO_FORMAT_NONE);
1636@@ -136,7 +122,7 @@
1637 }
1638 }
1639
1640-const char *SamplingName(int value)
1641+static const char *SamplingName(int value)
1642 {
1643 switch (value) {
1644 default:
1645@@ -150,7 +136,7 @@
1646 }
1647 }
1648
1649-const char *BPCName(int value)
1650+static const char *BPCName(int value)
1651 {
1652 switch (value) {
1653 ADD_NVCTRL_CASE(NV_CTRL_GVI_BITS_PER_COMPONENT_UNKNOWN);
1654@@ -349,9 +335,10 @@
1655 printf(" - Jack %d\n", jack);
1656
1657 for (channel = 0; channel < max_channels_per_jack; channel++) {
1658+ unsigned int link_definition = ((channel & 0xFFFF)<<16);
1659+
1660 printf(" - Channel %d\n", channel);
1661
1662- unsigned int link_definition = ((channel & 0xFFFF)<<16);
1663 link_definition |= (jack & 0xFFFF);
1664
1665 ret = XNVCTRLQueryTargetAttribute(dpy,
1666@@ -571,13 +558,13 @@
1667
1668
1669
1670-unsigned int firstbit (unsigned int mask)
1671+static unsigned int firstbit (unsigned int mask)
1672 {
1673 return mask ^ ((mask - 1) & mask);
1674 }
1675
1676 // List the configuration space of the GVI device.
1677-void do_listconfig(Display *dpy, int gvi)
1678+static void do_listconfig(Display *dpy, int gvi)
1679 {
1680 NVCTRLAttributeValidValuesRec values;
1681
1682@@ -770,7 +757,7 @@
1683
1684
1685
1686-void do_configure(Display *dpy, int use_gvi, char *pIn)
1687+static void do_configure(Display *dpy, int use_gvi, char *pIn)
1688 {
1689 Bool ret;
1690 char *pOut = NULL;
1691
1692=== modified file 'samples/nv-control-info.c'
1693--- samples/nv-control-info.c 2011-02-25 15:18:56 +0000
1694+++ samples/nv-control-info.c 2012-07-30 04:30:25 +0000
1695@@ -142,7 +142,6 @@
1696 MAKE_ENTRY(NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT),
1697 MAKE_ENTRY(NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT),
1698 MAKE_ENTRY(NV_CTRL_GVO_DATA_FORMAT),
1699- MAKE_ENTRY(NV_CTRL_GVO_DISPLAY_X_SCREEN),
1700 MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED),
1701 MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE),
1702 MAKE_ENTRY(NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED),
1703@@ -155,8 +154,6 @@
1704 MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH),
1705 MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_HEIGHT),
1706 MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE),
1707- MAKE_ENTRY(NV_CTRL_GVO_X_SCREEN_PAN_X),
1708- MAKE_ENTRY(NV_CTRL_GVO_X_SCREEN_PAN_Y),
1709 MAKE_ENTRY(NV_CTRL_GPU_OVERCLOCKING_STATE),
1710 MAKE_ENTRY(NV_CTRL_GPU_2D_CLOCK_FREQS),
1711 MAKE_ENTRY(NV_CTRL_GPU_3D_CLOCK_FREQS),
1712@@ -353,7 +350,7 @@
1713 MAKE_ENTRY(NV_CTRL_STRING_VALID_HORIZ_SYNC_RANGES),
1714 MAKE_ENTRY(NV_CTRL_STRING_VALID_VERT_REFRESH_RANGES),
1715 MAKE_ENTRY(NV_CTRL_STRING_XINERAMA_SCREEN_INFO),
1716- MAKE_ENTRY(NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER),
1717+ MAKE_ENTRY(NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER),
1718 MAKE_ENTRY(NV_CTRL_STRING_SLI_MODE),
1719 MAKE_ENTRY(NV_CTRL_STRING_PERFORMANCE_MODES),
1720 MAKE_ENTRY(NV_CTRL_STRING_VCSC_FAN_STATUS),
1721@@ -372,13 +369,20 @@
1722 MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_DATE_A),
1723 MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_GLASSES_ADDRESS),
1724 MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME),
1725+ MAKE_ENTRY(NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2),
1726+ MAKE_ENTRY(NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME),
1727+ MAKE_ENTRY(NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID),
1728+ MAKE_ENTRY(NV_CTRL_STRING_DISPLAY_NAME_DP_GUID),
1729+ MAKE_ENTRY(NV_CTRL_STRING_DISPLAY_NAME_EDID_HASH),
1730+ MAKE_ENTRY(NV_CTRL_STRING_DISPLAY_NAME_TARGET_INDEX),
1731+ MAKE_ENTRY(NV_CTRL_STRING_DISPLAY_NAME_RANDR),
1732 { -1, NULL, NULL }
1733 };
1734
1735 static AttrEntry attr_bin_table[] = {
1736 MAKE_ENTRY(NV_CTRL_BINARY_DATA_EDID),
1737 MAKE_ENTRY(NV_CTRL_BINARY_DATA_MODELINES),
1738- MAKE_ENTRY(NV_CTRL_BINARY_DATA_METAMODES),
1739+ MAKE_ENTRY(NV_CTRL_BINARY_DATA_METAMODES_VERSION_1),
1740 MAKE_ENTRY(NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU),
1741 MAKE_ENTRY(NV_CTRL_BINARY_DATA_GPUS_USED_BY_XSCREEN),
1742 MAKE_ENTRY(NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK),
1743@@ -390,6 +394,9 @@
1744 MAKE_ENTRY(NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN),
1745 MAKE_ENTRY(NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU),
1746 MAKE_ENTRY(NV_CTRL_BINARY_DATA_GLASSES_PAIRED_TO_3D_VISION_PRO_TRANSCEIVER),
1747+ MAKE_ENTRY(NV_CTRL_BINARY_DATA_DISPLAY_TARGETS),
1748+ MAKE_ENTRY(NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU),
1749+ MAKE_ENTRY(NV_CTRL_BINARY_DATA_METAMODES_VERSION_2),
1750 { -1, NULL, NULL }
1751 };
1752
1753@@ -404,7 +411,7 @@
1754 };
1755
1756
1757-void print_perms(NVCTRLAttributePermissionsRec *perms)
1758+static void print_perms(NVCTRLAttributePermissionsRec *perms)
1759 {
1760 printf("%c", (perms->permissions & ATTRIBUTE_TYPE_READ) ? 'R' : '_');
1761 printf("%c", (perms->permissions & ATTRIBUTE_TYPE_WRITE) ? 'W' : '_');
1762@@ -426,7 +433,7 @@
1763 case (FMT): \
1764 return #FMT;
1765
1766-const char *GetAttrTypeName(value)
1767+static const char *GetAttrTypeName(int value)
1768 {
1769 switch (value) {
1770 ADD_NVCTRL_CASE(ATTRIBUTE_TYPE_UNKNOWN);
1771
1772=== modified file 'samples/nv-control-targets.c'
1773--- samples/nv-control-targets.c 2010-06-27 18:59:46 +0000
1774+++ samples/nv-control-targets.c 2012-07-30 04:30:25 +0000
1775@@ -46,7 +46,7 @@
1776 * to the display device mask.
1777 */
1778
1779-char *display_device_name(int mask)
1780+static char *display_device_name(int mask)
1781 {
1782 switch (mask) {
1783 case (1 << 0): return "CRT-0"; break;
1784
1785=== modified file 'samples/src.mk'
1786--- samples/src.mk 2012-02-18 10:21:04 +0000
1787+++ samples/src.mk 2012-07-30 04:30:25 +0000
1788@@ -15,3 +15,5 @@
1789 SAMPLES_EXTRA_DIST += nv-control-framelock.c
1790 SAMPLES_EXTRA_DIST += nv-control-screen.h
1791 SAMPLES_EXTRA_DIST += src.mk
1792+
1793+SAMPLES_DIST_FILES := $(SAMPLES_SRC) $(SAMPLES_EXTRA_DIST)
1794\ No newline at end of file
1795
1796=== added file 'samples/version.mk'
1797--- samples/version.mk 1970-01-01 00:00:00 +0000
1798+++ samples/version.mk 2012-07-30 04:30:25 +0000
1799@@ -0,0 +1,1 @@
1800+NVIDIA_VERSION = 302.17
1801
1802=== added file 'src/Makefile'
1803--- src/Makefile 1970-01-01 00:00:00 +0000
1804+++ src/Makefile 2012-07-30 04:30:25 +0000
1805@@ -0,0 +1,174 @@
1806+#
1807+# nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
1808+# and Linux systems.
1809+#
1810+# Copyright (C) 2008-2012 NVIDIA Corporation.
1811+#
1812+# This program is free software; you can redistribute it and/or modify it
1813+# under the terms and conditions of the GNU General Public License,
1814+# version 2, as published by the Free Software Foundation.
1815+#
1816+# This program is distributed in the hope that it will be useful, but WITHOUT
1817+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1818+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
1819+# more details.
1820+#
1821+# You should have received a copy of the GNU General Public License
1822+# along with this program. If not, see <http://www.gnu.org/licenses>.
1823+#
1824+
1825+
1826+##############################################################################
1827+# include common variables and functions
1828+##############################################################################
1829+
1830+UTILS_MK_DIR ?= ..
1831+
1832+include $(UTILS_MK_DIR)/utils.mk
1833+
1834+
1835+##############################################################################
1836+# The calling Makefile may export any of the following variables; we
1837+# assign default values if they are not exported by the caller
1838+##############################################################################
1839+
1840+ifndef X_LDFLAGS
1841+ ifeq ($(TARGET_OS)-$(TARGET_ARCH),Linux-x86_64)
1842+ X_LDFLAGS = -L/usr/X11R6/lib64
1843+ else
1844+ X_LDFLAGS = -L/usr/X11R6/lib
1845+ endif
1846+endif
1847+
1848+X_CFLAGS ?=
1849+
1850+GL_INCLUDE_PATH ?= /usr/include
1851+
1852+PKG_CONFIG ?= pkg-config
1853+
1854+ifndef GTK_CFLAGS
1855+ GTK_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-2.0)
1856+endif
1857+
1858+ifndef GTK_LDFLAGS
1859+ GTK_LDFLAGS := $(shell $(PKG_CONFIG) --libs gtk+-2.0)
1860+endif
1861+
1862+
1863+##############################################################################
1864+# The XF86Config-parser, libXNVCtrl, and common-utils directories may
1865+# be in one of two places: either elsewhere in the driver source tree
1866+# when building nvidia-settings as part of the NVIDIA driver build (in
1867+# which case, XNVCTRL_DIR, XNVCTRL_ARCHIVE, XCONFIG_PARSER_DIR and
1868+# COMMON_UTILS_DIR should be defined by the calling makefile), or
1869+# directly in the source directory when building from the
1870+# nvidia-settings source tarball (in which case, the below conditional
1871+# assignments should be used)
1872+##############################################################################
1873+
1874+XNVCTRL_DIR ?= libXNVCtrl
1875+XNVCTRL_ARCHIVE ?= $(XNVCTRL_DIR)/libXNVCtrl.a
1876+XCONFIG_PARSER_DIR ?= XF86Config-parser
1877+COMMON_UTILS_DIR ?= common-utils
1878+
1879+##############################################################################
1880+# assign variables
1881+##############################################################################
1882+
1883+NVIDIA_SETTINGS = $(OUTPUTDIR)/nvidia-settings
1884+
1885+NVIDIA_SETTINGS_PROGRAM_NAME = "nvidia-settings"
1886+
1887+NVIDIA_SETTINGS_VERSION := $(NVIDIA_VERSION)
1888+
1889+CFLAGS += $(X_CFLAGS)
1890+
1891+ifeq ($(TARGET_OS),SunOS)
1892+ LDFLAGS += -Wl,-rpath=/usr/X11R6/lib
1893+endif
1894+
1895+LDFLAGS += $(X_LDFLAGS)
1896+
1897+# Some older Linux distributions do not have the dynamic library
1898+# libXxf86vm.so, though some newer Linux distributions do not have the
1899+# static library libXxf86vm.a. Statically link against libXxf86vm
1900+# when building nvidia-settings within the NVIDIA driver build, but
1901+# dynamically link against libXxf86vm in the public builds.
1902+ifdef NV_LINK_LIBXXF86VM_STATICALLY
1903+ LIBS += -Wl,-Bstatic -lXxf86vm -Wl,-Bdynamic
1904+else
1905+ LIBS += -lXxf86vm
1906+endif
1907+
1908+# Preferably, we would use pkg-config's "--libs-only-l" and
1909+# "--libs-only-L" options to get separate GTK_LDFLAGS and GTK_LIBS,
1910+# appending them to LDFLAGS and LIBS, respectively. However, the
1911+# pkg-config(1) man page cautions:
1912+#
1913+# [...] Note that the union of "--libs-only-l" and
1914+# "--libs-only-L" may be smaller than "--libs", due to flags such
1915+# as -rdynamic.
1916+#
1917+# So append all of GTK_LDFLAGS to LIBS, so that LIBS can go after
1918+# $(OBJECTS) on the link commandline, causing libraries for linking to
1919+# be named after the objects that depend on those libraries (needed
1920+# for "--as-needed" linker behavior).
1921+LIBS += -lX11 -lXext -lm $(LIBDL_LIBS) $(GTK_LDFLAGS)
1922+
1923+# Include all the source lists; dist-files.mk will define NVIDIA_SETTINGS_SRC
1924+include src.mk
1925+SRC += $(NVIDIA_SETTINGS_SRC)
1926+
1927+include $(XCONFIG_PARSER_DIR)/src.mk
1928+SRC += $(addprefix $(XCONFIG_PARSER_DIR)/,$(XCONFIG_PARSER_SRC))
1929+
1930+include $(COMMON_UTILS_DIR)/src.mk
1931+SRC += $(addprefix $(COMMON_UTILS_DIR)/,$(COMMON_UTILS_SRC))
1932+
1933+SRC += $(STAMP_C)
1934+
1935+OBJS = $(call BUILD_OBJECT_LIST,$(SRC))
1936+
1937+CFLAGS += -I .
1938+CFLAGS += -I image_data
1939+CFLAGS += -I $(XNVCTRL_DIR)
1940+CFLAGS += -I $(XCONFIG_PARSER_DIR)/..
1941+CFLAGS += -I libXNVCtrlAttributes
1942+CFLAGS += -I xpm_data
1943+CFLAGS += -I gtk+-2.x
1944+CFLAGS += -I $(COMMON_UTILS_DIR)
1945+CFLAGS += -I $(OUTPUTDIR)
1946+CFLAGS += -DPROGRAM_NAME=\"nvidia-setttings\"
1947+
1948+$(call BUILD_OBJECT_LIST,$(GTK_SRC)): CFLAGS += $(GTK_CFLAGS)
1949+
1950+
1951+##############################################################################
1952+# build rules
1953+##############################################################################
1954+
1955+.PNONY: all install NVIDIA_SETTINGS_install clean clobber
1956+
1957+all: $(NVIDIA_SETTINGS)
1958+
1959+install: NVIDIA_SETTINGS_install
1960+
1961+NVIDIA_SETTINGS_install: $(NVIDIA_SETTINGS)
1962+ $(MKDIR) $(BINDIR)
1963+ $(INSTALL) $(INSTALL_BIN_ARGS) $< $(BINDIR)/$(notdir $<)
1964+
1965+$(NVIDIA_SETTINGS): $(OBJS) $(XNVCTRL_ARCHIVE)
1966+ $(call quiet_cmd,LINK) $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) -o $@ $(OBJS) \
1967+ $(XNVCTRL_ARCHIVE) $(LIBS)
1968+ $(call quiet_cmd,STRIP_CMD) $@
1969+
1970+# define the rule to build each object file
1971+$(foreach src,$(SRC),$(eval $(call DEFINE_OBJECT_RULE,CC,$(src))))
1972+
1973+# define the rule to generate $(STAMP_C)
1974+$(eval $(call DEFINE_STAMP_C_RULE, $(OBJS),$(NVIDIA_SETTINGS_PROGRAM_NAME)))
1975+
1976+clean clobber:
1977+ rm -rf $(NVIDIA_SETTINGS) *~ $(STAMP_C) \
1978+ $(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d
1979+
1980
1981=== modified file 'src/command-line.c'
1982--- src/command-line.c 2012-02-18 10:21:04 +0000
1983+++ src/command-line.c 2012-07-30 04:30:25 +0000
1984@@ -146,6 +146,12 @@
1985 } /* print_attribute_help() */
1986
1987
1988+static void print_help_helper(const char *name, const char *description)
1989+{
1990+ nv_msg(TAB, name);
1991+ nv_msg_preserve_whitespace(BIGTAB, description);
1992+ nv_msg(NULL, "");
1993+}
1994
1995 /*
1996 * print_help() - loop through the __options[] table, and print the
1997@@ -154,66 +160,14 @@
1998
1999 void print_help(void)
2000 {
2001- int i, j, len;
2002- char *msg, *tmp, scratch[64];
2003- const NVGetoptOption *o;
2004-
2005 print_version();
2006
2007 nv_msg(NULL, "");
2008 nv_msg(NULL, "nvidia-settings [options]");
2009 nv_msg(NULL, "");
2010-
2011- for (i = 0; __options[i].name; i++) {
2012- o = &__options[i];
2013- if (isalpha(o->val)) {
2014- sprintf(scratch, "%c", o->val);
2015- msg = nvstrcat("-", scratch, ", --", o->name, NULL);
2016- } else {
2017- msg = nvstrcat("--", o->name, NULL);
2018- }
2019- if (o->flags & NVGETOPT_HAS_ARGUMENT) {
2020- len = strlen(o->name);
2021- for (j = 0; j < len; j++) scratch[j] = toupper(o->name[j]);
2022- scratch[len] = '\0';
2023- tmp = nvstrcat(msg, "=[", scratch, "]", NULL);
2024- free(msg);
2025- msg = tmp;
2026- }
2027- nv_msg(TAB, msg);
2028- free(msg);
2029-
2030- if (o->description) {
2031- char *buf = NULL, *pbuf = NULL, *s = NULL;
2032-
2033- buf = calloc(1, 1 + strlen(o->description));
2034- if (!buf) {
2035- /* XXX There should be better message than this */
2036- nv_error_msg("Not enough memory\n");
2037- return;
2038- }
2039- pbuf = buf;
2040-
2041- for (s = o->description; s && *s; s++) {
2042- switch (*s) {
2043- case '<':
2044- case '>':
2045- case '^':
2046- break;
2047- default:
2048- *pbuf = *s;
2049- pbuf++;
2050- break;
2051- }
2052- }
2053- *pbuf = '\0';
2054- nv_msg_preserve_whitespace(BIGTAB, buf);
2055- free(buf);
2056- }
2057-
2058- nv_msg(NULL, "");
2059- }
2060-} /* print_help() */
2061+
2062+ nvgetopt_print_help(__options, 0, print_help_helper);
2063+}
2064
2065
2066 /*
2067
2068=== modified file 'src/command-line.h'
2069--- src/command-line.h 2012-02-18 10:21:04 +0000
2070+++ src/command-line.h 2012-07-30 04:30:25 +0000
2071@@ -20,8 +20,6 @@
2072 #ifndef __COMMAND_LINE_H__
2073 #define __COMMAND_LINE_H__
2074
2075-#include <NvCtrlAttributes.h>
2076-
2077 #define DEFAULT_RC_FILE "~/.nvidia-settings-rc"
2078 #define CONFIG_FILE_OPTION 1
2079
2080
2081=== modified file 'src/common-utils/common-utils.c'
2082--- src/common-utils/common-utils.c 2012-02-18 10:21:04 +0000
2083+++ src/common-utils/common-utils.c 2012-07-30 04:30:25 +0000
2084@@ -1,5 +1,5 @@
2085 /*
2086- * Copyright (C) 2010 NVIDIA Corporation
2087+ * Copyright (C) 2010-2012 NVIDIA Corporation
2088 *
2089 * This program is free software; you can redistribute it and/or modify it
2090 * under the terms and conditions of the GNU General Public License,
2091@@ -150,6 +150,35 @@
2092
2093
2094 /*
2095+ * nvstrndup() - implementation of strndup() that checks return values; if
2096+ * an error occurs, an error is printed to stderr and exit is called
2097+ * -- this function will only return on success.
2098+ */
2099+
2100+char *nvstrndup(const char *s, size_t n)
2101+{
2102+ char *m;
2103+
2104+ if (!s) return NULL;
2105+
2106+ m = malloc(n + 1);
2107+
2108+ if (!m) {
2109+ fprintf(stderr, "%s: memory allocation failure during malloc (%s)! \n",
2110+ PROGRAM_NAME, strerror(errno));
2111+ exit(1);
2112+ }
2113+
2114+ strncpy (m, s, n);
2115+ m[n] = '\0';
2116+
2117+ return m;
2118+
2119+} /* nvstrndup() */
2120+
2121+
2122+
2123+/*
2124 * nvstrtolower() - convert the given string to lowercase.
2125 */
2126
2127@@ -250,3 +279,310 @@
2128 return ret;
2129
2130 } /* tilde_expansion() */
2131+
2132+
2133+/****************************************************************************/
2134+/* TextRows helper functions */
2135+/****************************************************************************/
2136+
2137+/*
2138+ * nv_format_text_rows() - this function breaks the given string str
2139+ * into some number of rows, where each row is not longer than the
2140+ * specified width.
2141+ *
2142+ * If prefix is non-NULL, the first line is prepended with the prefix,
2143+ * and subsequent lines are indented to line up with the prefix.
2144+ *
2145+ * If word_boundary is TRUE, then attempt to only break lines on
2146+ * boundaries between words.
2147+ */
2148+
2149+TextRows *nv_format_text_rows(const char *prefix,
2150+ const char *str,
2151+ int width, int word_boundary)
2152+{
2153+ int len, prefix_len, z, w, i;
2154+ char *line, *buf, *local_prefix, *a, *b, *c;
2155+ TextRows *t;
2156+
2157+ /* initialize the TextRows structure */
2158+
2159+ t = (TextRows *) malloc(sizeof(TextRows));
2160+
2161+ if (!t) return NULL;
2162+
2163+ t->t = NULL;
2164+ t->n = 0;
2165+ t->m = 0;
2166+
2167+ if (!str) return t;
2168+
2169+ buf = strdup(str);
2170+
2171+ if (!buf) return t;
2172+
2173+ z = strlen(buf); /* length of entire string */
2174+ a = buf; /* pointer to the start of the string */
2175+
2176+ /* initialize the prefix fields */
2177+
2178+ if (prefix) {
2179+ prefix_len = strlen(prefix);
2180+ local_prefix = strdup(prefix);
2181+ } else {
2182+ prefix_len = 0;
2183+ local_prefix = NULL;
2184+ }
2185+
2186+ /* adjust the max width for any prefix */
2187+
2188+ w = width - prefix_len;
2189+
2190+ do {
2191+ /*
2192+ * if the string will fit on one line, point b to the end of the
2193+ * string
2194+ */
2195+
2196+ if (z < w) b = a + z;
2197+
2198+ /*
2199+ * if the string won't fit on one line, move b to where the
2200+ * end of the line should be, and then move b back until we
2201+ * find a space; if we don't find a space before we back b all
2202+ * the way up to a, just assign b to where the line should end.
2203+ */
2204+
2205+ else {
2206+ b = a + w;
2207+
2208+ if (word_boundary) {
2209+ while ((b >= a) && (!isspace(*b))) b--;
2210+ if (b <= a) b = a + w;
2211+ }
2212+ }
2213+
2214+ /* look for any newline inbetween a and b, and move b to it */
2215+
2216+ for (c = a; c < b; c++) if (*c == '\n') { b = c; break; }
2217+
2218+ /*
2219+ * copy the string that starts at a and ends at b, prepending
2220+ * with a prefix, if present
2221+ */
2222+
2223+ len = b-a;
2224+ len += prefix_len;
2225+ line = (char *) malloc(len+1);
2226+ if (local_prefix) strncpy(line, local_prefix, prefix_len);
2227+ strncpy(line + prefix_len, a, len - prefix_len);
2228+ line[len] = '\0';
2229+
2230+ /* append the new line to the array of text rows */
2231+
2232+ t->t = (char **) realloc(t->t, sizeof(char *) * (t->n + 1));
2233+ t->t[t->n] = line;
2234+ t->n++;
2235+
2236+ if (t->m < len) t->m = len;
2237+
2238+ /*
2239+ * adjust the length of the string and move the pointer to the
2240+ * beginning of the new line
2241+ */
2242+
2243+ z -= (b - a + 1);
2244+ a = b + 1;
2245+
2246+ /* move to the first non whitespace character (excluding newlines) */
2247+
2248+ if (word_boundary && isspace(*b)) {
2249+ while ((z) && (isspace(*a)) && (*a != '\n')) a++, z--;
2250+ } else {
2251+ if (!isspace(*b)) z++, a--;
2252+ }
2253+
2254+ if (local_prefix) {
2255+ for (i = 0; i < prefix_len; i++) local_prefix[i] = ' ';
2256+ }
2257+
2258+ } while (z > 0);
2259+
2260+ if (local_prefix) free(local_prefix);
2261+ free(buf);
2262+
2263+ return t;
2264+}
2265+
2266+
2267+/*
2268+ * nv_text_rows_append() - append the given msg to the existing TextRows
2269+ */
2270+
2271+void nv_text_rows_append(TextRows *t, const char *msg)
2272+{
2273+ int len;
2274+
2275+ t->t = realloc(t->t, sizeof(char *) * (t->n + 1));
2276+
2277+ if (msg) {
2278+ t->t[t->n] = strdup(msg);
2279+ len = strlen(msg);
2280+ if (t->m < len) t->m = len;
2281+ } else {
2282+ t->t[t->n] = NULL;
2283+ }
2284+
2285+ t->n++;
2286+}
2287+
2288+/*
2289+ * nv_concat_text_rows() - concatenate two text rows, storing the
2290+ * result in t0
2291+ */
2292+
2293+#define NV_MAX(x,y) ((x) > (y) ? (x) : (y))
2294+
2295+void nv_concat_text_rows(TextRows *t0, TextRows *t1)
2296+{
2297+ int n, i;
2298+
2299+ n = t0->n + t1->n;
2300+
2301+ t0->t = realloc(t0->t, sizeof(char *) * n);
2302+
2303+ for (i = 0; i < t1->n; i++) {
2304+ t0->t[i + t0->n] = strdup(t1->t[i]);
2305+ }
2306+
2307+ t0->m = NV_MAX(t0->m, t1->m);
2308+ t0->n = n;
2309+
2310+} /* nv_concat_text_rows() */
2311+
2312+
2313+/*
2314+ * nv_free_text_rows() - free the TextRows data structure allocated by
2315+ * nv_format_text_rows()
2316+ */
2317+
2318+void nv_free_text_rows(TextRows *t)
2319+{
2320+ int i;
2321+
2322+ if (!t) return;
2323+ for (i = 0; i < t->n; i++) free(t->t[i]);
2324+ if (t->t) free(t->t);
2325+ free(t);
2326+
2327+} /* nv_free_text_rows() */
2328+
2329+
2330+/****************************************************************************/
2331+/* printing helper functions */
2332+/****************************************************************************/
2333+
2334+#define DEFAULT_WIDTH 75
2335+
2336+static unsigned short __terminal_width = 0;
2337+
2338+/*
2339+ * reset_current_terminal_width() - if new_val is zero, then use the
2340+ * TIOCGWINSZ ioctl to get the current width of the terminal, and
2341+ * assign it the value to __terminal_width. If the ioctl fails, use a
2342+ * hardcoded constant. If new_val is non-zero, then use new_val.
2343+ */
2344+
2345+void reset_current_terminal_width(unsigned short new_val)
2346+{
2347+ struct winsize ws;
2348+
2349+ if (new_val) {
2350+ __terminal_width = new_val;
2351+ return;
2352+ }
2353+
2354+ if (ioctl(STDERR_FILENO, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) {
2355+ __terminal_width = DEFAULT_WIDTH;
2356+ } else {
2357+ __terminal_width = ws.ws_col - 1;
2358+ }
2359+}
2360+
2361+/*
2362+ * Call silence_fmt(1) to turn fmtout(), fmtoutp() and format() into noops.
2363+ */
2364+static int __silent = 0;
2365+
2366+void silence_fmt(int val)
2367+{
2368+ __silent = val;
2369+}
2370+
2371+
2372+static void vformat(FILE *stream, const int wb,
2373+ const char *prefix, const char *buf)
2374+{
2375+ int i;
2376+ TextRows *t;
2377+
2378+ if (!__terminal_width) reset_current_terminal_width(0);
2379+
2380+ t = nv_format_text_rows(prefix, buf, __terminal_width, wb);
2381+
2382+ for (i = 0; i < t->n; i++) fprintf(stream, "%s\n", t->t[i]);
2383+
2384+ nv_free_text_rows(t);
2385+}
2386+
2387+
2388+#define NV_VFORMAT(stream, wb, prefix, fmt) \
2389+do { \
2390+ char *buf; \
2391+ NV_VSNPRINTF(buf, fmt); \
2392+ vformat(stream, wb, prefix, buf); \
2393+ free (buf); \
2394+} while(0)
2395+
2396+
2397+void fmtout(const char *fmt, ...)
2398+{
2399+ if (__silent > 0) {
2400+ return;
2401+ }
2402+ NV_VFORMAT(stdout, TRUE, NULL, fmt);
2403+}
2404+
2405+
2406+void fmtoutp(const char *prefix, const char *fmt, ...)
2407+{
2408+ if (__silent > 0) {
2409+ return;
2410+ }
2411+ NV_VFORMAT(stdout, TRUE, prefix, fmt);
2412+}
2413+
2414+
2415+void fmterr(const char *fmt, ...)
2416+{
2417+ vformat(stderr, 0, NULL, "");
2418+ NV_VFORMAT(stderr, TRUE, "ERROR: ", fmt);
2419+ vformat(stderr, 0, NULL, "");
2420+}
2421+
2422+
2423+void fmtwarn(const char *fmt, ...)
2424+{
2425+ vformat(stderr, 0, NULL, "");
2426+ NV_VFORMAT(stderr, TRUE, "WARNING: ", fmt);
2427+ vformat(stderr, 0, NULL, "");
2428+}
2429+
2430+
2431+void fmt(FILE *stream, const char *prefix, const char *fmt, ...)
2432+{
2433+ if (__silent > 0) {
2434+ return;
2435+ }
2436+ NV_VFORMAT(stream, TRUE, prefix, fmt);
2437+}
2438
2439=== modified file 'src/common-utils/common-utils.h'
2440--- src/common-utils/common-utils.h 2012-02-18 10:21:04 +0000
2441+++ src/common-utils/common-utils.h 2012-07-30 04:30:25 +0000
2442@@ -1,5 +1,5 @@
2443 /*
2444- * Copyright (C) 2010 NVIDIA Corporation
2445+ * Copyright (C) 2010-2012 NVIDIA Corporation
2446 *
2447 * This program is free software; you can redistribute it and/or modify it
2448 * under the terms and conditions of the GNU General Public License,
2449@@ -17,6 +17,9 @@
2450 #ifndef __COMMON_UTILS_H__
2451 #define __COMMON_UTILS_H__
2452
2453+#include <stdio.h>
2454+#include <stdarg.h>
2455+
2456 #if !defined(TRUE)
2457 #define TRUE 1
2458 #endif
2459@@ -25,13 +28,86 @@
2460 #define FALSE 0
2461 #endif
2462
2463+#define ARRAY_LEN(_arr) (sizeof(_arr) / sizeof(_arr[0]))
2464+
2465+#define TAB " "
2466+#define BIGTAB " "
2467+
2468+typedef struct {
2469+ char **t; /* the text rows */
2470+ int n; /* number of rows */
2471+ int m; /* maximum row length */
2472+} TextRows;
2473+
2474 void *nvalloc(size_t size);
2475 char *nvstrcat(const char *str, ...);
2476 void *nvrealloc(void *ptr, size_t size);
2477 char *nvstrdup(const char *s);
2478+char *nvstrndup(const char *s, size_t n);
2479 char *nvstrtolower(char *s);
2480 void nvfree(void *s);
2481
2482 char *tilde_expansion(const char *str);
2483
2484+TextRows *nv_format_text_rows(const char *prefix,
2485+ const char *str,
2486+ int width, int word_boundary);
2487+void nv_text_rows_append(TextRows *t, const char *msg);
2488+void nv_concat_text_rows(TextRows *t0, TextRows *t1);
2489+void nv_free_text_rows(TextRows *t);
2490+
2491+void reset_current_terminal_width(unsigned short new_val);
2492+
2493+void silence_fmt(int val);
2494+void fmtout(const char *fmt, ...);
2495+void fmtoutp(const char *prefix, const char *fmt, ...);
2496+void fmterr(const char *fmt, ...);
2497+void fmtwarn(const char *fmt, ...);
2498+void fmt(FILE *stream, const char *prefix, const char *fmt, ...);
2499+
2500+/*
2501+ * NV_VSNPRINTF(): macro that assigns buf using vsnprintf(). This is
2502+ * correct for differing semantics of the vsnprintf() return value:
2503+ *
2504+ * -1 when the buffer is not long enough (glibc < 2.1)
2505+ *
2506+ * or
2507+ *
2508+ * the length the string would have been if the buffer had been large
2509+ * enough (glibc >= 2.1)
2510+ *
2511+ * This macro allocates memory for buf; the caller should free it when
2512+ * done.
2513+ */
2514+
2515+#define NV_FMT_BUF_LEN 256
2516+
2517+#define NV_VSNPRINTF(buf, fmt) \
2518+do { \
2519+ if (!fmt) { \
2520+ (buf) = NULL; \
2521+ } else { \
2522+ va_list ap; \
2523+ int len, current_len = NV_FMT_BUF_LEN; \
2524+ \
2525+ (buf) = malloc(current_len); \
2526+ \
2527+ while (1) { \
2528+ va_start(ap, fmt); \
2529+ len = vsnprintf((buf), current_len, (fmt), ap); \
2530+ va_end(ap); \
2531+ \
2532+ if ((len > -1) && (len < current_len)) { \
2533+ break; \
2534+ } else if (len > -1) { \
2535+ current_len = len + 1; \
2536+ } else { \
2537+ current_len += NV_FMT_BUF_LEN; \
2538+ } \
2539+ free(buf); \
2540+ (buf) = malloc(current_len); \
2541+ } \
2542+ } \
2543+} while (0)
2544+
2545 #endif /* __COMMON_UTILS_H__ */
2546
2547=== added file 'src/common-utils/gen-manpage-opts-helper.c'
2548--- src/common-utils/gen-manpage-opts-helper.c 1970-01-01 00:00:00 +0000
2549+++ src/common-utils/gen-manpage-opts-helper.c 2012-07-30 04:30:25 +0000
2550@@ -0,0 +1,181 @@
2551+/*
2552+ * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
2553+ *
2554+ * This program is free software; you can redistribute it and/or modify it
2555+ * under the terms and conditions of the GNU General Public License,
2556+ * version 2, as published by the Free Software Foundation.
2557+ *
2558+ * This program is distributed in the hope it will be useful, but WITHOUT
2559+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2560+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
2561+ * more details.
2562+ *
2563+ * You should have received a copy of the GNU General Public License
2564+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2565+ */
2566+
2567+#include <stdio.h>
2568+#include <ctype.h>
2569+#include <string.h>
2570+
2571+#include "nvgetopt.h"
2572+#include "gen-manpage-opts-helper.h"
2573+
2574+static void print_option(const NVGetoptOption *o)
2575+{
2576+ char scratch[64], *s;
2577+ int j, len;
2578+
2579+ int italics, bold, omitWhiteSpace;
2580+
2581+ /* if we are going to need the argument, process it now */
2582+ if (o->flags & NVGETOPT_HAS_ARGUMENT) {
2583+ if (o->arg_name) {
2584+ strcpy(scratch, o->arg_name);
2585+ } else {
2586+ len = strlen(o->name);
2587+ for (j = 0; j < len; j++) scratch[j] = toupper(o->name[j]);
2588+ scratch[len] = '\0';
2589+ }
2590+ }
2591+
2592+ printf(".TP\n.BI \"");
2593+ /* Print the name of the option */
2594+ /* XXX We should backslashify the '-' characters in o->name. */
2595+
2596+ if (isalpha(o->val)) {
2597+ /* '\-c' */
2598+ printf("\\-%c", o->val);
2599+
2600+ if (o->flags & NVGETOPT_HAS_ARGUMENT) {
2601+ /* ' " "ARG" "' */
2602+ printf(" \" \"%s\" \"", scratch);
2603+ }
2604+ /* ', ' */
2605+ printf(", ");
2606+ }
2607+
2608+ /* '\-\-name' */
2609+ printf("\\-\\-%s", o->name);
2610+
2611+ /* '=" "ARG' */
2612+ if (o->flags & NVGETOPT_HAS_ARGUMENT) {
2613+ printf("=\" \"%s", scratch);
2614+
2615+ /* '" "' */
2616+ if ((o->flags & NVGETOPT_IS_BOOLEAN) ||
2617+ (o->flags & NVGETOPT_ALLOW_DISABLE)) {
2618+ printf("\" \"");
2619+ }
2620+ }
2621+
2622+ /* ', \-\-no\-name' */
2623+ if (((o->flags & NVGETOPT_IS_BOOLEAN) &&
2624+ !(o->flags & NVGETOPT_HAS_ARGUMENT)) ||
2625+ (o->flags & NVGETOPT_ALLOW_DISABLE)) {
2626+ printf(", \\-\\-no\\-%s", o->name);
2627+ }
2628+
2629+ printf("\"\n");
2630+
2631+ /* Print the option description */
2632+ /* XXX Each sentence should be on its own line! */
2633+
2634+ /*
2635+ * Print the option description: write each character one at a
2636+ * time (ugh) so that we can special-case a few characters:
2637+ *
2638+ * '&' : toggles italics on and off
2639+ * '^' : toggles bold on and off
2640+ * '-' : is backslashified: "\-"
2641+ *
2642+ * Whitespace is omited when italics or bold is on
2643+ */
2644+
2645+ italics = 0;
2646+ bold = 0;
2647+ omitWhiteSpace = 0;
2648+
2649+ for (s = o->description; s && *s; s++) {
2650+
2651+ switch (*s) {
2652+ case '&':
2653+ if (italics) {
2654+ printf("\n");
2655+ } else {
2656+ printf("\n.I ");
2657+ }
2658+ omitWhiteSpace = italics;
2659+ italics = !italics;
2660+ break;
2661+ case '^':
2662+ if (bold) {
2663+ printf("\n");
2664+ } else {
2665+ printf("\n.B ");
2666+ }
2667+ omitWhiteSpace = bold;
2668+ bold = !bold;
2669+ break;
2670+ case '-':
2671+ printf("\\-");
2672+ omitWhiteSpace = 0;
2673+ break;
2674+ case ' ':
2675+ if (!omitWhiteSpace) {
2676+ printf(" ");
2677+ }
2678+ break;
2679+ default:
2680+ printf("%c", *s);
2681+ omitWhiteSpace = 0;
2682+ break;
2683+ }
2684+ }
2685+
2686+ printf("\n");
2687+}
2688+
2689+void gen_manpage_opts_helper(const NVGetoptOption *options)
2690+{
2691+ int i;
2692+ int has_advanced_options = 0;
2693+
2694+ /* Print the "simple" options; i.e. the ones you get with --help. */
2695+ printf(".SH OPTIONS\n");
2696+ for (i = 0; options[i].name; i++) {
2697+ const NVGetoptOption *o = &options[i];
2698+
2699+ if (!o->description) {
2700+ continue;
2701+ }
2702+
2703+ if (!(o->flags & NVGETOPT_HELP_ALWAYS)) {
2704+ has_advanced_options = 1;
2705+ continue;
2706+ }
2707+
2708+ print_option(o);
2709+ }
2710+
2711+ if (has_advanced_options) {
2712+ /*
2713+ * If any exist, print the advanced options; i.e., the ones
2714+ * you get with --advanced-help
2715+ */
2716+ printf(".SH \"ADVANCED OPTIONS\"\n");
2717+ for (i = 0; options[i].name; i++) {
2718+ const NVGetoptOption *o = &options[i];
2719+
2720+ if (!o->description) {
2721+ continue;
2722+ }
2723+
2724+ if (o->flags & NVGETOPT_HELP_ALWAYS) {
2725+ continue;
2726+ }
2727+
2728+ print_option(o);
2729+ }
2730+ }
2731+}
2732
2733=== added file 'src/common-utils/gen-manpage-opts-helper.h'
2734--- src/common-utils/gen-manpage-opts-helper.h 1970-01-01 00:00:00 +0000
2735+++ src/common-utils/gen-manpage-opts-helper.h 2012-07-30 04:30:25 +0000
2736@@ -0,0 +1,24 @@
2737+/*
2738+ * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
2739+ *
2740+ * This program is free software; you can redistribute it and/or modify it
2741+ * under the terms and conditions of the GNU General Public License,
2742+ * version 2, as published by the Free Software Foundation.
2743+ *
2744+ * This program is distributed in the hope it will be useful, but WITHOUT
2745+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2746+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
2747+ * more details.
2748+ *
2749+ * You should have received a copy of the GNU General Public License
2750+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2751+ */
2752+
2753+#if !defined(__GEN_MANPAGE_OPTS_HELPER_H__)
2754+#define __GEN_MANPAGE_OPTS_HELPER_H__
2755+
2756+#include "nvgetopt.h"
2757+
2758+void gen_manpage_opts_helper(const NVGetoptOption *options);
2759+
2760+#endif /* __GEN_MANPAGE_OPTS_HELPER_H__ */
2761
2762=== modified file 'src/common-utils/nvgetopt.c'
2763--- src/common-utils/nvgetopt.c 2012-02-18 10:21:04 +0000
2764+++ src/common-utils/nvgetopt.c 2012-07-30 04:30:25 +0000
2765@@ -21,8 +21,10 @@
2766 #include <stdio.h>
2767 #include <string.h>
2768 #include <stdlib.h>
2769+#include <ctype.h>
2770
2771 #include "nvgetopt.h"
2772+#include "common-utils.h"
2773
2774
2775 int nvgetopt(int argc,
2776@@ -309,3 +311,126 @@
2777 return ret;
2778
2779 } /* nvgetopt() */
2780+
2781+
2782+/*
2783+ * cook_description() - the description string may contain text within
2784+ * special characters which are interpreted by the manpage generator.
2785+ * We want to omit those characters here.
2786+ */
2787+
2788+static char *cook_description(const char *description)
2789+{
2790+ const char *src;
2791+ char *s, *dst;
2792+
2793+ if (!description) {
2794+ return NULL;
2795+ }
2796+
2797+ s = strdup(description);
2798+
2799+ if (!s) {
2800+ return NULL;
2801+ }
2802+
2803+ for (src = description, dst = s; *src; src++) {
2804+ if ((*src == '&') || (*src == '^')) {
2805+ continue;
2806+ }
2807+ *dst = *src;
2808+ dst++;
2809+ }
2810+
2811+ *dst = '\0';
2812+
2813+ return s;
2814+}
2815+
2816+
2817+void nvgetopt_print_help(const NVGetoptOption *options,
2818+ unsigned int include_mask,
2819+ nvgetopt_print_help_callback_ptr callback)
2820+{
2821+ const NVGetoptOption *o;
2822+ int i;
2823+
2824+ for (i = 0; options[i].name; i++) {
2825+
2826+ char *msg = NULL, *arg = NULL, *description = NULL;
2827+
2828+ o = &options[i];
2829+
2830+ /* Skip options with no help text */
2831+ if (!o->description) {
2832+ continue;
2833+ }
2834+
2835+ /* skip options who don't have all the bits of include_mask */
2836+ if ((o->flags & include_mask) != include_mask) {
2837+ continue;
2838+ }
2839+
2840+ /* if we are going to need the argument, process it now */
2841+ arg = NULL;
2842+ if (o->flags & NVGETOPT_HAS_ARGUMENT) {
2843+ if (o->arg_name) {
2844+ arg = strdup(o->arg_name);
2845+ } else {
2846+ char *tmp;
2847+ arg = strdup(o->name);
2848+ for (tmp = arg; tmp && *tmp; tmp++) {
2849+ *tmp = toupper(*tmp);
2850+ }
2851+ }
2852+ }
2853+
2854+ msg = NULL;
2855+
2856+ /*
2857+ * create the long version of the option, possibly with an
2858+ * argument; e.g., "--foo" or "--foo=BAR"
2859+ */
2860+ if (arg) {
2861+ msg = nvstrcat("--", o->name, "=", arg, NULL);
2862+ } else {
2863+ msg = nvstrcat("--", o->name, NULL);
2864+ }
2865+
2866+ /*
2867+ * prepend the single character version of the option,
2868+ * possibly with an argument; e.g., "-f" or "-f BAR"
2869+ */
2870+ if (isalpha(o->val)) {
2871+ char scratch[16];
2872+ char *tmp;
2873+ snprintf(scratch, sizeof(scratch), "%c", o->val);
2874+ if (arg) {
2875+ tmp = nvstrcat("-", scratch, " ", arg, ", ", msg, NULL);
2876+ } else {
2877+ tmp = nvstrcat("-", scratch, ", ", msg, NULL);
2878+ }
2879+ free(msg);
2880+ msg = tmp;
2881+ }
2882+
2883+ /* append the boolean version of the option; e.g., "--no-foo" */
2884+ if (((o->flags & NVGETOPT_IS_BOOLEAN) &&
2885+ !(o->flags & NVGETOPT_HAS_ARGUMENT)) ||
2886+ (o->flags & NVGETOPT_ALLOW_DISABLE)) {
2887+ char *tmp = nvstrcat(msg, ", --no-", o->name, NULL);
2888+ free(msg);
2889+ msg = tmp;
2890+ }
2891+
2892+ /* process the description text */
2893+ description = cook_description(o->description);
2894+
2895+ /* give the strings to the caller to format and print */
2896+ callback(msg, description);
2897+
2898+ free(msg);
2899+ free(arg);
2900+ free(description);
2901+ }
2902+}
2903
2904=== modified file 'src/common-utils/nvgetopt.h'
2905--- src/common-utils/nvgetopt.h 2012-02-18 10:21:04 +0000
2906+++ src/common-utils/nvgetopt.h 2012-07-30 04:30:25 +0000
2907@@ -155,5 +155,29 @@
2908 double *doubleval,
2909 int *disable_val);
2910
2911+/*
2912+ * nvgetopt_print_help() - print a help message for each option in the
2913+ * provided NVGetoptOption array. This is useful for a utility's
2914+ * "--help" output.
2915+ *
2916+ * Options will only be printed if they have every bit set that
2917+ * include_mask includes.
2918+ *
2919+ * For each option, the provided callback function wil be called with
2920+ * two strings: a name string that lists the option's name, and a
2921+ * description string for the option. The callback function is
2922+ * responsible for actually printing these strings. Examples:
2923+ *
2924+ * name = "-v, --version";
2925+ * description = "Print usage information for the common commandline "
2926+ * "options and exit.";
2927+ */
2928+
2929+typedef void nvgetopt_print_help_callback_ptr(const char *name,
2930+ const char *description);
2931+
2932+void nvgetopt_print_help(const NVGetoptOption *options,
2933+ unsigned int include_mask,
2934+ nvgetopt_print_help_callback_ptr callback);
2935
2936 #endif /* __NVGETOPT_H__ */
2937
2938=== modified file 'src/common-utils/src.mk'
2939--- src/common-utils/src.mk 2011-02-25 15:18:56 +0000
2940+++ src/common-utils/src.mk 2012-07-30 04:30:25 +0000
2941@@ -7,3 +7,9 @@
2942 COMMON_UTILS_EXTRA_DIST += common-utils.h
2943 COMMON_UTILS_EXTRA_DIST += src.mk
2944
2945+# gen-manpage-opts-helper.c is listed in EXTRA_DIST, rather than SRC,
2946+# because it is not compiled into the utilities themselves, but used
2947+# when building the utility's gen-manpage-opts
2948+COMMON_UTILS_EXTRA_DIST += gen-manpage-opts-helper.c
2949+COMMON_UTILS_EXTRA_DIST += gen-manpage-opts-helper.h
2950+
2951
2952=== modified file 'src/config-file.c'
2953--- src/config-file.c 2012-02-18 10:21:04 +0000
2954+++ src/config-file.c 2012-07-30 04:30:25 +0000
2955@@ -434,14 +434,14 @@
2956 (p->display_device_mask);
2957
2958 fprintf(stream, "%s%s%c%s[%s]=%d\n", p->display, target_str,
2959- DISPLAY_NAME_SEPARATOR, tmp, tmp_d_str, p->val);
2960+ DISPLAY_NAME_SEPARATOR, tmp, tmp_d_str, p->val.i);
2961
2962 free(tmp_d_str);
2963
2964 } else {
2965
2966 fprintf(stream, "%s%s%c%s=%d\n", p->display, target_str,
2967- DISPLAY_NAME_SEPARATOR, tmp, p->val);
2968+ DISPLAY_NAME_SEPARATOR, tmp, p->val.i);
2969 }
2970
2971 p = p->next;
2972
2973=== modified file 'src/gen-manpage-opts.c'
2974--- src/gen-manpage-opts.c 2012-02-18 10:21:04 +0000
2975+++ src/gen-manpage-opts.c 2012-07-30 04:30:25 +0000
2976@@ -24,119 +24,10 @@
2977
2978 #include "nvgetopt.h"
2979 #include "option-table.h"
2980-
2981-#define NV_FMT_BUF_LEN 512
2982-
2983-/*
2984- * Prints the option help in a form that is suitable to include in the manpage.
2985- */
2986-
2987-static void print_option(const NVGetoptOption *o)
2988-{
2989- int omitWhiteSpace;
2990-
2991- /* if we are going to need the argument, process it now */
2992-
2993- printf(".TP\n.BI \"");
2994- /* Print the name of the option */
2995- /* XXX We should backslashify the '-' characters in o->name. */
2996-
2997- if (isalpha(o->val)) {
2998- /* '\-c \-\-name' */
2999- printf("\\-%c, \\-\\-%s", o->val, o->name);
3000- } else {
3001- printf("\\-\\-%s", o->name);
3002- }
3003-
3004- /* '=" "ARG' */
3005- if (o->flags & NVGETOPT_HAS_ARGUMENT) {
3006- int len, j;
3007- char tbuf[32];
3008- len = strlen(o->name);
3009- for (j = 0; j < len; j++)
3010- tbuf[j] = toupper(o->name[j]);
3011- tbuf[len] = '\0';
3012- printf("=\" \"%s", tbuf);
3013- }
3014-
3015- printf("\"\n");
3016-
3017- /* Print the option description */
3018- /* XXX Each sentence should be on its own line! */
3019-
3020- /*
3021- * Print the option description: write each character one at a
3022- * time (ugh) so that we can special-case a few characters:
3023- *
3024- * "^" --> "\n.I "
3025- * "<" --> "\n.B "
3026- * ">" --> "\n"
3027- *
3028- * '^' is used to mark the text as underlined till it is turned off with '>'.
3029- * '<' is used to mark the text as bold till it is turned off with '>'.
3030- *
3031- * XXX Each sentence should be on its own line!
3032- */
3033-
3034- if (o->description) {
3035- char *buf = NULL, *s = NULL, *pbuf = NULL;
3036-
3037- buf = calloc(1, NV_FMT_BUF_LEN + strlen(o->description));
3038- if (!buf) {
3039- /* XXX There should be better message than this */
3040- printf("Not enough memory\n");
3041- return;
3042- }
3043- pbuf = buf;
3044-
3045- omitWhiteSpace = 0;
3046- for (s = o->description; s && *s; s++) {
3047- switch (*s) {
3048- case '<':
3049- sprintf(pbuf, "\n.B ");
3050- pbuf = pbuf + 4;
3051- omitWhiteSpace = 0;
3052- break;
3053- case '^':
3054- sprintf(pbuf, "\n.I ");
3055- pbuf = pbuf + 4;
3056- omitWhiteSpace = 0;
3057- break;
3058- case '>':
3059- *pbuf = '\n';
3060- pbuf++;
3061- omitWhiteSpace = 1;
3062- break;
3063- case ' ':
3064- if (!omitWhiteSpace) {
3065- *pbuf = *s;
3066- pbuf++;
3067- }
3068- break;
3069- default:
3070- *pbuf = *s;
3071- pbuf++;
3072- omitWhiteSpace = 0;
3073- break;
3074- }
3075- }
3076- printf("%s", buf);
3077- free(buf);
3078- }
3079-
3080- printf("\n");
3081-}
3082-
3083-int main(int argc, char* argv[])
3084-{
3085- int i;
3086- const NVGetoptOption *o;
3087-
3088- printf(".SH OPTIONS\n");
3089- for (i = 0; __options[i].name; i++) {
3090- o = &__options[i];
3091- print_option(o);
3092- }
3093-
3094+#include "gen-manpage-opts-helper.h"
3095+
3096+int main(void)
3097+{
3098+ gen_manpage_opts_helper(__options);
3099 return 0;
3100 }
3101
3102=== modified file 'src/glxinfo.c'
3103--- src/glxinfo.c 2012-02-18 10:21:04 +0000
3104+++ src/glxinfo.c 2012-07-30 04:30:25 +0000
3105@@ -25,6 +25,7 @@
3106 #include "NvCtrlAttributes.h"
3107 #include "query-assign.h" /* CtrlHandles */
3108 #include "msg.h"
3109+#include "glxinfo.h"
3110
3111 #include <GL/glx.h> /* GLX #defines */
3112
3113
3114=== modified file 'src/gtk+-2.x/ctk3dvisionpro.c'
3115--- src/gtk+-2.x/ctk3dvisionpro.c 2012-02-18 10:21:04 +0000
3116+++ src/gtk+-2.x/ctk3dvisionpro.c 2012-07-30 04:30:25 +0000
3117@@ -197,6 +197,7 @@
3118 sizeof (Ctk3DVisionPro),
3119 0, /* n_preallocs */
3120 NULL, /* instance_init */
3121+ NULL /* value_table */
3122 };
3123
3124 ctk_3d_vision_pro_type = g_type_register_static(GTK_TYPE_VBOX,
3125
3126=== modified file 'src/gtk+-2.x/ctkbanner.c'
3127--- src/gtk+-2.x/ctkbanner.c 2012-02-18 10:21:04 +0000
3128+++ src/gtk+-2.x/ctkbanner.c 2012-07-30 04:30:25 +0000
3129@@ -49,7 +49,6 @@
3130 #include "opengl_pixdata.h"
3131 #include "penguin_pixdata.h"
3132 #include "gvi_pixdata.h"
3133-#include "rotation_pixdata.h"
3134 #include "sdi_pixdata.h"
3135 #include "sdi_shared_sync_bnc_pixdata.h"
3136 #include "slimm_pixdata.h"
3137@@ -105,6 +104,7 @@
3138 sizeof (CtkBanner),
3139 0, /* n_preallocs */
3140 NULL, /* instance_init */
3141+ NULL /* value_table */
3142 };
3143
3144 ctk_banner_type = g_type_register_static(GTK_TYPE_DRAWING_AREA,
3145@@ -365,7 +365,6 @@
3146 { BANNER_ARTWORK_HELP, FALSE, 16, &help_pixdata },
3147 { BANNER_ARTWORK_OPENGL, FALSE, 16, &opengl_pixdata },
3148 { BANNER_ARTWORK_PENGUIN, TRUE, 16, &penguin_pixdata },
3149- { BANNER_ARTWORK_ROTATION, FALSE, 16, &rotation_pixdata },
3150 { BANNER_ARTWORK_SDI, FALSE, 16, &sdi_pixdata },
3151 { BANNER_ARTWORK_SDI_SHARED_SYNC_BNC, FALSE, 16, &sdi_shared_sync_bnc_pixdata },
3152 { BANNER_ARTWORK_SLIMM, FALSE, 16, &slimm_pixdata },
3153
3154=== modified file 'src/gtk+-2.x/ctkbanner.h'
3155--- src/gtk+-2.x/ctkbanner.h 2012-02-18 10:21:04 +0000
3156+++ src/gtk+-2.x/ctkbanner.h 2012-07-30 04:30:25 +0000
3157@@ -60,7 +60,6 @@
3158 BANNER_ARTWORK_HELP,
3159 BANNER_ARTWORK_OPENGL,
3160 BANNER_ARTWORK_PENGUIN,
3161- BANNER_ARTWORK_ROTATION,
3162 BANNER_ARTWORK_SDI,
3163 BANNER_ARTWORK_SDI_SHARED_SYNC_BNC,
3164 BANNER_ARTWORK_SLIMM,
3165
3166=== modified file 'src/gtk+-2.x/ctkclocks.c'
3167--- src/gtk+-2.x/ctkclocks.c 2012-02-18 10:21:04 +0000
3168+++ src/gtk+-2.x/ctkclocks.c 2012-07-30 04:30:25 +0000
3169@@ -165,6 +165,7 @@
3170 sizeof(CtkClocks),
3171 0, /* n_preallocs */
3172 NULL, /* instance_init */
3173+ NULL /* value_table */
3174 };
3175
3176 ctk_object_type = g_type_register_static
3177
3178=== modified file 'src/gtk+-2.x/ctkcolorcontrols.c'
3179--- src/gtk+-2.x/ctkcolorcontrols.c 2012-02-18 10:21:04 +0000
3180+++ src/gtk+-2.x/ctkcolorcontrols.c 2012-07-30 04:30:25 +0000
3181@@ -43,6 +43,8 @@
3182 static
3183 gboolean update_color_space_menu_info(CtkColorControls *ctk_color_controls);
3184
3185+static void setup_reset_button(CtkColorControls *ctk_color_controls);
3186+
3187 static void color_space_menu_changed(GtkOptionMenu *color_space_menu,
3188 gpointer user_data);
3189 static void color_range_menu_changed(GtkOptionMenu *color_range_menu,
3190@@ -90,6 +92,7 @@
3191 sizeof (CtkColorControls),
3192 0, /* n_preallocs */
3193 NULL, /* instance_init */
3194+ NULL /* value_table */
3195 };
3196
3197 ctk_color_controls_type =
3198@@ -105,7 +108,6 @@
3199 CtkConfig *ctk_config,
3200 CtkEvent *ctk_event,
3201 GtkWidget *reset_button,
3202- unsigned int display_device_mask,
3203 char *name)
3204 {
3205 GObject *object;
3206@@ -117,12 +119,12 @@
3207 gint i;
3208
3209 /* check if color configuration is supported */
3210- ret1 = NvCtrlGetValidDisplayAttributeValues(handle, display_device_mask,
3211- NV_CTRL_COLOR_SPACE,
3212- &valid1);
3213- ret2 = NvCtrlGetValidDisplayAttributeValues(handle, display_device_mask,
3214- NV_CTRL_COLOR_RANGE,
3215- &valid2);
3216+ ret1 = NvCtrlGetValidAttributeValues(handle,
3217+ NV_CTRL_COLOR_SPACE,
3218+ &valid1);
3219+ ret2 = NvCtrlGetValidAttributeValues(handle,
3220+ NV_CTRL_COLOR_RANGE,
3221+ &valid2);
3222
3223 if ((ret1 != NvCtrlSuccess) || (ret2 != NvCtrlSuccess)) {
3224 return NULL;
3225@@ -138,7 +140,6 @@
3226 ctk_color_controls->handle = handle;
3227 ctk_color_controls->ctk_config = ctk_config;
3228 ctk_color_controls->reset_button = reset_button;
3229- ctk_color_controls->display_device_mask = display_device_mask;
3230 ctk_color_controls->name = strdup(name);
3231
3232 /* build a table holding available color space */
3233@@ -150,7 +151,7 @@
3234
3235 hbox = gtk_hbox_new(FALSE, 0);
3236 gtk_box_pack_start(GTK_BOX(object), hbox, FALSE, FALSE, FRAME_PADDING);
3237- ctk_color_controls->color_controls_main = hbox;
3238+ ctk_color_controls->color_controls_box = hbox;
3239
3240 frame = gtk_frame_new("Color Controls");
3241 gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, FALSE, 0);
3242@@ -210,7 +211,6 @@
3243 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
3244
3245 hbox = gtk_hbox_new(FALSE, 0);
3246- ctk_color_controls->color_space_box = hbox;
3247 gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 0, 1,
3248 GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
3249 gtk_box_pack_start(GTK_BOX(hbox),
3250@@ -270,6 +270,50 @@
3251 } /* ctk_color_controls_new() */
3252
3253
3254+
3255+/*
3256+ * setup_reset_button() - enables the reset button if any of the current
3257+ * settings are not the default.
3258+ */
3259+static void setup_reset_button(CtkColorControls *ctk_color_controls)
3260+{
3261+ gint history;
3262+ gint val;
3263+
3264+ if (!GTK_WIDGET_SENSITIVE(ctk_color_controls->color_controls_box)) {
3265+ /* Nothing is available, don't bother enabling the reset button yet. */
3266+ return;
3267+ }
3268+
3269+ /* The color space menu is always available */
3270+ history = gtk_option_menu_get_history
3271+ (GTK_OPTION_MENU(ctk_color_controls->color_space_menu));
3272+ val = ctk_color_controls->color_space_table[history];
3273+ if (val != NV_CTRL_COLOR_SPACE_RGB) {
3274+ goto enable;
3275+ }
3276+
3277+ /* Color range is dependent on the color space */
3278+ if (GTK_WIDGET_SENSITIVE(ctk_color_controls->color_range_menu)) {
3279+ history = gtk_option_menu_get_history
3280+ (GTK_OPTION_MENU(ctk_color_controls->color_range_menu));
3281+ val = ctk_color_controls->color_range_table[history];
3282+ if (val != NV_CTRL_COLOR_RANGE_FULL) {
3283+ goto enable;
3284+ }
3285+ }
3286+
3287+ /* Don't disable reset button here, since other settings that are not
3288+ * managed by the ctk_image_slider here may need it enabled
3289+ */
3290+ return;
3291+
3292+ enable:
3293+ gtk_widget_set_sensitive(ctk_color_controls->reset_button, TRUE);
3294+}
3295+
3296+
3297+
3298 /*
3299 * ctk_color_controls_setup() - Setup routine for color attributes. Used
3300 * in DFP setup stage as well as for updating the GUI when there is change in
3301@@ -283,10 +327,12 @@
3302
3303 /* color space */
3304 if (!update_color_space_menu_info(ctk_color_controls)) {
3305- gtk_widget_set_sensitive(ctk_color_controls->color_controls_main,
3306- FALSE);
3307- gtk_widget_hide_all(ctk_color_controls->color_controls_main);
3308+ gtk_widget_set_sensitive(ctk_color_controls->color_controls_box, FALSE);
3309+ gtk_widget_hide_all(ctk_color_controls->color_controls_box);
3310 }
3311+
3312+ setup_reset_button(ctk_color_controls);
3313+
3314 } /* ctk_color_controls_setup() */
3315
3316
3317@@ -296,11 +342,9 @@
3318
3319 /* color space */
3320 if (NvCtrlSuccess !=
3321- NvCtrlGetDisplayAttribute(ctk_color_controls->handle,
3322- ctk_color_controls->display_device_mask,
3323- NV_CTRL_COLOR_SPACE,
3324- &color_space)) {
3325- free(ctk_color_controls->color_space_table);
3326+ NvCtrlGetAttribute(ctk_color_controls->handle,
3327+ NV_CTRL_COLOR_SPACE,
3328+ &color_space)) {
3329 return FALSE;
3330 }
3331
3332@@ -322,9 +366,14 @@
3333 (gpointer) ctk_color_controls);
3334
3335 /* dynamically regenerate color range dropdown */
3336- setup_color_range_dropdown(ctk_color_controls);
3337-
3338- return True;
3339+ if (!setup_color_range_dropdown(ctk_color_controls)) {
3340+ gtk_widget_set_sensitive(ctk_color_controls->color_range_menu, FALSE);
3341+ } else {
3342+ gtk_widget_set_sensitive(ctk_color_controls->color_range_menu, TRUE);
3343+ }
3344+
3345+ return TRUE;
3346+
3347 } /* update_color_space_menu_info() */
3348
3349 static
3350@@ -370,10 +419,9 @@
3351 history = gtk_option_menu_get_history(color_range_menu);
3352 color_range = ctk_color_controls->color_range_table[history];
3353
3354- NvCtrlSetDisplayAttribute(ctk_color_controls->handle,
3355- ctk_color_controls->display_device_mask,
3356- NV_CTRL_COLOR_RANGE,
3357- color_range);
3358+ NvCtrlSetAttribute(ctk_color_controls->handle,
3359+ NV_CTRL_COLOR_RANGE,
3360+ color_range);
3361
3362 g_signal_handlers_block_by_func
3363 (G_OBJECT(ctk_color_controls->color_range_menu),
3364@@ -406,10 +454,9 @@
3365
3366 color_space = ctk_color_controls->color_space_table[history];
3367
3368- NvCtrlSetDisplayAttribute(ctk_color_controls->handle,
3369- ctk_color_controls->display_device_mask,
3370- NV_CTRL_COLOR_SPACE,
3371- color_space);
3372+ NvCtrlSetAttribute(ctk_color_controls->handle,
3373+ NV_CTRL_COLOR_SPACE,
3374+ color_space);
3375
3376 color_space = map_nvctrl_value_to_table(ctk_color_controls,
3377 color_space);
3378@@ -444,15 +491,13 @@
3379 return;
3380 }
3381
3382- NvCtrlSetDisplayAttribute(ctk_color_controls->handle,
3383- ctk_color_controls->display_device_mask,
3384- NV_CTRL_COLOR_SPACE,
3385- NV_CTRL_COLOR_SPACE_RGB);
3386+ NvCtrlSetAttribute(ctk_color_controls->handle,
3387+ NV_CTRL_COLOR_SPACE,
3388+ NV_CTRL_COLOR_SPACE_RGB);
3389
3390- NvCtrlSetDisplayAttribute(ctk_color_controls->handle,
3391- ctk_color_controls->display_device_mask,
3392- NV_CTRL_COLOR_RANGE,
3393- NV_CTRL_COLOR_RANGE_FULL);
3394+ NvCtrlSetAttribute(ctk_color_controls->handle,
3395+ NV_CTRL_COLOR_RANGE,
3396+ NV_CTRL_COLOR_RANGE_FULL);
3397
3398 ctk_color_controls_setup(ctk_color_controls);
3399 } /* ctk_color_controls_reset() */
3400@@ -487,14 +532,8 @@
3401 CtkColorControls *ctk_object = CTK_COLOR_CONTROLS(user_data);
3402 CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
3403
3404- /* if the event is not for this display device, return */
3405-
3406- if (!(event_struct->display_mask & ctk_object->display_device_mask)) {
3407- return;
3408- }
3409-
3410 ctk_color_controls_setup(ctk_object);
3411-
3412+
3413 /* update status bar message */
3414 switch (event_struct->attribute) {
3415 case NV_CTRL_COLOR_RANGE:
3416@@ -557,10 +596,9 @@
3417 GtkWidget *menu, *menu_item;
3418 NVCTRLAttributeValidValuesRec valid;
3419
3420- ret = NvCtrlGetValidDisplayAttributeValues(ctk_color_controls->handle,
3421- ctk_color_controls->display_device_mask,
3422- NV_CTRL_COLOR_RANGE,
3423- &valid);
3424+ ret = NvCtrlGetValidAttributeValues(ctk_color_controls->handle,
3425+ NV_CTRL_COLOR_RANGE,
3426+ &valid);
3427
3428 if (valid.type != ATTRIBUTE_TYPE_INT_BITS) {
3429 return FALSE;
3430@@ -609,9 +647,9 @@
3431
3432 /* color range */
3433 if (NvCtrlSuccess !=
3434- NvCtrlGetDisplayAttribute(ctk_color_controls->handle,
3435- ctk_color_controls->display_device_mask,
3436- NV_CTRL_COLOR_RANGE, &val)) {
3437+ NvCtrlGetAttribute(ctk_color_controls->handle,
3438+ NV_CTRL_COLOR_RANGE,
3439+ &val)) {
3440 val = NV_CTRL_COLOR_RANGE_FULL;
3441 }
3442
3443@@ -628,18 +666,16 @@
3444 (GTK_OPTION_MENU(ctk_color_controls->color_range_menu),
3445 val);
3446
3447- /* If dropdown only has one item, disable it */
3448- if (ctk_color_controls->color_range_table_size > 1) {
3449- gtk_widget_set_sensitive(ctk_color_controls->color_range_menu, True);
3450- } else {
3451- gtk_widget_set_sensitive(ctk_color_controls->color_range_menu, False);
3452- }
3453-
3454 g_signal_handlers_unblock_by_func
3455 (G_OBJECT(ctk_color_controls->color_range_menu),
3456 G_CALLBACK(color_range_menu_changed),
3457 (gpointer) ctk_color_controls);
3458
3459+ /* If dropdown only has one item, disable it */
3460+ if (ctk_color_controls->color_range_table_size <= 1) {
3461+ return FALSE;
3462+ }
3463+
3464 return TRUE;
3465
3466 } /* setup_color_range_dropdown() */
3467
3468=== modified file 'src/gtk+-2.x/ctkcolorcontrols.h'
3469--- src/gtk+-2.x/ctkcolorcontrols.h 2012-02-18 10:21:04 +0000
3470+++ src/gtk+-2.x/ctkcolorcontrols.h 2012-07-30 04:30:25 +0000
3471@@ -55,14 +55,11 @@
3472 NvCtrlAttributeHandle *handle;
3473 CtkConfig *ctk_config;
3474 GtkWidget *reset_button;
3475- GtkWidget *color_controls_main;
3476- GtkWidget *color_space_box;
3477+ GtkWidget *color_controls_box;
3478
3479 GtkWidget *color_range_menu;
3480 GtkWidget *color_space_menu;
3481- GtkWidget *color_current_config;
3482
3483- gint display_device_mask;
3484 gint *color_space_table;
3485 gint color_space_table_size;
3486 gint *color_range_table;
3487@@ -81,7 +78,6 @@
3488 GtkWidget* ctk_color_controls_new (NvCtrlAttributeHandle *,
3489 CtkConfig *, CtkEvent *,
3490 GtkWidget *,
3491- unsigned int display_device_mask,
3492 char *);
3493
3494 void ctk_color_controls_reset (CtkColorControls*);
3495
3496=== modified file 'src/gtk+-2.x/ctkcolorcorrection.c'
3497--- src/gtk+-2.x/ctkcolorcorrection.c 2012-02-18 10:21:04 +0000
3498+++ src/gtk+-2.x/ctkcolorcorrection.c 2012-07-30 04:30:25 +0000
3499@@ -143,6 +143,7 @@
3500 sizeof (CtkColorCorrection),
3501 0, /* n_preallocs */
3502 NULL, /* instance_init */
3503+ NULL /* value_table */
3504 };
3505
3506 ctk_color_correction_type =
3507@@ -903,42 +904,42 @@
3508 switch (p->attr & (ALL_VALUES | ALL_CHANNELS)) {
3509 case (CONTRAST_VALUE | RED_CHANNEL):
3510 set_color_state(ctk_color_correction, CONTRAST,
3511- RED_CHANNEL, p->fval, TRUE); break;
3512+ RED_CHANNEL, p->val.f, TRUE); break;
3513 case (CONTRAST_VALUE | GREEN_CHANNEL):
3514 set_color_state(ctk_color_correction, CONTRAST,
3515- GREEN_CHANNEL, p->fval, TRUE); break;
3516+ GREEN_CHANNEL, p->val.f, TRUE); break;
3517 case (CONTRAST_VALUE | BLUE_CHANNEL):
3518 set_color_state(ctk_color_correction, CONTRAST,
3519- BLUE_CHANNEL, p->fval, TRUE); break;
3520+ BLUE_CHANNEL, p->val.f, TRUE); break;
3521 case (CONTRAST_VALUE | ALL_CHANNELS):
3522 set_color_state(ctk_color_correction, CONTRAST,
3523- ALL_CHANNELS, p->fval, TRUE); break;
3524+ ALL_CHANNELS, p->val.f, TRUE); break;
3525
3526 case (BRIGHTNESS_VALUE | RED_CHANNEL):
3527 set_color_state(ctk_color_correction, BRIGHTNESS,
3528- RED_CHANNEL, p->fval, TRUE); break;
3529+ RED_CHANNEL, p->val.f, TRUE); break;
3530 case (BRIGHTNESS_VALUE | GREEN_CHANNEL):
3531 set_color_state(ctk_color_correction, BRIGHTNESS,
3532- GREEN_CHANNEL, p->fval, TRUE); break;
3533+ GREEN_CHANNEL, p->val.f, TRUE); break;
3534 case (BRIGHTNESS_VALUE | BLUE_CHANNEL):
3535 set_color_state(ctk_color_correction, BRIGHTNESS,
3536- BLUE_CHANNEL, p->fval, TRUE); break;
3537+ BLUE_CHANNEL, p->val.f, TRUE); break;
3538 case (BRIGHTNESS_VALUE | ALL_CHANNELS):
3539 set_color_state(ctk_color_correction, BRIGHTNESS,
3540- ALL_CHANNELS, p->fval, TRUE); break;
3541+ ALL_CHANNELS, p->val.f, TRUE); break;
3542
3543 case (GAMMA_VALUE | RED_CHANNEL):
3544 set_color_state(ctk_color_correction, GAMMA,
3545- RED_CHANNEL, p->fval, TRUE); break;
3546+ RED_CHANNEL, p->val.f, TRUE); break;
3547 case (GAMMA_VALUE | GREEN_CHANNEL):
3548 set_color_state(ctk_color_correction, GAMMA,
3549- GREEN_CHANNEL, p->fval, TRUE); break;
3550+ GREEN_CHANNEL, p->val.f, TRUE); break;
3551 case (GAMMA_VALUE | BLUE_CHANNEL):
3552 set_color_state(ctk_color_correction, GAMMA,
3553- BLUE_CHANNEL, p->fval, TRUE); break;
3554+ BLUE_CHANNEL, p->val.f, TRUE); break;
3555 case (GAMMA_VALUE | ALL_CHANNELS):
3556 set_color_state(ctk_color_correction, GAMMA,
3557- ALL_CHANNELS, p->fval, TRUE); break;
3558+ ALL_CHANNELS, p->val.f, TRUE); break;
3559
3560 default:
3561 goto next_attribute;
3562
3563=== modified file 'src/gtk+-2.x/ctkconfig.c'
3564--- src/gtk+-2.x/ctkconfig.c 2012-02-18 10:21:04 +0000
3565+++ src/gtk+-2.x/ctkconfig.c 2012-07-30 04:30:25 +0000
3566@@ -102,6 +102,7 @@
3567 sizeof (CtkConfig),
3568 0, /* n_preallocs */
3569 NULL, /* instance_init */
3570+ NULL /* value_table */
3571 };
3572
3573 ctk_config_type = g_type_register_static
3574
3575=== modified file 'src/gtk+-2.x/ctkcursorshadow.c'
3576--- src/gtk+-2.x/ctkcursorshadow.c 2012-02-18 10:21:04 +0000
3577+++ src/gtk+-2.x/ctkcursorshadow.c 2012-07-30 04:30:25 +0000
3578@@ -176,6 +176,7 @@
3579 sizeof(CtkCursorShadow),
3580 0, /* n_preallocs */
3581 NULL, /* instance_init */
3582+ NULL /* value_table */
3583 };
3584
3585 ctk_cursor_shadow_type = g_type_register_static
3586
3587=== modified file 'src/gtk+-2.x/ctkcurve.c'
3588--- src/gtk+-2.x/ctkcurve.c 2012-02-18 10:21:04 +0000
3589+++ src/gtk+-2.x/ctkcurve.c 2012-07-30 04:30:25 +0000
3590@@ -68,6 +68,7 @@
3591 sizeof (CtkCurve),
3592 0, /* n_preallocs */
3593 NULL, /* instance_init */
3594+ NULL /* value_table */
3595 };
3596
3597 ctk_curve_type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
3598
3599=== modified file 'src/gtk+-2.x/ctkdisplayconfig-utils.c'
3600--- src/gtk+-2.x/ctkdisplayconfig-utils.c 2012-02-18 10:21:04 +0000
3601+++ src/gtk+-2.x/ctkdisplayconfig-utils.c 2012-07-30 04:30:25 +0000
3602@@ -41,7 +41,7 @@
3603
3604
3605 static void xconfig_update_buffer(GtkWidget *widget, gpointer user_data);
3606-
3607+static gchar *display_pick_config_name(nvDisplayPtr display, int be_generic);
3608
3609
3610
3611@@ -432,6 +432,37 @@
3612 /*****************************************************************************/
3613
3614
3615+/** apply_mode_attribute_token() *************************************
3616+ *
3617+ * Modifies the nvMode structure (pointed to by data) with
3618+ * information from the token-value pair given. Currently accepts
3619+ * stereo (mode) data.
3620+ *
3621+ * Unknown token and/or values are silently ignored.
3622+ *
3623+ **/
3624+static void apply_mode_attribute_token(char *token, char *value, void *data)
3625+{
3626+ nvModePtr mode = (nvModePtr)data;
3627+
3628+ if (!mode || !token || !strlen(token)) {
3629+ return;
3630+ }
3631+
3632+ /* stereo */
3633+ if (!strcasecmp("stereo", token)) {
3634+ if (!strcasecmp("PassiveLeft", value)) {
3635+ mode->passive_stereo_eye = PASSIVE_STEREO_EYE_LEFT;
3636+ } else if (!strcasecmp("PassiveRight", value)) {
3637+ mode->passive_stereo_eye = PASSIVE_STEREO_EYE_RIGHT;
3638+ }
3639+ return;
3640+ }
3641+
3642+} /* apply_mode_attribute_token() */
3643+
3644+
3645+
3646 /** mode_parse() *****************************************************
3647 *
3648 * Converts a mode string (dpy specific part of a metamode) to a
3649@@ -439,9 +470,10 @@
3650 *
3651 * Mode strings have the following format:
3652 *
3653- * "mode_name +X+Y @WxH"
3654+ * "mode_name +X+Y @WxH {token=value, ...}"
3655 *
3656 **/
3657+
3658 nvModePtr mode_parse(nvDisplayPtr display, const char *mode_str)
3659 {
3660 nvModePtr mode;
3661@@ -484,7 +516,7 @@
3662 if (strcmp(mode_str, "NULL")) {
3663 nv_warning_msg("Mode name '%s' does not match any modelines for "
3664 "display device '%s' in modeline '%s'.",
3665- mode_name, display->name, mode_str);
3666+ mode_name, display->logName, mode_str);
3667 }
3668 mode->dim[W] = display->modelines->data.hdisplay;
3669 mode->dim[H] = display->modelines->data.vdisplay;
3670@@ -518,8 +550,29 @@
3671 &(mode->dim[X]), &(mode->dim[Y]));
3672 }
3673
3674+ /* Read extra params */
3675+ else if (*str == '{') {
3676+ const char *end;
3677+ char *tmp;
3678+ str++;
3679+
3680+ end = strchr(str, '}');
3681+ if (!end) goto fail;
3682+
3683+ /* Dupe the string so we can parse it properly */
3684+ tmp = nvstrndup(str, (size_t)(end-str));
3685+ if (!tmp) goto fail;
3686+
3687+ parse_token_value_pairs(tmp, apply_mode_attribute_token, mode);
3688+ free(tmp);
3689+ if (end && (*end == '}')) {
3690+ str = ++end;
3691+ }
3692+ }
3693+
3694 /* Mode parse error - Ack! */
3695 else {
3696+ nv_error_msg("Unknown mode token: %s", str);
3697 str = NULL;
3698 }
3699
3700@@ -567,46 +620,31 @@
3701 {
3702 gchar *mode_str;
3703 gchar *tmp;
3704-
3705+ gchar *flags_str;
3706+ nvDisplayPtr display = mode->display;
3707+ nvScreenPtr screen;
3708+ nvGpuPtr gpu;
3709
3710 /* Make sure the mode has everything it needs to be displayed */
3711- if (!mode || !mode->display || !mode->display->gpu || !mode->metamode) {
3712+ if (!mode || !mode->metamode || !display) {
3713 return NULL;
3714 }
3715
3716-
3717 /* Don't display dummy modes */
3718 if (be_generic && mode->dummy && !mode->modeline) {
3719 return NULL;
3720 }
3721
3722-
3723- /* Only one display, be very generic (no 'CRT:' in metamode) */
3724- if (be_generic && mode->display->gpu->num_displays == 1) {
3725- mode_str = g_strdup("");
3726-
3727- /* If there's more than one CRT/DFP/TV, we can't be generic. */
3728- } else {
3729- int generic = be_generic;
3730-
3731- if ((mode->display->device_mask & 0x000000FF) &&
3732- (mode->display->device_mask !=
3733- (mode->display->gpu->connected_displays & 0x000000FF))) {
3734- generic = 0;
3735- }
3736- if ((mode->display->device_mask & 0x0000FF00) &&
3737- (mode->display->device_mask !=
3738- (mode->display->gpu->connected_displays & 0x0000FF00))) {
3739- generic = 0;
3740- }
3741- if ((mode->display->device_mask & 0x00FF0000) &&
3742- (mode->display->device_mask !=
3743- (mode->display->gpu->connected_displays & 0x00FF0000))) {
3744- generic = 0;
3745- }
3746-
3747- /* Get the display type */
3748- tmp = display_get_type_str(mode->display->device_mask, generic);
3749+ screen = display->screen;
3750+ gpu = display->gpu;
3751+ if (!screen || !gpu) {
3752+ return NULL;
3753+ }
3754+
3755+ /* Pick a suitable display name qualifier */
3756+ mode_str = display_pick_config_name(display, be_generic);
3757+ if (mode_str[0] != '\0') {
3758+ tmp = mode_str;
3759 mode_str = g_strconcat(tmp, ": ", NULL);
3760 g_free(tmp);
3761 }
3762@@ -663,6 +701,42 @@
3763 mode_str = tmp;
3764
3765
3766+ /* Mode Flags */
3767+ flags_str = NULL;
3768+
3769+ /* Passive Stereo Eye */
3770+ if (screen->stereo_supported && screen->stereo == 4) {
3771+ const char *eye;
3772+
3773+ switch (mode->passive_stereo_eye) {
3774+ case PASSIVE_STEREO_EYE_LEFT:
3775+ eye = "PassiveLeft";
3776+ break;
3777+ case PASSIVE_STEREO_EYE_RIGHT:
3778+ eye = "PassiveRight";
3779+ break;
3780+ case 0:
3781+ default:
3782+ eye = NULL;
3783+ break;
3784+ }
3785+
3786+ if (eye) {
3787+ tmp = g_strdup_printf("%s, stereo=%s", (flags_str ? flags_str : ""), eye);
3788+ g_free(flags_str);
3789+ flags_str = tmp;
3790+ }
3791+ }
3792+
3793+ if (flags_str) {
3794+ tmp = g_strdup_printf("%s {%s}",
3795+ mode_str,
3796+ flags_str+2 // Skip the first comma and whitespace
3797+ );
3798+ g_free(mode_str);
3799+ mode_str = tmp;
3800+ }
3801+
3802 return mode_str;
3803
3804 } /* mode_get_str() */
3805@@ -675,56 +749,67 @@
3806 /*****************************************************************************/
3807
3808
3809-/** display_get_type_str() *******************************************
3810- *
3811- * Returns the type name of a display (CRT, CRT-1, DFP ..)
3812- *
3813- * If 'generic' is set to 1, then a generic version of the name is
3814- * returned.
3815- *
3816- **/
3817-gchar *display_get_type_str(unsigned int device_mask, int be_generic)
3818-{
3819- unsigned int bit = 0;
3820- int num;
3821- gchar *name = NULL;
3822- gchar *type_name;
3823-
3824-
3825- /* Get the generic type name of the display */
3826- if (device_mask & 0x000000FF) {
3827- name = g_strdup("CRT");
3828- bit = (device_mask & 0x000000FF);
3829-
3830- } else if (device_mask & 0x0000FF00) {
3831- name = g_strdup("TV");
3832- bit = (device_mask & 0x0000FF00) >> 8;
3833-
3834- } else if (device_mask & 0x00FF0000) {
3835- name = g_strdup("DFP");
3836- bit = (device_mask & 0x00FF0000) >> 16;
3837- }
3838-
3839- if (be_generic || !name) {
3840- return name;
3841- }
3842-
3843- /* Add the specific display number to the name */
3844- num = 0;
3845- while (bit) {
3846- num++;
3847- bit >>= 1;
3848- }
3849- if (num) {
3850- num--;
3851- }
3852-
3853- type_name = g_strdup_printf("%s-%d", name, num);
3854- g_free(name);
3855-
3856- return type_name;
3857-
3858-} /* display_get_type_str() */
3859+/** display_names_match() ********************************************
3860+ *
3861+ * Determines if two (display) names are the same. Returns FALSE if
3862+ * either name is NULL.
3863+ *
3864+ **/
3865+
3866+static Bool display_names_match(const char *name1, const char *name2)
3867+{
3868+ if (!name1 || !name2) {
3869+ return FALSE;
3870+ }
3871+
3872+ return (strcasecmp(name1, name2) == 0) ? TRUE : FALSE;
3873+}
3874+
3875+
3876+
3877+/** display_pick_config_name() ***************************************
3878+ *
3879+ * Returns one of the display's names to be used for writing
3880+ * configuration.
3881+ *
3882+ * If 'generic' is TRUE, then the most generic name possible is
3883+ * returned. This depends on the current existence of other display
3884+ * devices, and the name returned here will not collide with the name
3885+ * of other display devices.
3886+ *
3887+ **/
3888+static gchar *display_pick_config_name(nvDisplayPtr display, int be_generic)
3889+{
3890+ nvDisplayPtr other;
3891+
3892+ /* Be specific */
3893+ if (!be_generic) {
3894+ goto return_specific;
3895+ }
3896+
3897+ /* Only one display, so no need for a qualifier */
3898+ if (display->gpu->num_displays == 1) {
3899+ return g_strdup("");
3900+ }
3901+
3902+ /* Find the best generic name possible. If any display connected to the
3903+ * GPU has the same typeBaseName, then return the typeIdName instead
3904+ */
3905+ for (other = display->gpu->displays; other; other = other->next_on_gpu) {
3906+ if (other == display) continue;
3907+ if (strcmp(other->typeBaseName, display->typeBaseName) == 0) {
3908+ goto return_specific;
3909+ }
3910+ }
3911+
3912+ /* No other display device on the GPU shares the same type basename,
3913+ * so we can use it
3914+ */
3915+ return g_strdup(display->typeBaseName);
3916+
3917+ return_specific:
3918+ return g_strdup(display->typeIdName);
3919+}
3920
3921
3922
3923@@ -896,9 +981,9 @@
3924 */
3925 broken_doublescan_modelines = 1;
3926
3927- ret = NvCtrlGetAttribute(display->gpu->handle,
3928+ ret = NvCtrlGetAttribute(display->handle,
3929 NV_CTRL_ATTR_NV_MAJOR_VERSION, &major);
3930- ret1 = NvCtrlGetAttribute(display->gpu->handle,
3931+ ret1 = NvCtrlGetAttribute(display->handle,
3932 NV_CTRL_ATTR_NV_MINOR_VERSION, &minor);
3933
3934 if ((ret == NvCtrlSuccess) && (ret1 == NvCtrlSuccess) &&
3935@@ -912,17 +997,14 @@
3936
3937
3938 /* Get the validated modelines for the display */
3939- ret = NvCtrlGetBinaryAttribute(display->gpu->handle,
3940- display->device_mask,
3941+ ret = NvCtrlGetBinaryAttribute(display->handle, 0,
3942 NV_CTRL_BINARY_DATA_MODELINES,
3943 (unsigned char **)&modeline_strs, &len);
3944 if (ret != NvCtrlSuccess) {
3945 *err_str = g_strdup_printf("Failed to query modelines of display "
3946- "device 0x%08x '%s'\nconnected to "
3947- "GPU-%d '%s'.",
3948- display->device_mask, display->name,
3949- NvCtrlGetTargetId(display->gpu->handle),
3950- display->gpu->name);
3951+ "device %d '%s'.",
3952+ NvCtrlGetTargetId(display->handle),
3953+ display->logName);
3954 nv_error_msg(*err_str);
3955 goto fail;
3956 }
3957@@ -936,12 +1018,9 @@
3958 if (!modeline) {
3959 *err_str = g_strdup_printf("Failed to parse the following "
3960 "modeline of display device\n"
3961- "0x%08x '%s' connected to GPU-%d "
3962- "'%s':\n\n%s",
3963- display->device_mask,
3964- display->name,
3965- NvCtrlGetTargetId(display->gpu->handle),
3966- display->gpu->name,
3967+ "%d '%s' :\n\n%s",
3968+ NvCtrlGetTargetId(display->handle),
3969+ display->logName,
3970 str);
3971 nv_error_msg(*err_str);
3972 goto fail;
3973@@ -1030,7 +1109,13 @@
3974 if (display) {
3975 display_remove_modes(display);
3976 display_remove_modelines(display);
3977- XFree(display->name);
3978+ XFree(display->logName);
3979+ XFree(display->typeBaseName);
3980+ XFree(display->typeIdName);
3981+ XFree(display->dpGuidName);
3982+ XFree(display->edidHashName);
3983+ XFree(display->targetIdName);
3984+ XFree(display->randrName);
3985 free(display);
3986 }
3987
3988@@ -1040,17 +1125,64 @@
3989
3990
3991 /*****************************************************************************/
3992-/** METAMODE FUNCTIONS *******************************************************/
3993-/*****************************************************************************/
3994-
3995-
3996-
3997-
3998-/*****************************************************************************/
3999 /** SCREEN FUNCTIONS *********************************************************/
4000 /*****************************************************************************/
4001
4002
4003+/** screen_find_named_display() **************************************
4004+ *
4005+ * Finds a display named 'display_name' in the list of displays on the
4006+ * given screen, or NULL if no display matched 'display_name'.
4007+ *
4008+ **/
4009+
4010+static nvDisplayPtr screen_find_named_display(nvScreenPtr screen,
4011+ char *display_name)
4012+{
4013+ nvDisplayPtr display;
4014+ nvDisplayPtr possible_display = NULL;
4015+
4016+ if (!display_name) {
4017+ return NULL;
4018+ }
4019+
4020+ /* Look for exact matches */
4021+ for (display = screen->displays;
4022+ display;
4023+ display = display->next_in_screen) {
4024+
4025+ /* Look for an exact match */
4026+ if (display_names_match(display->typeIdName, display_name)) {
4027+ return display;
4028+ }
4029+ if (display_names_match(display->dpGuidName, display_name)) {
4030+ return display;
4031+ }
4032+ if (display_names_match(display->targetIdName, display_name)) {
4033+ return display;
4034+ }
4035+ if (display_names_match(display->randrName, display_name)) {
4036+ return display;
4037+ }
4038+
4039+ /* Allow matching to generic names, but only return these
4040+ * if no other name matched
4041+ */
4042+ if (!possible_display) {
4043+ if (display_names_match(display->typeBaseName, display_name)) {
4044+ possible_display = display;
4045+ }
4046+ if (display_names_match(display->edidHashName, display_name)) {
4047+ possible_display = display;
4048+ }
4049+ }
4050+ }
4051+
4052+ return possible_display;
4053+}
4054+
4055+
4056+
4057 /** renumber_xscreens() **********************************************
4058 *
4059 * Ensures that the screens are numbered from 0 to (n-1).
4060@@ -1114,7 +1246,6 @@
4061 }
4062 }
4063 }
4064- screen->displays_mask |= display->device_mask;
4065 screen->num_displays++;
4066
4067 } /* screen_link_display() */
4068@@ -1147,7 +1278,6 @@
4069 cur = cur->next_in_screen;
4070 }
4071 }
4072- screen->displays_mask &= ~(display->device_mask);
4073 screen->num_displays--;
4074
4075 display->screen = NULL;
4076@@ -1292,6 +1422,47 @@
4077
4078
4079
4080+ /** mode_strtok() ***************************************************
4081+ *
4082+ * Special strtok function for parsing modes. This function ignores
4083+ * anything between curly braces, including commas when parsing tokens
4084+ * deliminated by commas.
4085+ *
4086+ **/
4087+static char *mode_strtok(char *str)
4088+{
4089+ static char *intStr = NULL;
4090+ char *start;
4091+
4092+ if (str) {
4093+ intStr = str;
4094+ }
4095+
4096+ if (!intStr || *intStr == '\0') {
4097+ return NULL;
4098+ }
4099+
4100+ /* Mark off the next token value */
4101+ start = intStr;
4102+ while (*intStr != '\0') {
4103+ if (*intStr == '{') {
4104+ while (*intStr != '}' && *intStr != '\0') {
4105+ intStr++;
4106+ }
4107+ }
4108+ if (*intStr == ',') {
4109+ *intStr = '\0';
4110+ intStr++;
4111+ break;
4112+ }
4113+ intStr++;
4114+ }
4115+
4116+ return start;
4117+}
4118+
4119+
4120+
4121 /** screen_add_metamode() ********************************************
4122 *
4123 * Parses a metamode string and adds the appropriate modes to the
4124@@ -1342,35 +1513,35 @@
4125 metamode_copy = strdup(metamode_modes);
4126 if (!metamode_copy) goto fail;
4127
4128- for (mode_str_itr = strtok(metamode_copy, ",");
4129+ for (mode_str_itr = mode_strtok(metamode_copy);
4130 mode_str_itr;
4131- mode_str_itr = strtok(NULL, ",")) {
4132+ mode_str_itr = mode_strtok(NULL)) {
4133
4134 nvModePtr mode;
4135- unsigned int device_mask;
4136 nvDisplayPtr display;
4137+ unsigned int display_id;
4138 const char *orig_mode_str = parse_skip_whitespace(mode_str_itr);
4139 const char *mode_str;
4140
4141- /* Parse the display device bitmask from the name */
4142- mode_str = parse_read_display_name(mode_str_itr, &device_mask);
4143+ /* Parse the display device (NV-CONTROL target) id from the name */
4144+ mode_str = parse_read_display_id(mode_str_itr, &display_id);
4145 if (!mode_str) {
4146 nv_warning_msg("Failed to read a display device name on screen %d "
4147- "(on GPU-%d)\nwhile parsing metamode:\n\n'%s'",
4148+ "while parsing metamode:\n\n'%s'",
4149 screen->scrnum,
4150- NvCtrlGetTargetId(screen->gpu->handle),
4151+
4152 orig_mode_str);
4153 continue;
4154 }
4155
4156- /* Match device bitmask to an existing display */
4157- display = gpu_get_display(screen->gpu, device_mask);
4158+ /* Match device id to an existing display */
4159+ display = layout_get_display(screen->layout, display_id);
4160 if (!display) {
4161- nv_warning_msg("Failed to find display device 0x%08x on screen %d "
4162- "(on GPU-%d)\nwhile parsing metamode:\n\n'%s'",
4163- device_mask,
4164+ nv_warning_msg("Failed to find display device %d on screen %d "
4165+ "while parsing metamode:\n\n'%s'",
4166+ display_id,
4167 screen->scrnum,
4168- NvCtrlGetTargetId(screen->gpu->handle),
4169+
4170 orig_mode_str);
4171 continue;
4172 }
4173@@ -1378,10 +1549,10 @@
4174 /* Parse the mode */
4175 mode = mode_parse(display, mode_str);
4176 if (!mode) {
4177- nv_warning_msg("Failed to parse mode '%s'\non screen %d (on GPU-%d)"
4178- "\nfrom metamode:\n\n'%s'",
4179- mode_str, screen->scrnum,
4180- NvCtrlGetTargetId(screen->gpu->handle),
4181+ nv_warning_msg("Failed to parse mode '%s'\non screen %d\n"
4182+ "from metamode:\n\n'%s'",
4183+ mode_str,
4184+ screen->scrnum,
4185 orig_mode_str);
4186 continue;
4187 }
4188@@ -1512,7 +1683,7 @@
4189 * match the top left of the first non-dummy mode
4190 *
4191 **/
4192-void screen_assign_dummy_metamode_positions(nvScreenPtr screen)
4193+static void screen_assign_dummy_metamode_positions(nvScreenPtr screen)
4194 {
4195 nvDisplayPtr display;
4196 nvModePtr ok_mode;
4197@@ -1565,7 +1736,7 @@
4198
4199 /* Get the list of metamodes for the screen */
4200 ret = NvCtrlGetBinaryAttribute(screen->handle, 0,
4201- NV_CTRL_BINARY_DATA_METAMODES,
4202+ NV_CTRL_BINARY_DATA_METAMODES_VERSION_2,
4203 (unsigned char **)&metamode_strs,
4204 &len);
4205 if (ret != NvCtrlSuccess) {
4206@@ -1580,7 +1751,7 @@
4207
4208 /* Get the current metamode for the screen */
4209 ret = NvCtrlGetStringAttribute(screen->handle,
4210- NV_CTRL_STRING_CURRENT_METAMODE,
4211+ NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2,
4212 &cur_metamode_str);
4213 if (ret != NvCtrlSuccess) {
4214 *err_str = g_strdup_printf("Failed to query current metamode of\n"
4215@@ -1700,26 +1871,6 @@
4216 /*****************************************************************************/
4217
4218
4219-/** gpu_get_display() ************************************************
4220- *
4221- * Returns the display with the matching device_mask or NULL if not
4222- * found.
4223- *
4224- **/
4225-nvDisplayPtr gpu_get_display(nvGpuPtr gpu, unsigned int device_mask)
4226-{
4227- nvDisplayPtr display;
4228-
4229- for (display = gpu->displays; display; display = display->next_on_gpu) {
4230- if (display->device_mask == device_mask) return display;
4231- }
4232-
4233- return NULL;
4234-
4235-} /* gpu_get_display() */
4236-
4237-
4238-
4239 /** gpu_remove_and_free_display() ************************************
4240 *
4241 * Removes a display from the GPU and frees it.
4242@@ -1756,7 +1907,6 @@
4243 }
4244 }
4245 }
4246- gpu->connected_displays &= ~(display->device_mask);
4247 gpu->num_displays--;
4248
4249 display_free(display);
4250@@ -1777,7 +1927,6 @@
4251 while (gpu->displays) {
4252 gpu_remove_and_free_display(gpu->displays);
4253 }
4254- gpu->connected_displays = 0;
4255
4256 } /* gpu_remove_displays() */
4257
4258@@ -1808,7 +1957,6 @@
4259 }
4260 }
4261 }
4262- gpu->connected_displays |= display->device_mask;
4263 gpu->num_displays++;
4264
4265 } /* gpu_add_display() */
4266@@ -1857,17 +2005,74 @@
4267 }
4268
4269
4270+
4271+/** display_add_name_from_server() ***********************************
4272+ *
4273+ * Queries and adds the NV-CONTROL name to the display device.
4274+ *
4275+ **/
4276+
4277+static const struct DisplayNameInfoRec {
4278+ int attr;
4279+ Bool canBeNull;
4280+ const char *nameDescription;
4281+ size_t offset;
4282+} DisplayNamesTable[] = {
4283+ { NV_CTRL_STRING_DISPLAY_DEVICE_NAME, FALSE, "Log Name",
4284+ offsetof(nvDisplay, logName) },
4285+ { NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME, FALSE, "Type Base Name",
4286+ offsetof(nvDisplay, typeBaseName) },
4287+ { NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID, FALSE, "Type ID",
4288+ offsetof(nvDisplay, typeIdName) },
4289+ { NV_CTRL_STRING_DISPLAY_NAME_DP_GUID, TRUE, "DP GUID Name",
4290+ offsetof(nvDisplay, dpGuidName) },
4291+ { NV_CTRL_STRING_DISPLAY_NAME_EDID_HASH, TRUE, "EDID Hash Name",
4292+ offsetof(nvDisplay, edidHashName) },
4293+ { NV_CTRL_STRING_DISPLAY_NAME_TARGET_INDEX, FALSE, "Target Index Name",
4294+ offsetof(nvDisplay, targetIdName) },
4295+ { NV_CTRL_STRING_DISPLAY_NAME_RANDR, FALSE, "RandR Name",
4296+ offsetof(nvDisplay, randrName) },
4297+};
4298+
4299+static Bool display_add_name_from_server(nvDisplayPtr display,
4300+ const struct DisplayNameInfoRec *displayNameInfo,
4301+ gchar **err_str)
4302+{
4303+ ReturnStatus ret;
4304+ char *str;
4305+
4306+ ret = NvCtrlGetStringAttribute(display->handle,
4307+ displayNameInfo->attr,
4308+ &str);
4309+ if (ret == NvCtrlSuccess) {
4310+ *((char **)(((char *)display) + displayNameInfo->offset)) = str;
4311+
4312+ } else if (!displayNameInfo->canBeNull) {
4313+ *err_str = g_strdup_printf("Failed to query name '%s' of display "
4314+ "device DPY-%d.",
4315+ displayNameInfo->nameDescription,
4316+ NvCtrlGetTargetId(display->handle));
4317+ nv_error_msg(*err_str);
4318+ return FALSE;
4319+ }
4320+
4321+ return TRUE;
4322+}
4323+
4324+
4325+
4326 /** gpu_add_display_from_server() ************************************
4327 *
4328- * Adds the display with the device mask given to the GPU structure.
4329+ * Adds the display with the device id given to the GPU structure.
4330 *
4331 **/
4332 nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
4333- unsigned int device_mask,
4334+ unsigned int display_id,
4335 gchar **err_str)
4336 {
4337 ReturnStatus ret;
4338 nvDisplayPtr display;
4339+ int i;
4340
4341
4342 /* Create the display structure */
4343@@ -1875,34 +2080,40 @@
4344 if (!display) goto fail;
4345
4346
4347- /* Init the display structure */
4348- display->device_mask = device_mask;
4349+ /* Make an NV-CONTROL handle to talk to the display */
4350+ display->handle =
4351+ NvCtrlAttributeInit(NvCtrlGetDisplayPtr(gpu->handle),
4352+ NV_CTRL_TARGET_TYPE_DISPLAY,
4353+ display_id,
4354+ NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM);
4355+ if (!display->handle) {
4356+ *err_str = g_strdup_printf("Failed to create NV-CONTROL handle for\n"
4357+ "display %d (on GPU-%d).",
4358+ display_id,
4359+ NvCtrlGetTargetId(gpu->handle));
4360+ nv_error_msg(*err_str);
4361+ goto fail;
4362+ }
4363
4364
4365 /* Query the display information */
4366- ret = NvCtrlGetStringDisplayAttribute(gpu->handle,
4367- device_mask,
4368- NV_CTRL_STRING_DISPLAY_DEVICE_NAME,
4369- &(display->name));
4370- if (ret != NvCtrlSuccess) {
4371- *err_str = g_strdup_printf("Failed to query name of display device\n"
4372- "0x%08x connected to GPU-%d '%s'.",
4373- device_mask, NvCtrlGetTargetId(gpu->handle),
4374- gpu->name);
4375- nv_error_msg(*err_str);
4376- goto fail;
4377+ for (i = 0; i < ARRAY_LEN(DisplayNamesTable); i++) {
4378+ if (!display_add_name_from_server(display,
4379+ DisplayNamesTable + i, err_str)) {
4380+ goto fail;
4381+ }
4382 }
4383
4384
4385 /* Query if this display is an SDI display */
4386- ret = NvCtrlGetDisplayAttribute(gpu->handle, device_mask,
4387- NV_CTRL_IS_GVO_DISPLAY,
4388- &(display->is_sdi));
4389+ ret = NvCtrlGetAttribute(display->handle,
4390+ NV_CTRL_IS_GVO_DISPLAY,
4391+ &(display->is_sdi));
4392 if (ret != NvCtrlSuccess) {
4393 nv_warning_msg("Failed to query if display device\n"
4394- "0x%08x connected to GPU-%d '%s' is an\n"
4395+ "%d connected to GPU-%d '%s' is an\n"
4396 "SDI device.",
4397- device_mask, NvCtrlGetTargetId(gpu->handle),
4398+ display_id, NvCtrlGetTargetId(gpu->handle),
4399 gpu->name);
4400 display->is_sdi = FALSE;
4401 }
4402@@ -1995,9 +2206,9 @@
4403
4404 /* Query the modelines for the display device */
4405 if (!display_add_modelines_from_server(display, err_str)) {
4406- nv_warning_msg("Failed to add modelines to display device 0x%08x "
4407+ nv_warning_msg("Failed to add modelines to display device %d "
4408 "'%s'\nconnected to GPU-%d '%s'.",
4409- device_mask, display->name,
4410+ display_id, display->logName,
4411 NvCtrlGetTargetId(gpu->handle), gpu->name);
4412 goto fail;
4413 }
4414@@ -2023,38 +2234,44 @@
4415 static Bool gpu_add_displays_from_server(nvGpuPtr gpu, gchar **err_str)
4416 {
4417 ReturnStatus ret;
4418- unsigned int mask;
4419+ int *pData;
4420+ int len;
4421+ int i;
4422
4423
4424 /* Clean up the GPU list */
4425 gpu_remove_displays(gpu);
4426
4427-
4428- /* Get the list of connected displays */
4429- ret = NvCtrlGetAttribute(gpu->handle, NV_CTRL_CONNECTED_DISPLAYS,
4430- (int *)&(gpu->connected_displays));
4431+ /* Get list of displays connected to this GPU */
4432+ ret = NvCtrlGetBinaryAttribute(gpu->handle, 0,
4433+ NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU,
4434+ (unsigned char **)(&pData), &len);
4435 if (ret != NvCtrlSuccess) {
4436- *err_str = g_strdup_printf("Failed to query connected display "
4437- "devices on GPU-%d '%s'.",
4438- NvCtrlGetTargetId(gpu), gpu->name);
4439+ *err_str = g_strdup_printf("Failed to query list of displays \n"
4440+ "connected to GPU-%d '%s'.",
4441+ NvCtrlGetTargetId(gpu->handle), gpu->name);
4442 nv_error_msg(*err_str);
4443 goto fail;
4444 }
4445
4446-
4447 /* Add each connected display */
4448- for (mask = 1; mask; mask <<= 1) {
4449-
4450- if (!(mask & (gpu->connected_displays))) continue;
4451-
4452- if (!gpu_add_display_from_server(gpu, mask, err_str)) {
4453- nv_warning_msg("Failed to add display device 0x%08x to GPU-%d "
4454+ for (i = 0; i < pData[0]; i++) {
4455+ if (!gpu_add_display_from_server(gpu, pData[i+1], err_str)) {
4456+ nv_warning_msg("Failed to add display device %d to GPU-%d "
4457+
4458+
4459+
4460+
4461+
4462 "'%s'.",
4463- mask, NvCtrlGetTargetId(gpu->handle), gpu->name);
4464+ pData[i+1], NvCtrlGetTargetId(gpu->handle),
4465+ gpu->name);
4466+ XFree(pData);
4467 goto fail;
4468 }
4469 }
4470
4471+ XFree(pData);
4472 return TRUE;
4473
4474 fail:
4475@@ -2508,8 +2725,8 @@
4476 NvCtrlAttributeInit(display,
4477 NV_CTRL_TARGET_TYPE_X_SCREEN,
4478 screen_id,
4479- NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM |
4480- NV_CTRL_ATTRIBUTES_XRANDR_SUBSYSTEM);
4481+ NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM);
4482+
4483 if (!screen->handle) {
4484 *err_str = g_strdup_printf("Failed to create NV-CONTROL handle for\n"
4485 "screen %d.",
4486@@ -2519,6 +2736,15 @@
4487 }
4488
4489
4490+ /* Query the current stereo mode */
4491+ ret = NvCtrlGetAttribute(screen->handle, NV_CTRL_STEREO, &val);
4492+ if (ret == NvCtrlSuccess) {
4493+ screen->stereo_supported = TRUE;
4494+ screen->stereo = val;
4495+ } else {
4496+ screen->stereo_supported = FALSE;
4497+ }
4498+
4499 /* See if the screen supports dynamic twinview */
4500 ret = NvCtrlGetAttribute(screen->handle, NV_CTRL_DYNAMIC_TWINVIEW, &val);
4501 if (ret != NvCtrlSuccess) {
4502@@ -2595,20 +2821,27 @@
4503
4504 /* Query & parse the screen's primary display */
4505 screen->primaryDisplay = NULL;
4506- ret = NvCtrlGetStringDisplayAttribute
4507- (screen->handle,
4508- 0,
4509- NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER,
4510- &primary_str);
4511-
4512- if (ret == NvCtrlSuccess) {
4513- unsigned int device_mask;
4514-
4515- /* Parse the device mask */
4516- parse_read_display_name(primary_str, &device_mask);
4517-
4518- /* Find the matching primary display */
4519- screen->primaryDisplay = gpu_get_display(screen->gpu, device_mask);
4520+ ret = NvCtrlGetStringAttribute(screen->handle,
4521+ NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER,
4522+ &primary_str);
4523+
4524+ if (ret == NvCtrlSuccess && primary_str) {
4525+ char *str;
4526+
4527+ /* The TwinView Xinerana Info Order string may be a comma-separated
4528+ * list of display device names, though we could add full support
4529+ * for ordering these, just keep track of a single display here.
4530+ */
4531+ str = strchr(primary_str, ',');
4532+ if (!str) {
4533+ str = nvstrdup(primary_str);
4534+ } else {
4535+ str = nvstrndup(primary_str, str-primary_str);
4536+ }
4537+ XFree(primary_str);
4538+
4539+ screen->primaryDisplay = screen_find_named_display(screen, str);
4540+ nvfree(str);
4541 }
4542 }
4543
4544@@ -2724,7 +2957,7 @@
4545 {
4546 nvLayoutPtr layout = NULL;
4547 ReturnStatus ret;
4548-
4549+ int tmp;
4550
4551 /* Allocate the layout structure */
4552 layout = (nvLayoutPtr)calloc(1, sizeof(nvLayout));
4553@@ -2744,6 +2977,19 @@
4554 goto fail;
4555 }
4556
4557+ /* does the driver know about NV_CTRL_CURRENT_METAMODE_ID? */
4558+ ret = NvCtrlGetAttribute(handle, NV_CTRL_CURRENT_METAMODE_ID, &tmp);
4559+ if (ret != NvCtrlSuccess) {
4560+ char *displayName = NvCtrlGetDisplayName(handle);
4561+ *err_str = g_strdup_printf("The NVIDIA X driver on %s is not new\n"
4562+ "enough to support the nvidia-settings "
4563+ "Display Configuration page.",
4564+ displayName ? displayName : "this X server");
4565+ free(displayName);
4566+ nv_warning_msg(*err_str);
4567+ goto fail;
4568+ }
4569+
4570 if (!layout_add_gpus_from_server(layout, err_str)) {
4571 nv_warning_msg("Failed to add GPU(s) to layout for display "
4572 "configuration page.");
4573@@ -2807,6 +3053,35 @@
4574
4575
4576
4577+/** layout_get_display() *********************************************
4578+ *
4579+ * Returns the display with the matching display id or NULL if not
4580+ * found.
4581+ *
4582+ **/
4583+nvDisplayPtr layout_get_display(const nvLayoutPtr layout,
4584+ const unsigned int display_id)
4585+{
4586+ nvGpuPtr gpu;
4587+ nvDisplayPtr display;
4588+
4589+ for (gpu = layout->gpus; gpu; gpu = gpu->next_in_layout) {
4590+ for (display = gpu->displays;
4591+ display;
4592+ display = display->next_on_gpu) {
4593+
4594+ if (NvCtrlGetTargetId(display->handle) == display_id) {
4595+ return display;
4596+ }
4597+ }
4598+ }
4599+
4600+ return NULL;
4601+
4602+} /* layout_get_display() */
4603+
4604+
4605+
4606
4607 /*****************************************************************************/
4608 /** XCONFIG FUNCTIONS ********************************************************/
4609
4610=== modified file 'src/gtk+-2.x/ctkdisplayconfig-utils.h'
4611--- src/gtk+-2.x/ctkdisplayconfig-utils.h 2012-02-18 10:21:04 +0000
4612+++ src/gtk+-2.x/ctkdisplayconfig-utils.h 2012-07-30 04:30:25 +0000
4613@@ -59,7 +59,6 @@
4614
4615 /* Display functions */
4616
4617-gchar * display_get_type_str(unsigned int device_mask, int be_generic);
4618 int display_find_closest_mode_matching_modeline(nvDisplayPtr display,
4619 nvModeLinePtr modeline);
4620 Bool display_has_modeline(nvDisplayPtr display, nvModeLinePtr modeline);
4621@@ -82,10 +81,9 @@
4622
4623 /* GPU functions */
4624
4625-nvDisplayPtr gpu_get_display(nvGpuPtr gpu, unsigned int device_mask);
4626 void gpu_remove_and_free_display(nvDisplayPtr display);
4627 nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
4628- unsigned int device_mask,
4629+ unsigned int display_id,
4630 gchar **err_str);
4631
4632 Bool gpu_add_screenless_modes_to_displays(nvGpuPtr gpu);
4633@@ -98,6 +96,8 @@
4634 nvLayoutPtr layout_load_from_server(NvCtrlAttributeHandle *handle,
4635 gchar **err_str);
4636 nvScreenPtr layout_get_a_screen(nvLayoutPtr layout, nvGpuPtr preferred_gpu);
4637+nvDisplayPtr layout_get_display(const nvLayoutPtr layout,
4638+ const unsigned int display_id);
4639 void layout_remove_and_free_screen(nvScreenPtr screen);
4640
4641
4642
4643=== modified file 'src/gtk+-2.x/ctkdisplayconfig.c'
4644--- src/gtk+-2.x/ctkdisplayconfig.c 2012-02-18 10:21:04 +0000
4645+++ src/gtk+-2.x/ctkdisplayconfig.c 2012-07-30 04:30:25 +0000
4646@@ -48,12 +48,19 @@
4647
4648 static void setup_layout_frame(CtkDisplayConfig *ctk_object);
4649
4650+static void setup_selected_item_dropdown(CtkDisplayConfig *ctk_object);
4651+
4652+static void selected_item_changed(GtkWidget *widget, gpointer user_data);
4653+
4654+static void update_selected_page(CtkDisplayConfig *ctk_object);
4655+
4656 static void setup_display_page(CtkDisplayConfig *ctk_object);
4657
4658 static void display_config_changed(GtkWidget *widget, gpointer user_data);
4659 static void display_resolution_changed(GtkWidget *widget, gpointer user_data);
4660 static void display_refresh_changed(GtkWidget *widget, gpointer user_data);
4661-static void display_modelname_changed(GtkWidget *widget, gpointer user_data);
4662+
4663+static void display_stereo_changed(GtkWidget *widget, gpointer user_data);
4664
4665 static void display_position_type_changed(GtkWidget *widget, gpointer user_data);
4666 static void display_position_offset_activate(GtkWidget *widget, gpointer user_data);
4667@@ -71,6 +78,8 @@
4668
4669 static void screen_depth_changed(GtkWidget *widget, gpointer user_data);
4670
4671+static void screen_stereo_changed(GtkWidget *widget, gpointer user_data);
4672+
4673 static void screen_position_type_changed(GtkWidget *widget, gpointer user_data);
4674 static void screen_position_offset_activate(GtkWidget *widget, gpointer user_data);
4675 static void screen_position_relative_changed(GtkWidget *widget, gpointer user_data);
4676@@ -157,12 +166,12 @@
4677 "this option will require restarting your X server. Note that when Xinerama "
4678 "is enabled, resolution changes will also require restarting your X server.";
4679
4680+static const char * __selected_item_help =
4681+"The Selection drop-down allows you to pick which X screen or display device "
4682+"to configure.";
4683
4684 /* Display tooltips */
4685
4686-static const char * __dpy_model_help =
4687-"The Display drop-down allows you to select a desired display device.";
4688-
4689 static const char * __dpy_configuration_mnu_help =
4690 "The Configure drop-down allows you to select the desired configuration "
4691 "for the currently selected display device.";
4692@@ -176,6 +185,11 @@
4693 "for the currently selected display device. Note that the selected "
4694 "resolution may restrict the available refresh rates.";
4695
4696+static const char * __dpy_stereo_help =
4697+"The Display Passive Stereo Eye drop-down allows you to select a desired "
4698+"stereo eye the display should output when Passive Stereo (Mode 4) is "
4699+"selected enabled.";
4700+
4701 static const char * __dpy_position_type_help =
4702 "The Position Type drop-down allows you to set how the selected display "
4703 "device is placed within the X screen. This is only available when "
4704@@ -213,6 +227,10 @@
4705 "The Depth drop-down allows setting of the color quality for the selected "
4706 "screen; changing this option will require restarting your X server.";
4707
4708+static const char * __screen_stereo_help =
4709+"The Stereo Mode drop-down allows setting of the stereo mode for the selected "
4710+"screen; changing this option will require restarting your X server.";
4711+
4712 static const char * __screen_position_type_help =
4713 "The Position Type drop-down appears when two or more display devices are active. "
4714 "This allows you to set how the selected screen "
4715@@ -381,12 +399,7 @@
4716 if (!screen->handle) continue;
4717
4718 g_signal_connect(G_OBJECT(screen->ctk_event),
4719- CTK_EVENT_NAME(NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER),
4720- G_CALLBACK(display_config_attribute_changed),
4721- (gpointer) ctk_object);
4722-
4723- g_signal_connect(G_OBJECT(screen->ctk_event),
4724- CTK_EVENT_NAME(NV_CTRL_ASSOCIATED_DISPLAY_DEVICES),
4725+ CTK_EVENT_NAME(NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER),
4726 G_CALLBACK(display_config_attribute_changed),
4727 (gpointer) ctk_object);
4728
4729@@ -497,33 +510,12 @@
4730
4731 /** update_btn_apply() **************************************************
4732 *
4733- * Updates the apply button's sensitvity (if possible)
4734+ * Updates the apply button's sensitivity
4735 *
4736 **/
4737
4738-void update_btn_apply(CtkDisplayConfig *ctk_object, Bool sensitive)
4739+static void update_btn_apply(CtkDisplayConfig *ctk_object, Bool sensitive)
4740 {
4741- Bool xrandr_available = FALSE;
4742- nvLayoutPtr layout = ctk_object->layout;
4743- nvScreenPtr screen;
4744-
4745-
4746- if (sensitive) {
4747- /* If none of the screens support XRandR, we can't apply */
4748- for (screen = layout->screens;
4749- screen;
4750- screen = screen->next_in_layout) {
4751- if (NvCtrlGetXrandrEventBase(screen->handle) >= 0) {
4752- xrandr_available = TRUE;
4753- break;
4754- }
4755- }
4756-
4757- if (!xrandr_available && !ctk_object->primary_display_changed) {
4758- sensitive = FALSE;
4759- }
4760- }
4761-
4762 gtk_widget_set_sensitive(ctk_object->btn_apply, sensitive);
4763
4764 } /* update_btn_apply() */
4765@@ -697,7 +689,7 @@
4766 GTK_DIALOG_DESTROY_WITH_PARENT,
4767 GTK_MESSAGE_WARNING,
4768 GTK_BUTTONS_NONE,
4769- msg);
4770+ "%s", msg);
4771
4772 gtk_dialog_add_buttons(GTK_DIALOG(dlg),
4773 "Truncate MetaModes",
4774@@ -874,6 +866,7 @@
4775 sizeof(CtkDisplayConfig),
4776 0, /* n_preallocs */
4777 NULL, /* instance_init */
4778+ NULL /* value_table */
4779 };
4780
4781 ctk_display_config_type = g_type_register_static
4782@@ -892,7 +885,7 @@
4783 *
4784 **/
4785
4786-GtkWidget * create_validation_dialog(CtkDisplayConfig *ctk_object)
4787+static GtkWidget * create_validation_dialog(CtkDisplayConfig *ctk_object)
4788 {
4789 GtkWidget *dialog;
4790 GtkWidget *image;
4791@@ -989,7 +982,7 @@
4792 *
4793 **/
4794
4795-GtkWidget * create_validation_apply_dialog(CtkDisplayConfig *ctk_object)
4796+static GtkWidget * create_validation_apply_dialog(CtkDisplayConfig *ctk_object)
4797 {
4798 GtkWidget *dialog;
4799 GtkWidget *image;
4800@@ -1013,7 +1006,7 @@
4801 GTK_DIALOG_DESTROY_WITH_PARENT,
4802 NULL);
4803 ctk_object->dlg_validation_apply = dialog;
4804-
4805+
4806 /* Main horizontal box */
4807 hbox = gtk_hbox_new(FALSE, 5);
4808 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
4809@@ -1024,11 +1017,11 @@
4810 GTK_ICON_SIZE_DIALOG);
4811 gtk_misc_set_alignment(GTK_MISC(image), 0.0f, 0.0f);
4812 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 5);
4813-
4814+
4815 /* Main vertical box */
4816 vbox = gtk_vbox_new(FALSE, 5);
4817 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 5);
4818-
4819+
4820 /* Pack the main message */
4821 str = g_strdup_printf("The current settings cannot be completely applied\n"
4822 "due to one or more of the following reasons:\n"
4823@@ -1047,7 +1040,7 @@
4824 g_free(str);
4825 gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.0f);
4826 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
4827-
4828+
4829 /* Action Buttons */
4830 gtk_dialog_add_button(GTK_DIALOG(dialog), "Apply What Is Possible",
4831 GTK_RESPONSE_ACCEPT);
4832@@ -1129,6 +1122,24 @@
4833
4834
4835
4836+/** update_gui() *****************************************************
4837+ *
4838+ * Sync state of all widgets to reflect current configuration
4839+ *
4840+ **/
4841+
4842+static void update_gui(CtkDisplayConfig *ctk_object)
4843+{
4844+ setup_display_page(ctk_object);
4845+ setup_screen_page(ctk_object);
4846+ setup_selected_item_dropdown(ctk_object);
4847+ update_selected_page(ctk_object);
4848+ setup_layout_frame(ctk_object);
4849+
4850+} /* update_gui() */
4851+
4852+
4853+
4854 /** ctk_display_config_new() *****************************************
4855 *
4856 * Display Configuration widget creation.
4857@@ -1143,14 +1154,17 @@
4858
4859 GtkWidget *banner;
4860 GtkWidget *frame;
4861- GtkWidget *notebook;
4862 GtkWidget *hbox;
4863 GtkWidget *vbox;
4864 GdkScreen *screen;
4865 GtkWidget *label;
4866 GtkWidget *eventbox;
4867+ GtkWidget *hseparator;
4868 GtkRequisition req;
4869
4870+ GSList *labels = NULL;
4871+ GSList *slitem;
4872+ gint max_width;
4873
4874 GtkWidget *menu;
4875 GtkWidget *menu_item;
4876@@ -1286,12 +1300,12 @@
4877 (gpointer) ctk_object);
4878
4879
4880- /* Display model name */
4881- ctk_object->mnu_display_model = gtk_option_menu_new();
4882- ctk_config_set_tooltip(ctk_config, ctk_object->mnu_display_model,
4883- __dpy_model_help);
4884- g_signal_connect(G_OBJECT(ctk_object->mnu_display_model), "changed",
4885- G_CALLBACK(display_modelname_changed),
4886+ /* Selected display/X screen dropdown */
4887+ ctk_object->mnu_selected_item = gtk_option_menu_new();
4888+ ctk_config_set_tooltip(ctk_config, ctk_object->mnu_selected_item,
4889+ __selected_item_help);
4890+ g_signal_connect(G_OBJECT(ctk_object->mnu_selected_item), "changed",
4891+ G_CALLBACK(selected_item_changed),
4892 (gpointer) ctk_object);
4893
4894 /* Display configuration (Disabled, TwinView, Separate X screen) */
4895@@ -1352,6 +1366,23 @@
4896 ctk_object->txt_display_modename = gtk_label_new("");
4897 gtk_label_set_selectable(GTK_LABEL(ctk_object->txt_display_modename), TRUE);
4898
4899+ /* Display passive stereo eye dropdown */
4900+ ctk_object->mnu_display_stereo = gtk_option_menu_new();
4901+ menu = gtk_menu_new();
4902+ menu_item = gtk_menu_item_new_with_label("None");
4903+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4904+ menu_item = gtk_menu_item_new_with_label("Left");
4905+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4906+ menu_item = gtk_menu_item_new_with_label("Right");
4907+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4908+ gtk_option_menu_set_menu
4909+ (GTK_OPTION_MENU(ctk_object->mnu_display_stereo), menu);
4910+ ctk_config_set_tooltip(ctk_config, ctk_object->mnu_display_stereo,
4911+ __dpy_stereo_help);
4912+ g_signal_connect(G_OBJECT(ctk_object->mnu_display_stereo),
4913+ "changed", G_CALLBACK(display_stereo_changed),
4914+ (gpointer) ctk_object);
4915+
4916 /* Display Position Type (Absolute/Relative Menu) */
4917 ctk_object->mnu_display_position_type = gtk_option_menu_new();
4918 menu = gtk_menu_new();
4919@@ -1404,11 +1435,6 @@
4920 G_CALLBACK(display_panning_focus_out),
4921 (gpointer) ctk_object);
4922
4923- /* X screen number */
4924- ctk_object->txt_screen_num = gtk_label_new("");
4925- gtk_label_set_selectable(GTK_LABEL(ctk_object->txt_screen_num), TRUE);
4926- gtk_misc_set_alignment(GTK_MISC(ctk_object->txt_screen_num), 0.0f, 0.5f);
4927-
4928 /* X screen virtual size */
4929 ctk_object->txt_screen_virtual_size = gtk_entry_new();
4930 ctk_config_set_tooltip(ctk_config, ctk_object->txt_screen_virtual_size,
4931@@ -1429,6 +1455,41 @@
4932 G_CALLBACK(screen_depth_changed),
4933 (gpointer) ctk_object);
4934
4935+ /* Screen Stereo Mode */
4936+ ctk_object->mnu_screen_stereo = gtk_option_menu_new();
4937+ menu = gtk_menu_new();
4938+ menu_item = gtk_menu_item_new_with_label("Disabled");
4939+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4940+ menu_item = gtk_menu_item_new_with_label("DCC Glasses");
4941+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4942+ menu_item = gtk_menu_item_new_with_label("BlueLine Glasses");
4943+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4944+ menu_item = gtk_menu_item_new_with_label("Onboard (DIN)");
4945+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4946+ menu_item = gtk_menu_item_new_with_label("Passive Eye Per Display");
4947+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4948+ menu_item = gtk_menu_item_new_with_label("Vertical Interlaced");
4949+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4950+ menu_item = gtk_menu_item_new_with_label("Color Interleaved");
4951+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4952+ menu_item = gtk_menu_item_new_with_label("Horizontal Interlaced");
4953+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4954+ menu_item = gtk_menu_item_new_with_label("Checkerboard 3D DLP");
4955+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4956+ menu_item = gtk_menu_item_new_with_label("Inverse Checkerboard 3D DLP");
4957+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4958+ menu_item = gtk_menu_item_new_with_label("NVIDIA 3D Vision");
4959+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4960+ menu_item = gtk_menu_item_new_with_label("NVIDIA 3D Vision Pro");
4961+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
4962+ gtk_option_menu_set_menu
4963+ (GTK_OPTION_MENU(ctk_object->mnu_screen_stereo), menu);
4964+ ctk_config_set_tooltip(ctk_config, ctk_object->mnu_screen_stereo,
4965+ __screen_stereo_help);
4966+ g_signal_connect(G_OBJECT(ctk_object->mnu_screen_stereo),
4967+ "changed", G_CALLBACK(screen_stereo_changed),
4968+ (gpointer) ctk_object);
4969+
4970 /* Screen Position Type (Absolute/Relative Menu) */
4971 ctk_object->mnu_screen_position_type = gtk_option_menu_new();
4972 menu = gtk_menu_new();
4973@@ -1599,14 +1660,6 @@
4974 G_CALLBACK(save_clicked),
4975 (gpointer) ctk_object);
4976
4977-
4978-
4979- /****
4980- *
4981- * Pack the widgets
4982- *
4983- ***/
4984-
4985 { /* Layout section */
4986
4987 frame = gtk_frame_new("Layout"); /* main panel */
4988@@ -1624,52 +1677,42 @@
4989 gtk_box_pack_start(GTK_BOX(vbox), ctk_object->chk_xinerama_enabled,
4990 FALSE, FALSE, 0);
4991 }
4992-
4993-
4994- /* Panel for the notebook sections */
4995- notebook = gtk_notebook_new();
4996- ctk_object->notebook = notebook;
4997- gtk_box_pack_start(GTK_BOX(ctk_object), notebook, FALSE, FALSE, 0);
4998+
4999+
5000+ /* Selection */
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches