summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2014-11-13 08:51:31 -0800
committerAaron Plattner <aplattner@nvidia.com>2014-11-13 08:51:31 -0800
commit0b72534304615d6171d3111b2e9b1999a5c1b2df (patch)
tree27c92abb8a2ae1c3c1d711eeeed4234a0053a889
parent6101dbee74c1a2997e8ca0f24ea59dd38ab79b46 (diff)
346.16346.16
-rw-r--r--doc/version.mk2
-rw-r--r--samples/nv-control-dpy.c57
-rw-r--r--samples/nv-control-events.c8
-rw-r--r--samples/nv-control-framelock.c16
-rw-r--r--samples/nv-control-gvi.c32
-rw-r--r--samples/nv-control-info.c8
-rw-r--r--samples/nv-control-warpblend.h15
-rw-r--r--samples/version.mk2
-rw-r--r--src/Makefile133
-rw-r--r--src/XF86Config-parser/Generate.c18
-rw-r--r--src/app-profiles.c58
-rw-r--r--src/command-line.c59
-rw-r--r--src/command-line.h18
-rw-r--r--src/common-utils/common-utils.c98
-rw-r--r--src/common-utils/common-utils.h5
-rw-r--r--src/common-utils/nvgetopt.c16
-rw-r--r--src/config-file.c175
-rw-r--r--src/config-file.h6
-rw-r--r--src/glxinfo.c49
-rw-r--r--src/glxinfo.h2
-rw-r--r--src/gtk+-2.x/ctk3dvisionpro.c216
-rw-r--r--src/gtk+-2.x/ctk3dvisionpro.h7
-rw-r--r--src/gtk+-2.x/ctkappprofile.c65
-rw-r--r--src/gtk+-2.x/ctkappprofile.h5
-rw-r--r--src/gtk+-2.x/ctkbanner.c13
-rw-r--r--src/gtk+-2.x/ctkclocks.c1343
-rw-r--r--src/gtk+-2.x/ctkclocks.h96
-rw-r--r--src/gtk+-2.x/ctkcolorcontrols.c48
-rw-r--r--src/gtk+-2.x/ctkcolorcontrols.h4
-rw-r--r--src/gtk+-2.x/ctkcolorcorrection.c50
-rw-r--r--src/gtk+-2.x/ctkcolorcorrection.h4
-rw-r--r--src/gtk+-2.x/ctkcolorcorrectionpage.c10
-rw-r--r--src/gtk+-2.x/ctkcolorcorrectionpage.h6
-rw-r--r--src/gtk+-2.x/ctkconfig.c41
-rw-r--r--src/gtk+-2.x/ctkconfig.h6
-rw-r--r--src/gtk+-2.x/ctkcurve.c17
-rw-r--r--src/gtk+-2.x/ctkcurve.h4
-rw-r--r--src/gtk+-2.x/ctkdisplayconfig-utils.c503
-rw-r--r--src/gtk+-2.x/ctkdisplayconfig-utils.h8
-rw-r--r--src/gtk+-2.x/ctkdisplayconfig.c174
-rw-r--r--src/gtk+-2.x/ctkdisplayconfig.h5
-rw-r--r--src/gtk+-2.x/ctkdisplaydevice.c72
-rw-r--r--src/gtk+-2.x/ctkdisplaydevice.h5
-rw-r--r--src/gtk+-2.x/ctkdisplaylayout.c10
-rw-r--r--src/gtk+-2.x/ctkdisplaylayout.h14
-rw-r--r--src/gtk+-2.x/ctkditheringcontrols.c80
-rw-r--r--src/gtk+-2.x/ctkditheringcontrols.h4
-rw-r--r--src/gtk+-2.x/ctkecc.c76
-rw-r--r--src/gtk+-2.x/ctkecc.h5
-rw-r--r--src/gtk+-2.x/ctkedid.c158
-rw-r--r--src/gtk+-2.x/ctkedid.h4
-rw-r--r--src/gtk+-2.x/ctkevent.c531
-rw-r--r--src/gtk+-2.x/ctkevent.h19
-rw-r--r--src/gtk+-2.x/ctkframelock.c585
-rw-r--r--src/gtk+-2.x/ctkframelock.h8
-rw-r--r--src/gtk+-2.x/ctkglx.c408
-rw-r--r--src/gtk+-2.x/ctkglx.h5
-rw-r--r--src/gtk+-2.x/ctkgpu.c121
-rw-r--r--src/gtk+-2.x/ctkgpu.h12
-rw-r--r--src/gtk+-2.x/ctkgvi.c82
-rw-r--r--src/gtk+-2.x/ctkgvi.h6
-rw-r--r--src/gtk+-2.x/ctkgvo-banner.c75
-rw-r--r--src/gtk+-2.x/ctkgvo-banner.h5
-rw-r--r--src/gtk+-2.x/ctkgvo-csc.c68
-rw-r--r--src/gtk+-2.x/ctkgvo-csc.h6
-rw-r--r--src/gtk+-2.x/ctkgvo-sync.c132
-rw-r--r--src/gtk+-2.x/ctkgvo-sync.h6
-rw-r--r--src/gtk+-2.x/ctkgvo.c73
-rw-r--r--src/gtk+-2.x/ctkgvo.h6
-rw-r--r--src/gtk+-2.x/ctkimagesliders.c61
-rw-r--r--src/gtk+-2.x/ctkimagesliders.h4
-rw-r--r--src/gtk+-2.x/ctkmultisample.c213
-rw-r--r--src/gtk+-2.x/ctkmultisample.h7
-rw-r--r--src/gtk+-2.x/ctkopengl.c248
-rw-r--r--src/gtk+-2.x/ctkopengl.h7
-rw-r--r--src/gtk+-2.x/ctkpowermizer.c128
-rw-r--r--src/gtk+-2.x/ctkpowermizer.h7
-rw-r--r--src/gtk+-2.x/ctkscreen.c94
-rw-r--r--src/gtk+-2.x/ctkscreen.h7
-rw-r--r--src/gtk+-2.x/ctkserver.c65
-rw-r--r--src/gtk+-2.x/ctkserver.h3
-rw-r--r--src/gtk+-2.x/ctkslimm.c50
-rw-r--r--src/gtk+-2.x/ctkslimm.h5
-rw-r--r--src/gtk+-2.x/ctkthermal.c172
-rw-r--r--src/gtk+-2.x/ctkthermal.h13
-rw-r--r--src/gtk+-2.x/ctkui.c13
-rw-r--r--src/gtk+-2.x/ctkui.h2
-rw-r--r--src/gtk+-2.x/ctkutils.c240
-rw-r--r--src/gtk+-2.x/ctkutils.h28
-rw-r--r--src/gtk+-2.x/ctkvcs.c51
-rw-r--r--src/gtk+-2.x/ctkvcs.h4
-rw-r--r--src/gtk+-2.x/ctkvdpau.c14
-rw-r--r--src/gtk+-2.x/ctkvdpau.h4
-rw-r--r--src/gtk+-2.x/ctkwindow.c305
-rw-r--r--src/gtk+-2.x/ctkwindow.h2
-rw-r--r--src/gtk+-2.x/ctkxvideo.c81
-rw-r--r--src/gtk+-2.x/ctkxvideo.h6
-rw-r--r--src/libXNVCtrl/NVCtrl.h440
-rw-r--r--src/libXNVCtrl/utils.mk90
-rw-r--r--src/libXNVCtrl/version.mk2
-rw-r--r--src/libXNVCtrlAttributes/NvCtrlAttributes.c1079
-rw-r--r--src/libXNVCtrlAttributes/NvCtrlAttributes.h484
-rw-r--r--src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c26
-rw-r--r--src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c293
-rw-r--r--src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c191
-rw-r--r--src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h115
-rw-r--r--src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c1097
-rw-r--r--src/libXNVCtrlAttributes/NvCtrlAttributesVidMode.c24
-rw-r--r--src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c32
-rw-r--r--src/libXNVCtrlAttributes/NvCtrlAttributesXv.c11
-rw-r--r--src/nvidia-settings.c306
-rw-r--r--src/option-table.h19
-rw-r--r--src/parse.c179
-rw-r--r--src/parse.h84
-rw-r--r--src/query-assign.c1768
-rw-r--r--src/query-assign.h91
-rw-r--r--src/src.mk9
-rw-r--r--src/version.h1
-rw-r--r--src/version.mk2
-rw-r--r--utils.mk90
-rw-r--r--version.mk2
121 files changed, 7217 insertions, 7030 deletions
diff --git a/doc/version.mk b/doc/version.mk
index 66ba96f..14c4194 100644
--- a/doc/version.mk
+++ b/doc/version.mk
@@ -1 +1 @@
-NVIDIA_VERSION = 343.22
+NVIDIA_VERSION = 346.16
diff --git a/samples/nv-control-dpy.c b/samples/nv-control-dpy.c
index 87e28dd..0e381fa 100644
--- a/samples/nv-control-dpy.c
+++ b/samples/nv-control-dpy.c
@@ -44,7 +44,7 @@
static char *remove_whitespace(char *str);
static char *mode_strtok(char *str);
-static void parse_mode_string(char *modeString, char **modeName,
+static Bool parse_mode_string(char *modeString, char **modeName,
int *dpyId);
static char *find_modeline(char *modeString, char *pModeLines,
int ModeLineLen);
@@ -69,6 +69,22 @@ static void print_display_name(Display *dpy, int target_id, int attr,
XFree(str);
}
+static void print_display_id_and_name(Display *dpy, int target_id,
+ const char *tab)
+{
+ char name_str[64];
+ int len;
+
+ len = snprintf(name_str, sizeof(name_str), "%sDPY-%d", tab, target_id);
+
+ if ((len < 0) || (len >= sizeof(name_str))) {
+ return;
+ }
+
+ print_display_name(dpy, target_id, NV_CTRL_STRING_DISPLAY_DEVICE_NAME,
+ name_str);
+}
+
int main(int argc, char *argv[])
{
Display *dpy;
@@ -124,15 +140,7 @@ int main(int argc, char *argv[])
for (i = 0; i < enabledDpyIds[0]; i++) {
int dpyId = enabledDpyIds[i+1];
- XNVCTRLQueryTargetStringAttribute(dpy,
- NV_CTRL_TARGET_TYPE_DISPLAY,
- dpyId,
- 0,
- NV_CTRL_STRING_DISPLAY_DEVICE_NAME,
- &str);
-
- printf(" DPY-%d : %s\n", dpyId, str);
- XFree(str);
+ print_display_id_and_name(dpy, dpyId, " ");
}
printf("\n");
@@ -837,15 +845,7 @@ int main(int argc, char *argv[])
for (j = 0; j < pData[0]; j++) {
int dpyId = pData[j+1];
- XNVCTRLQueryTargetStringAttribute(dpy,
- NV_CTRL_TARGET_TYPE_DISPLAY,
- dpyId,
- 0,
- NV_CTRL_STRING_DISPLAY_DEVICE_NAME,
- &str);
-
- printf(" DPY-%d : %s\n", dpyId, str);
- XFree(str);
+ print_display_id_and_name(dpy, dpyId, " ");
}
printf("\n");
@@ -1040,7 +1040,12 @@ int main(int argc, char *argv[])
* for this segment of the Metamode
*/
- parse_mode_string(modeString, &modeName, &dpyId);
+ if (!parse_mode_string(modeString, &modeName, &dpyId)) {
+ fprintf(stderr, " Failed to parse mode string '%s'."
+ "\n\n",
+ modeString);
+ continue;
+ }
/* lookup the modeline that matches */
@@ -1292,12 +1297,15 @@ static char *mode_strtok(char *str)
* id for the per-display device MetaMode string in 'modeString'
*/
-static void parse_mode_string(char *modeString, char **modeName,
- int *dpyId)
+static Bool parse_mode_string(char *modeString, char **modeName,
+ int *dpyId)
{
char *colon, *s, tmp;
colon = strchr(modeString, ':');
+ if (!colon) {
+ return False;
+ }
*colon = '\0';
*dpyId = strtol(modeString+4, NULL, 0);
*colon = ':';
@@ -1319,8 +1327,9 @@ static void parse_mode_string(char *modeString, char **modeName,
*s = '\0';
*modeName = strdup(modeString);
*s = tmp;
-
-} /* parse_mode_string() */
+
+ return True;
+}
diff --git a/samples/nv-control-events.c b/samples/nv-control-events.c
index 34e6310..9265990 100644
--- a/samples/nv-control-events.c
+++ b/samples/nv-control-events.c
@@ -564,15 +564,7 @@ static AttrEntry attr_table[] = {
MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH),
MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_HEIGHT),
MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE),
- MAKE_ENTRY(NV_CTRL_GPU_OVERCLOCKING_STATE),
- MAKE_ENTRY(NV_CTRL_GPU_2D_CLOCK_FREQS),
- MAKE_ENTRY(NV_CTRL_GPU_3D_CLOCK_FREQS),
- MAKE_ENTRY(NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS),
- MAKE_ENTRY(NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS),
MAKE_ENTRY(NV_CTRL_GPU_CURRENT_CLOCK_FREQS),
- MAKE_ENTRY(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS),
- MAKE_ENTRY(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION),
- MAKE_ENTRY(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE),
MAKE_ENTRY(NV_CTRL_FLATPANEL_CHIP_LOCATION),
MAKE_ENTRY(NV_CTRL_FLATPANEL_LINK),
MAKE_ENTRY(NV_CTRL_FLATPANEL_SIGNAL),
diff --git a/samples/nv-control-framelock.c b/samples/nv-control-framelock.c
index dd3ffe3..8163215 100644
--- a/samples/nv-control-framelock.c
+++ b/samples/nv-control-framelock.c
@@ -341,12 +341,16 @@ static void do_enable(Display *dpy)
/* Make sure frame lock is disabled */
- XNVCTRLQueryTargetAttribute(dpy,
- NV_CTRL_TARGET_TYPE_GPU,
- gpu, // target_id
- 0, // display_mask
- NV_CTRL_FRAMELOCK_SYNC,
- &enabled);
+ ret = XNVCTRLQueryTargetAttribute(dpy,
+ NV_CTRL_TARGET_TYPE_GPU,
+ gpu, // target_id
+ 0, // display_mask
+ NV_CTRL_FRAMELOCK_SYNC,
+ &enabled);
+ if (!ret) {
+ printf(" - Failed to query Frame lock state.\n");
+ continue;
+ }
if (enabled != NV_CTRL_FRAMELOCK_SYNC_DISABLE) {
printf(" - Frame lock already enabled!\n");
continue;
diff --git a/samples/nv-control-gvi.c b/samples/nv-control-gvi.c
index c5a0d91..7b12b3c 100644
--- a/samples/nv-control-gvi.c
+++ b/samples/nv-control-gvi.c
@@ -125,13 +125,13 @@ static char *VideoFormatName(int value)
static const char *SamplingName(int value)
{
switch (value) {
- default:
ADD_NVCTRL_CASE(NV_CTRL_GVI_COMPONENT_SAMPLING_UNKNOWN);
ADD_NVCTRL_CASE(NV_CTRL_GVI_COMPONENT_SAMPLING_4444);
ADD_NVCTRL_CASE(NV_CTRL_GVI_COMPONENT_SAMPLING_4224);
ADD_NVCTRL_CASE(NV_CTRL_GVI_COMPONENT_SAMPLING_444);
ADD_NVCTRL_CASE(NV_CTRL_GVI_COMPONENT_SAMPLING_422);
ADD_NVCTRL_CASE(NV_CTRL_GVI_COMPONENT_SAMPLING_420);
+ default:
return "Invalid Value";
}
}
@@ -481,11 +481,11 @@ static void do_query(Display *dpy, int use_gvi)
NV_CTRL_STRING_OPERATION_GVI_CONFIGURE_STREAMS,
NULL, // pIn
&pOut);
- if (!ret || !pOut) {
+ if (!ret) {
printf(" - Failed to query stream topology configuration of "
"GVI %d.\n", gvi);
continue;
- }
+ }
printf(" - Topology:\n");
printf("\n %s\n\n", pOut ? pOut : "No streams are configured.");
@@ -547,11 +547,10 @@ static void do_query(Display *dpy, int use_gvi)
i++;
str++;
}
+ XFree(pOut);
+ pOut = NULL;
}
- XFree(pOut);
- pOut = NULL;
-
} /* Done Querying information about GVI devices */
} /* do_query() */
@@ -588,16 +587,17 @@ static void do_listconfig(Display *dpy, int gvi)
NV_CTRL_STRING_OPERATION_GVI_CONFIGURE_STREAMS,
NULL, // pIn
&pOut);
- if (!ret || !pOut) {
+ if (!ret) {
printf(" - Failed to query stream topology configuration of "
"GVI %d.\n", gvi);
return;
- }
+ }
printf("- Current Topology:\n\n");
printf(" %s\n\n", pOut ? pOut : "No streams are configured.");
- XFree(pOut);
- pOut = NULL;
-
+ if (pOut) {
+ XFree(pOut);
+ pOut = NULL;
+ }
ret = XNVCTRLQueryValidTargetAttributeValues(dpy,
NV_CTRL_TARGET_TYPE_GVI,
@@ -788,15 +788,17 @@ static void do_configure(Display *dpy, int use_gvi, char *pIn)
NV_CTRL_STRING_OPERATION_GVI_CONFIGURE_STREAMS,
pIn,
&pOut);
- if (!ret || !pOut) {
+ if (!ret) {
printf(" - Failed to configure stream topology of GVI %d.\n",
use_gvi);
return;
- }
+ }
printf("Topology:\n\n");
printf(" %s\n\n", pOut ? pOut : "No streams are configured.");
- XFree(pOut);
- pOut = NULL;
+ if (pOut) {
+ XFree(pOut);
+ pOut = NULL;
+ }
}
diff --git a/samples/nv-control-info.c b/samples/nv-control-info.c
index bb57515..fbaab54 100644
--- a/samples/nv-control-info.c
+++ b/samples/nv-control-info.c
@@ -147,15 +147,7 @@ static AttrEntry attr_int_table[] = {
MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH),
MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_HEIGHT),
MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE),
- MAKE_ENTRY(NV_CTRL_GPU_OVERCLOCKING_STATE),
- MAKE_ENTRY(NV_CTRL_GPU_2D_CLOCK_FREQS),
- MAKE_ENTRY(NV_CTRL_GPU_3D_CLOCK_FREQS),
- MAKE_ENTRY(NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS),
- MAKE_ENTRY(NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS),
MAKE_ENTRY(NV_CTRL_GPU_CURRENT_CLOCK_FREQS),
- MAKE_ENTRY(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS),
- MAKE_ENTRY(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION),
- MAKE_ENTRY(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE),
MAKE_ENTRY(NV_CTRL_FLATPANEL_CHIP_LOCATION),
MAKE_ENTRY(NV_CTRL_FLATPANEL_LINK),
MAKE_ENTRY(NV_CTRL_FLATPANEL_SIGNAL),
diff --git a/samples/nv-control-warpblend.h b/samples/nv-control-warpblend.h
index 4550e06..e403db8 100644
--- a/samples/nv-control-warpblend.h
+++ b/samples/nv-control-warpblend.h
@@ -152,6 +152,7 @@ RemoveAttributeFromDisplayOfCurrentMetaMode(
char *newMetaMode = NULL;
int error = 1;
int attributeLen;
+ Bool ret;
if (!attribute) {
goto cleanup;
@@ -159,11 +160,15 @@ RemoveAttributeFromDisplayOfCurrentMetaMode(
attributeLen = strlen(attribute);
- XNVCTRLQueryStringAttribute(xDpy,
- screenId,
- 0, // displayMask
- NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2,
- &pOldCurrentMetaMode);
+ ret = XNVCTRLQueryStringAttribute(xDpy,
+ screenId,
+ 0, // displayMask
+ NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2,
+ &pOldCurrentMetaMode);
+
+ if (!ret || !pOldCurrentMetaMode) {
+ goto cleanup;
+ }
// Discard the metadata from the beginning of the MetaMode.
pCurrentMetaMode = strstr(pOldCurrentMetaMode, "::");
diff --git a/samples/version.mk b/samples/version.mk
index 66ba96f..14c4194 100644
--- a/samples/version.mk
+++ b/samples/version.mk
@@ -1 +1 @@
-NVIDIA_VERSION = 343.22
+NVIDIA_VERSION = 346.16
diff --git a/src/Makefile b/src/Makefile
index 7471d7d..82d38cb 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -44,12 +44,34 @@ X_CFLAGS ?=
PKG_CONFIG ?= pkg-config
-ifndef GTK_CFLAGS
- GTK_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-2.0)
+ifndef GTK2_CFLAGS
+ GTK2_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-2.0)
endif
-ifndef GTK_LDFLAGS
- GTK_LDFLAGS := $(shell $(PKG_CONFIG) --libs gtk+-2.0)
+ifndef GTK2_LDFLAGS
+ GTK2_LDFLAGS := -Wl,--no-as-needed $(shell $(PKG_CONFIG) --libs gtk+-2.0)
+endif
+
+ifndef GTK3_AVAILABLE
+ GTK3_AVAILABLE := $(shell $(PKG_CONFIG) --exists gtk+-3.0 && echo 1)
+endif
+
+ifeq (1,$(GTK3_AVAILABLE))
+ ifndef GTK3_CFLAGS
+ GTK3_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-3.0)
+ endif
+
+ ifndef GTK3_LDFLAGS
+ GTK3_LDFLAGS := -Wl,--no-as-needed $(shell $(PKG_CONFIG) --libs gtk+-3.0)
+ endif
+else
+ GTK3_CFLAGS ?=
+ GTK3_LDFLAGS ?=
+endif
+
+# If GTK3_CFLAGS is set, try and build GTK3LIB
+ifdef GTK3_CFLAGS
+ BUILD_GTK3LIB = 1
endif
ifndef VDPAU_CFLAGS
@@ -99,15 +121,47 @@ NVIDIA_SETTINGS_PROGRAM_NAME = "nvidia-settings"
NVIDIA_SETTINGS_VERSION := $(NVIDIA_VERSION)
+GTK2LIB_NAME = libnvidia-gtk2.so
+GTK2LIB_DIR = $(OUTPUTDIR)/gtk2
+GTK2LIB = $(OUTPUTDIR)/$(GTK2LIB_NAME)
+GTK2LIB_SONAME = $(GTK2LIB_NAME).$(NVIDIA_SETTINGS_VERSION)
+
+ifdef BUILD_GTK3LIB
+ GTK3LIB_NAME = libnvidia-gtk3.so
+ GTK3LIB_DIR = $(OUTPUTDIR)/gtk3
+ GTK3LIB = $(OUTPUTDIR)/$(GTK3LIB_NAME)
+ GTK3LIB_SONAME = $(GTK3LIB_NAME).$(NVIDIA_SETTINGS_VERSION)
+else
+ # This value is empty if we are not building GTK3 so that the
+ # nvidia-settings build step has this as an empty dependency.
+ GTK3LIB =
+endif
+
CFLAGS += $(X_CFLAGS)
ifeq ($(TARGET_OS),SunOS)
- LDFLAGS += -Wl,-rpath=/usr/X11R6/lib
+ LDFLAGS += -Wl,-rpath=/usr/X11R6/lib -Wl,--export-dynamic
LIBS += -lscf
endif
LDFLAGS += $(X_LDFLAGS)
+
+# Link against NVIDIA NVML library if available
+
+# Set to 1 if NVML is available on the target system
+NVML_AVAILABLE ?= 0
+
+ifeq (1,$(NVML_AVAILABLE))
+ # Here "gdk" stands for "GPU Developer Kit", rather than gtk's lower-level
+ # "GIMP Drawing Kit"
+ NVML_CFLAGS ?= -I /usr/include/nvidia/gdk -DNVML_AVAILABLE
+ NVML_LDFLAGS ?=
+ CFLAGS += $(NVML_CFLAGS)
+ LDFLAGS += $(NVML_LDFLAGS)
+ LIBS += -lnvidia-ml
+endif
+
# Some older Linux distributions do not have the dynamic library
# libXxf86vm.so, though some newer Linux distributions do not have the
# static library libXxf86vm.a. Statically link against libXxf86vm
@@ -145,14 +199,17 @@ endif
# $(OBJECTS) on the link commandline, causing libraries for linking to
# be named after the objects that depend on those libraries (needed
# for "--as-needed" linker behavior).
-LIBS += -lX11 -lXext -lm $(LIBDL_LIBS) $(GTK_LDFLAGS)
+LIBS += -lX11 -lXext -lm $(LIBDL_LIBS)
+
+GTK2_LIBS += $(GTK2_LDFLAGS)
+GTK3_LIBS += $(GTK3_LDFLAGS)
# Include all the source lists; dist-files.mk will define NVIDIA_SETTINGS_SRC
include src.mk
SRC += $(NVIDIA_SETTINGS_SRC)
include $(XCONFIG_PARSER_DIR)/src.mk
-SRC += $(addprefix $(XCONFIG_PARSER_DIR)/,$(XCONFIG_PARSER_SRC))
+XCP_SRC += $(addprefix $(XCONFIG_PARSER_DIR)/,$(XCONFIG_PARSER_SRC))
include $(COMMON_UTILS_DIR)/src.mk
SRC += $(addprefix $(COMMON_UTILS_DIR)/,$(COMMON_UTILS_SRC))
@@ -163,6 +220,10 @@ SRC += $(addprefix $(VIRTUAL_RESOLUTIONS_DIR)/,$(VIRTUAL_RESOLUTIONS_SRC)
SRC += $(STAMP_C)
OBJS = $(call BUILD_OBJECT_LIST,$(SRC))
+XCP_OBJS = $(call BUILD_OBJECT_LIST,$(XCP_SRC))
+
+GTK2_OBJS = $(call BUILD_OBJECT_LIST_WITH_DIR,$(GTK_SRC),$(GTK2LIB_DIR))
+GTK3_OBJS = $(call BUILD_OBJECT_LIST_WITH_DIR,$(GTK_SRC),$(GTK3LIB_DIR))
CFLAGS += -I .
CFLAGS += -I image_data
@@ -170,7 +231,6 @@ CFLAGS += -I $(XNVCTRL_DIR)
CFLAGS += -I $(XCONFIG_PARSER_DIR)/..
CFLAGS += -I libXNVCtrlAttributes
CFLAGS += -I xpm_data
-CFLAGS += -I gtk+-2.x
ifneq ($(NV_USE_BUNDLED_LIBJANSSON),0)
CFLAGS += -I jansson
@@ -182,7 +242,15 @@ CFLAGS += -I $(OUTPUTDIR)
CFLAGS += $(VDPAU_CFLAGS)
CFLAGS += -DPROGRAM_NAME=\"nvidia-settings\"
-$(call BUILD_OBJECT_LIST,$(GTK_SRC)): CFLAGS += $(GTK_CFLAGS)
+$(call BUILD_OBJECT_LIST,$(XCP_SRC)): CFLAGS += -fPIC
+
+$(call BUILD_OBJECT_LIST_WITH_DIR,$(GTK_SRC),$(GTK2LIB_DIR)): \
+ CFLAGS += $(GTK2_CFLAGS) -fPIC -I $(XCONFIG_PARSER_DIR)/..
+
+ifdef BUILD_GTK3LIB
+ $(call BUILD_OBJECT_LIST_WITH_DIR,$(GTK_SRC),$(GTK3LIB_DIR)): \
+ CFLAGS += $(GTK3_CFLAGS) -fPIC -I $(XCONFIG_PARSER_DIR)/..
+endif
ifneq ($(NV_USE_BUNDLED_LIBJANSSON),0)
$(call BUILD_OBJECT_LIST,$(JANSSON_SRC)): CFLAGS += $(JANSSON_CFLAGS)
@@ -195,21 +263,49 @@ endif
.PHONY: all install NVIDIA_SETTINGS_install clean clobber build-xnvctrl
-all: $(NVIDIA_SETTINGS)
+all: $(NVIDIA_SETTINGS) $(GTK2LIB) $(GTK3LIB)
-install: NVIDIA_SETTINGS_install
+install: NVIDIA_SETTINGS_install NVIDIA_GTKLIB_install
+
+NVIDIA_GTKLIB_install: $(GTK2LIB) $(GTK3LIB)
+ $(MKDIR) $(LIBDIR)
+ $(INSTALL) $(INSTALL_LIB_ARGS) $(GTK2LIB) \
+ $(LIBDIR)/$(GTK2LIB_SONAME)
+ifdef BUILD_GTK3LIB
+ $(INSTALL) $(INSTALL_LIB_ARGS) $(GTK3LIB) \
+ $(LIBDIR)/$(GTK3LIB_SONAME)
+endif
NVIDIA_SETTINGS_install: $(NVIDIA_SETTINGS)
$(MKDIR) $(BINDIR)
$(INSTALL) $(INSTALL_BIN_ARGS) $< $(BINDIR)/$(notdir $<)
$(NVIDIA_SETTINGS): $(OBJS) $(XNVCTRL_ARCHIVE)
- $(call quiet_cmd,LINK) $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) -o $@ $(OBJS) \
- $(XNVCTRL_ARCHIVE) $(LIBS)
+ $(call quiet_cmd,LINK) $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) \
+ -rdynamic -o $@ $(OBJS) $(XNVCTRL_ARCHIVE) $(LIBS)
$(call quiet_cmd,STRIP_CMD) $@
+$(GTK2LIB): $(GTK2_OBJS) $(XCP_OBJS) $(VERSION_MK)
+ $(call quiet_cmd,LINK) -shared $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) \
+ $(XNVCTRL_ARCHIVE) $(LIBS) $(GTK2_LIBS) \
+ -Wl,--unresolved-symbols=ignore-all -o $(GTK2LIB) \
+ -Wl,-soname -Wl,$(GTK2LIB_SONAME) \
+ $(GTK2_OBJS) $(XCP_OBJS)
+ $(call quiet_cmd,STRIP_CMD) $@
+
+ifdef BUILD_GTK3LIB
+$(GTK3LIB): $(GTK3_OBJS) $(XCP_OBJS) $(VERSION_MK)
+ $(call quiet_cmd,LINK) -shared $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) \
+ $(XNVCTRL_ARCHIVE) $(LIBS) $(GTK3_LIBS) \
+ -Wl,--unresolved-symbols=ignore-all -o $(GTK3LIB) \
+ -Wl,-soname -Wl,$(GTK3LIB_SONAME) \
+ $(GTK3_OBJS) $(XCP_OBJS)
+ $(call quiet_cmd,STRIP_CMD) $@
+endif
+
# define the rule to build each object file
$(foreach src,$(SRC),$(eval $(call DEFINE_OBJECT_RULE,TARGET,$(src))))
+$(foreach src,$(XCP_SRC),$(eval $(call DEFINE_OBJECT_RULE,TARGET,$(src))))
# define the rule to generate $(STAMP_C)
$(eval $(call DEFINE_STAMP_C_RULE, $(OBJS),$(NVIDIA_SETTINGS_PROGRAM_NAME)))
@@ -222,6 +318,15 @@ build-xnvctrl:
clean clobber:
rm -rf $(NVIDIA_SETTINGS) *~ $(STAMP_C) \
- $(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d
+ $(OUTPUTDIR)/*.o $(OUTPUTDIR)/*.d \
+ $(GTK2LIB) $(GTK3LIB) $(GTK2LIB_DIR) $(GTK3LIB_DIR)
@$(MAKE) -C $(XNVCTRL_DIR) -f $(XNVCTRL_MAKEFILE) clean
+$(foreach src,$(GTK_SRC), \
+ $(eval $(call DEFINE_OBJECT_RULE_WITH_DIR,TARGET,$(src),$(GTK2LIB_DIR))))
+
+ifdef BUILD_GTK3LIB
+$(foreach src,$(GTK_SRC), \
+ $(eval $(call DEFINE_OBJECT_RULE_WITH_DIR,TARGET,$(src),$(GTK3LIB_DIR))))
+endif
+
diff --git a/src/XF86Config-parser/Generate.c b/src/XF86Config-parser/Generate.c
index cdd7054..9e1db27 100644
--- a/src/XF86Config-parser/Generate.c
+++ b/src/XF86Config-parser/Generate.c
@@ -1313,13 +1313,10 @@ static char *xconfigGetDefaultProjectRoot(void)
* get_xserver_information() - parse the versionString (from `X
* -version`) and assign relevant information that we infer from the X
* server version.
- *
- * Note: this implementation should be shared with nvidia-installer
*/
static int get_xserver_information(const char *versionString,
int *isXorg,
- int *isModular,
int *autoloadsGLX,
int *supportsExtensionSection,
int *xineramaPlusCompositeWorks)
@@ -1334,7 +1331,6 @@ static int get_xserver_information(const char *versionString,
if (strstr(versionString, "XFree86 Version")) {
*isXorg = FALSE;
- *isModular = FALSE;
*autoloadsGLX = FALSE;
*supportsExtensionSection = FALSE;
*xineramaPlusCompositeWorks = FALSE;
@@ -1365,17 +1361,6 @@ static int get_xserver_information(const char *versionString,
if (!found) return FALSE;
/*
- * isModular: X.Org X11R6.x X servers are monolithic, all others
- * are modular
- */
-
- if (major == 6) {
- *isModular = FALSE;
- } else {
- *isModular = TRUE;
- }
-
- /*
* supportsExtensionSection: support for the "Extension" xorg.conf
* section was added between X.Org 6.7 and 6.8. To account for
* the X server version wrap, it is easier to check for X servers
@@ -1443,7 +1428,7 @@ void xconfigGetXServerInUse(GenerateOptions *gop)
FILE *stream = NULL;
int xserver = -1;
int isXorg;
- int dummy, len, found;
+ int len, found;
char *cmd, *ptr, *ret;
gop->supports_extension_section = FALSE;
@@ -1476,7 +1461,6 @@ void xconfigGetXServerInUse(GenerateOptions *gop)
found = get_xserver_information(buf,
&isXorg,
- &dummy, /* isModular */
&gop->autoloads_glx,
&gop->supports_extension_section,
&gop->xinerama_plus_composite_works);
diff --git a/src/app-profiles.c b/src/app-profiles.c
index a3b1003..1ac4142 100644
--- a/src/app-profiles.c
+++ b/src/app-profiles.c
@@ -63,19 +63,18 @@ static char *slurp(FILE *fp)
int eof = FALSE;
char *text = strdup("");
char *new_text;
- char *line = NULL;
while (text && !eof) {
- line = fget_next_line(fp, &eof);
- if (!eof) {
+ char *line = fget_next_line(fp, &eof);
+
+ if (line && *line != '\0' && *line != '\n') {
new_text = nvstrcat(text, "\n", line, NULL);
free(text);
text = new_text;
}
+ free(line);
}
- free(line);
-
return text;
}
@@ -900,6 +899,9 @@ static json_t *app_profile_config_load_global_options(const char *global_config_
ret = open_and_stat(global_config_file, "r", &fp, &stat_buf);
if ((ret < 0) || !S_ISREG(stat_buf.st_mode)) {
+ if (ret >= 0) {
+ fclose(fp);
+ }
return options;
}
@@ -1007,50 +1009,20 @@ static int file_in_search_path(AppProfileConfig *config, const char *filename)
} while (0)
/*
- * Creates parent directories as needed, similarly to "mkdir -p"
+ * Create parent directories as needed and handle error messages
*/
static int nv_mkdirp(const char *dirname, char **error_str)
{
- int ret = 0;
- char *parent_name;
- const char *cur, *next;
- struct stat stat_buf;
- cur = dirname;
-
- while (*cur && (next = strchr(cur + 1, '/'))) {
- parent_name = nvstrndup(dirname, next - dirname);
- ret = mkdir(parent_name, 0777);
- if ((ret < 0) && (errno != EEXIST)) {
- LOG_ERROR(error_str,
- "Could not create parent directory \"%s\" "
- "for full path \"%s\" (%s)",
- parent_name, dirname, strerror(errno));
- free(parent_name);
- return ret;
- }
- cur = next;
- free(parent_name);
- }
+ char *tmp_error_str = NULL;
+ int success;
- ret = mkdir(dirname, 0777);
- if (ret < 0) {
- if (errno != EEXIST) {
- LOG_ERROR(error_str, "Could not create directory \"%s\" (%s)",
- dirname, strerror(errno));
- } else {
- ret = stat(dirname, &stat_buf);
- if (ret == 0) {
- if (!S_ISDIR(stat_buf.st_mode)) {
- LOG_ERROR(error_str, "Could not create directory \"%s\" "
- "(file exists, but not as a directory)",
- dirname);
- ret = -1;
- }
- }
- }
+ success = nv_mkdir_recursive(dirname, 0777, &tmp_error_str, NULL);
+ if (tmp_error_str) {
+ LOG_ERROR(error_str, "%s", tmp_error_str);
+ free(tmp_error_str);
}
- return ret;
+ return success ? 0 : -1;
}
char *nv_app_profile_config_get_backup_filename(AppProfileConfig *config, const char *filename)
diff --git a/src/command-line.c b/src/command-line.c
index ef47ad3..6327780 100644
--- a/src/command-line.c
+++ b/src/command-line.c
@@ -38,7 +38,7 @@
/* local prototypes */
-static void print_attribute_help(char *attr);
+static void print_attribute_help(const char *attr);
static void print_help(void);
/*
@@ -67,7 +67,7 @@ static void print_version(void)
* print_attribute_help() - print information about the specified attribute.
*/
-static void print_attribute_help(char *attr)
+static void print_attribute_help(const char *attr)
{
int i;
int found = 0;
@@ -96,17 +96,20 @@ static void print_attribute_help(char *attr)
/* Attribute type (value) information */
switch (entry->type) {
- case NV_PARSER_ATTRIBUTE_TYPE_INTEGER:
+ case CTRL_ATTRIBUTE_TYPE_INTEGER:
nv_msg(NULL, " - Attribute value is an integer.");
break;
- case NV_PARSER_ATTRIBUTE_TYPE_STRING:
- case NV_PARSER_ATTRIBUTE_TYPE_STRING_OPERATION:
+ case CTRL_ATTRIBUTE_TYPE_STRING:
+ case CTRL_ATTRIBUTE_TYPE_STRING_OPERATION:
nv_msg(NULL, " - Attribute value is a string.");
break;
- case NV_PARSER_ATTRIBUTE_TYPE_COLOR:
+ case CTRL_ATTRIBUTE_TYPE_BINARY_DATA:
+ nv_msg(NULL, " - Attribute value is binary data.");
+ break;
+ case CTRL_ATTRIBUTE_TYPE_COLOR:
nv_msg(NULL, " - Attribute value is a color.");
break;
- case NV_PARSER_ATTRIBUTE_TYPE_SDI_CSC:
+ case CTRL_ATTRIBUTE_TYPE_SDI_CSC:
nv_msg(NULL, " - Attribute value is a SDI CSC matrix.");
break;
}
@@ -132,7 +135,7 @@ static void print_attribute_help(char *attr)
/* Attribute type-specific flags */
switch (entry->type) {
- case NV_PARSER_ATTRIBUTE_TYPE_INTEGER:
+ case CTRL_ATTRIBUTE_TYPE_INTEGER:
if (entry->f.int_flags.is_100Hz) {
nv_msg(NULL, " - Attribute value is in units of Centihertz "
"(1/100Hz).");
@@ -157,10 +160,11 @@ static void print_attribute_help(char *attr)
nv_msg(NULL, " - Attribute value is switch display.");
}
break;
- case NV_PARSER_ATTRIBUTE_TYPE_STRING:
- case NV_PARSER_ATTRIBUTE_TYPE_COLOR:
- case NV_PARSER_ATTRIBUTE_TYPE_SDI_CSC:
- case NV_PARSER_ATTRIBUTE_TYPE_STRING_OPERATION:
+ case CTRL_ATTRIBUTE_TYPE_STRING:
+ case CTRL_ATTRIBUTE_TYPE_COLOR:
+ case CTRL_ATTRIBUTE_TYPE_SDI_CSC:
+ case CTRL_ATTRIBUTE_TYPE_STRING_OPERATION:
+ case CTRL_ATTRIBUTE_TYPE_BINARY_DATA:
/* Nothing specific to report for these */
break;
}
@@ -210,16 +214,14 @@ void print_help(void)
/*
* parse_command_line() - malloc an Options structure, initialize it
* with defaults, and fill in any pertinent data from the commandline
- * arguments. This must be called after the gui is initialized (so
- * that the gui can remove its commandline arguments from argv).
- *
- * XXX it's unfortunate that we need to init the gui before calling
- * this, because many of the commandline options will cause us to not
- * even use the gui.
+ * arguments. This must be called before the gui is initialized so
+ * that the correct gui library can be used. Arguments for the gui must
+ * follow a '--' marker. The marker will be removed before passing the
+ * commandline arguments to the gui init function.
*/
-Options *parse_command_line(int argc, char *argv[], char *dpy,
- CtrlHandlesArray *handles_array)
+Options *parse_command_line(int argc, char *argv[],
+ CtrlSystemList *systems)
{
Options *op;
int n, c;
@@ -234,9 +236,7 @@ Options *parse_command_line(int argc, char *argv[], char *dpy,
* initialize the controlled display to the gui display name
* passed in.
*/
-
- op->ctrl_display = dpy;
-
+
while (1) {
c = nvgetopt(argc, argv, __options, &strval,
&boolval, /* boolval */
@@ -254,6 +254,15 @@ Options *parse_command_line(int argc, char *argv[], char *dpy,
case 'n': op->no_load = 1; break;
case 'r': op->rewrite = 1; break;
case 'c': op->ctrl_display = strval; break;
+ case DISPLAY_OPTION:
+ /*
+ * --ctrl-display and --display can both be specified so only assign
+ * --display to ctrl_display if it is not yet assigned.
+ */
+ if (!op->ctrl_display) {
+ op->ctrl_display = strval;
+ }
+ break;
case 'p': op->page = strval; break;
case 'V':
nv_set_verbosity(NV_VERBOSITY_DEFAULT);
@@ -292,12 +301,14 @@ Options *parse_command_line(int argc, char *argv[], char *dpy,
op->num_queries++;
break;
case CONFIG_FILE_OPTION: op->config = strval; break;
- case 'g': print_glxinfo(NULL, handles_array); exit(0); break;
+ case 'g': print_glxinfo(NULL, systems); exit(0); break;
case 't': op->terse = NV_TRUE; break;
case 'd': op->dpy_string = NV_TRUE; break;
case 'e': print_attribute_help(strval); exit(0); break;
case 'L': op->list_targets = NV_TRUE; break;
case 'w': op->write_config = boolval; break;
+ case 'i': op->use_gtk2 = NV_TRUE; break;
+ case 'I': op->gtk_lib_path = strval; break;
default:
nv_error_msg("Invalid commandline, please run `%s --help` "
"for usage information.\n", argv[0]);
diff --git a/src/command-line.h b/src/command-line.h
index 21e17c8..5e8c526 100644
--- a/src/command-line.h
+++ b/src/command-line.h
@@ -25,10 +25,11 @@
/*
* Forward declaration to break circular dependancy with query-assign.h
*/
-struct _CtrlHandlesArray;
+struct _CtrlSystemList;
#define DEFAULT_RC_FILE "~/.nvidia-settings-rc"
#define CONFIG_FILE_OPTION 1
+#define DISPLAY_OPTION 2
/*
* Options structure -- stores the parameters specified on the
@@ -110,10 +111,21 @@ typedef struct {
* If true, write out the configuration file on exit.
*/
+ int use_gtk2; /*
+ * If true, use GTK+ 2 user interface library
+ */
+
+ char *gtk_lib_path; /*
+ * Path to the user interface library to use or to the
+ * directory containing the library to use. In the
+ * former case, the value of the use_gtk2 option is
+ * ignored.
+ */
+
} Options;
-Options *parse_command_line(int argc, char *argv[], char *dpy,
- struct _CtrlHandlesArray *handles_array);
+Options *parse_command_line(int argc, char *argv[],
+ struct _CtrlSystemList *systems);
#endif /* __COMMAND_LINE_H__ */
diff --git a/src/common-utils/common-utils.c b/src/common-utils/common-utils.c
index f581f0d..81fd7ed 100644
--- a/src/common-utils/common-utils.c
+++ b/src/common-utils/common-utils.c
@@ -522,6 +522,68 @@ char *nv_basename(const char *path)
}
+/*
+ * nv_mkdir_recursive() - make a directory and all parent directories as needed.
+ * dir_list is an optional arguments that if not empty, will be set to a string
+ * containing a newline separated list of all directories created.
+ */
+int nv_mkdir_recursive(const char *path, const mode_t mode,
+ char **error_str, char **dir_list)
+{
+ char *c, *tmp, ch, *list;
+ int success = FALSE;
+
+ if (!path || !path[0]) {
+ return FALSE;
+ }
+
+ tmp = nvstrdup(path);
+ remove_trailing_slashes(tmp);
+
+ list = NULL;
+
+ c = tmp;
+ do {
+ c++;
+ if ((*c == '/') || (*c == '\0')) {
+ ch = *c;
+ *c = '\0';
+ if (!directory_exists(tmp)) {
+ char *tmplist;
+ if (mkdir(tmp, mode) != 0) {
+ *error_str =
+ nvasprintf("Failure creating directory '%s' : (%s)",
+ tmp, strerror(errno));
+ goto done;
+ }
+ /* Prepend the created directory path to a running list */
+ if (dir_list) {
+ tmplist = list;
+ list = nvstrcat(tmp, "\n", tmplist, NULL);
+ free(tmplist);
+ }
+ }
+ *c = ch;
+ }
+ } while (*c);
+
+ /* Log any created directories */
+ if (dir_list && list) {
+ *dir_list = list;
+ }
+
+ success = TRUE;
+
+ done:
+
+ if (!dir_list) {
+ free(list);
+ }
+ free(tmp);
+ return success;
+}
+
+
/****************************************************************************/
/* string helper functions */
/****************************************************************************/
@@ -611,3 +673,39 @@ char *nv_trim_char_strict(char *string, char trim) {
return NULL;
}
+/*
+ * directory_exists() - test whether the given directory exists
+ */
+
+int directory_exists(const char *dir)
+{
+ struct stat stat_buf;
+
+ if ((stat (dir, &stat_buf) == -1) || (!S_ISDIR(stat_buf.st_mode))) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+}
+
+/*
+ * remove_trailing_slashes() - begin at the end of the given string,
+ * and overwrite slashes with NULL as long as we find slashes.
+ */
+
+void remove_trailing_slashes(char *string)
+{
+ int len;
+
+ if (string == NULL) {
+ return;
+ }
+
+ len = strlen(string);
+
+ while (string[len-1] == '/') {
+ string[--len] = '\0';
+ }
+
+}
+
diff --git a/src/common-utils/common-utils.h b/src/common-utils/common-utils.h
index 3db71b6..709ff02 100644
--- a/src/common-utils/common-utils.h
+++ b/src/common-utils/common-utils.h
@@ -62,10 +62,15 @@ int nv_get_file_length(const char *filename);
void nv_set_file_length(const char *filename, int fd, int len);
void *nv_mmap(const char *filename, size_t len, int prot, int flags, int fd);
char *nv_basename(const char *path);
+int nv_mkdir_recursive(const char *path, const mode_t mode,
+ char **error_str, char **log_str);
char *nv_trim_space(char *string);
char *nv_trim_char(char *string, char trim);
char *nv_trim_char_strict(char *string, char trim);
+void remove_trailing_slashes(char *string);
+
+int directory_exists(const char *dir);
#if defined(__GNUC__)
# define NV_INLINE __inline__
diff --git a/src/common-utils/nvgetopt.c b/src/common-utils/nvgetopt.c
index 1c6c9b8..aaebd78 100644
--- a/src/common-utils/nvgetopt.c
+++ b/src/common-utils/nvgetopt.c
@@ -42,6 +42,7 @@ int nvgetopt(int argc,
int ret = 0;
int negate = NVGETOPT_FALSE;
int disable = NVGETOPT_FALSE;
+ int double_dash = NVGETOPT_FALSE;
const NVGetoptOption *o = NULL;
static int argv_index = 0;
@@ -65,6 +66,7 @@ int nvgetopt(int argc,
if ((arg[0] == '-') && (arg[1] == '-')) {
name = arg + 2;
+ double_dash = NVGETOPT_TRUE;
} else if (arg[0] == '-') {
name = arg + 1;
} else {
@@ -80,16 +82,26 @@ int nvgetopt(int argc,
c = name;
while (*c) {
- if (*c == '=') { argument = c + 1; *c = '\0'; break; }
+ if (*c == '=') {
+ argument = c + 1;
+ *c = '\0';
+ break;
+ }
c++;
}
/*
+ * if there is no character after '--' then stop processing options.
* if the string is terminated after one character, interpret it
* as a short option. Otherwise, interpret it as a long option.
*/
- if (name[1] == '\0') { /* short option */
+ if (name[0] == '\0') {
+ if (double_dash && argument == NULL) { /* option list terminator */
+ ret = -1;
+ goto done;
+ }
+ } else if (name[1] == '\0') { /* short option */
for (i = 0; options[i].name; i++) {
if (options[i].val == name[0]) {
o = &options[i];
diff --git a/src/config-file.c b/src/config-file.c
index 2364291..02061ae 100644
--- a/src/config-file.c
+++ b/src/config-file.c
@@ -54,7 +54,7 @@
typedef struct {
ParsedAttribute a;
int line;
- CtrlHandles *h;
+ CtrlSystem *system;
} ParsedAttributeWrapper;
@@ -67,7 +67,7 @@ static int process_config_file_attributes(const Options *op,
const char *file,
ParsedAttributeWrapper *w,
const char *display_name,
- CtrlHandlesArray *handles_array);
+ CtrlSystemList *system_list);
static void save_gui_parsed_attributes(ParsedAttributeWrapper *w,
ParsedAttribute *p);
@@ -78,11 +78,11 @@ static float get_color_value(int attr,
static int parse_config_property(const char *file, const char *line,
ConfigProperties *conf);
-static void write_config_properties(FILE *stream, ConfigProperties *conf,
+static void write_config_properties(FILE *stream, const ConfigProperties *conf,
char *locale);
-static char *create_display_device_target_string(CtrlHandleTarget *t,
- ConfigProperties *conf);
+static char *create_display_device_target_string(CtrlTarget *t,
+ const ConfigProperties *conf);
/*
* set_dynamic_verbosity() - Sets the __dynamic_verbosity variable which
@@ -118,11 +118,14 @@ void set_dynamic_verbosity(int dynamic)
int nv_read_config_file(const Options *op, const char *file,
const char *display_name,
ParsedAttribute *p, ConfigProperties *conf,
- CtrlHandlesArray *handles_array)
+ CtrlSystemList *systems)
{
- int fd, ret, length;
+ int fd = -1;
+ int ret = NV_FALSE;
+ int length;
struct stat stat_buf;
- char *buf, *locale;
+ char *buf;
+ char *locale;
ParsedAttributeWrapper *w = NULL;
if (!file) {
@@ -130,9 +133,9 @@ int nv_read_config_file(const Options *op, const char *file,
* file is NULL, likely because tilde_expansion() failed and
* returned NULL; silently fail
*/
- return NV_FALSE;
+ goto done;
}
-
+
/* open the file */
fd = open(file, O_RDONLY);
@@ -141,37 +144,35 @@ int nv_read_config_file(const Options *op, const char *file,
* It's OK if the file doesn't exist... but should we print a
* warning?
*/
- return NV_FALSE;
+ goto done;
}
-
+
/* get the size of the file */
- ret = fstat(fd, &stat_buf);
- if (ret == -1) {
+ if (fstat(fd, &stat_buf) == -1) {
nv_error_msg("Unable to determine size of file '%s' (%s).",
file, strerror(errno));
- return NV_FALSE;
+ goto done;
}
- if (stat_buf.st_size == 0) {
+ length = stat_buf.st_size;
+
+ if (length == 0) {
nv_warning_msg("File '%s' has zero size; not reading.", file);
- close(fd);
- return NV_TRUE;
+ ret = NV_TRUE;
+ goto done;
}
- length = stat_buf.st_size;
-
/* map the file into memory */
buf = mmap(0, length, PROT_READ, MAP_SHARED, fd, 0);
if (buf == (void *) -1) {
nv_error_msg("Unable to mmap file '%s' for reading (%s).",
file, strerror(errno));
- return NV_FALSE;
+ goto done;
}
-
- /*
+ /*
* save the current locale, parse the actual text in the file
* and restore the saved locale (could be changed).
*/
@@ -185,20 +186,19 @@ int nv_read_config_file(const Options *op, const char *file,
/* unmap and close the file */
- if (munmap (buf, stat_buf.st_size) == -1) {
+ if (munmap(buf, length) == -1) {
nv_error_msg("Unable to unmap file '%s' after reading (%s).",
file, strerror(errno));
- return NV_FALSE;
+ goto done;
}
- close(fd);
-
- if (!w) return NV_FALSE;
+ if (!w) {
+ goto done;
+ }
/* process the parsed attributes */
- ret = process_config_file_attributes(op, file, w, display_name,
- handles_array);
+ ret = process_config_file_attributes(op, file, w, display_name, systems);
/*
* add any relevant parsed attributes back to the list to be
@@ -206,11 +206,13 @@ int nv_read_config_file(const Options *op, const char *file,
*/
save_gui_parsed_attributes(w, p);
-
- if (w) free(w);
+
+ done:
+ free(w);
+ close(fd);
return ret;
-
+
} /* nv_read_config_file() */
@@ -226,16 +228,17 @@ int nv_read_config_file(const Options *op, const char *file,
* write the file (to avoid deleting the existing file).
*/
-int nv_write_config_file(const char *filename, CtrlHandles *h,
- ParsedAttribute *p, ConfigProperties *conf)
+int nv_write_config_file(const char *filename, const CtrlSystem *system,
+ const ParsedAttribute *p, const ConfigProperties *conf)
{
- int screen, ret, entry, val, display, randr_gamma_available;
+ int ret, entry, val, randr_gamma_available;
FILE *stream;
time_t now;
ReturnStatus status;
- NVCTRLAttributePermissionsRec perms;
+ CtrlAttributePerms perms;
NVCTRLAttributeValidValuesRec valid;
- CtrlHandleTarget *t;
+ CtrlTargetNode *node;
+ CtrlTarget *t;
char *prefix, scratch[4];
char *locale = "C";
@@ -291,10 +294,10 @@ int nv_write_config_file(const char *filename, CtrlHandles *h,
* Note: we only save writable attributes addressable by X screen here
* followed by attributes for display target types.
*/
-
- for (screen = 0; screen < h->targets[X_SCREEN_TARGET].n; screen++) {
- t = &h->targets[X_SCREEN_TARGET].t[screen];
+ for (node = system->targets[X_SCREEN_TARGET]; node; node = node->next) {
+
+ t = node->t;
/* skip it if we don't have a handle for this screen */
@@ -310,7 +313,7 @@ int nv_write_config_file(const char *filename, CtrlHandles *h,
CONFIG_PROPERTIES_INCLUDE_DISPLAY_NAME_IN_CONFIG_FILE) {
prefix = t->name;
} else {
- snprintf(scratch, 4, "%d", screen);
+ snprintf(scratch, 4, "%d", NvCtrlGetTargetId(t));
prefix = scratch;
}
@@ -333,17 +336,19 @@ int nv_write_config_file(const char *filename, CtrlHandles *h,
* print floats
*/
- if (a->type == NV_PARSER_ATTRIBUTE_TYPE_COLOR) {
+ if (a->type == CTRL_ATTRIBUTE_TYPE_COLOR) {
float c[3], b[3], g[3];
/*
* if we are using RandR gamma, skip saving the color info
*/
- status = NvCtrlGetAttribute(t->h, NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE, &val);
+ status = NvCtrlGetAttribute(t,
+ NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE,
+ &val);
if (status == NvCtrlSuccess && val) continue;
- status = NvCtrlGetColorAttributes(t->h, c, b, g);
+ status = NvCtrlGetColorAttributes(t, c, b, g);
if (status != NvCtrlSuccess) continue;
fprintf(stream, "%s%c%s=%f\n",
prefix, DISPLAY_NAME_SEPARATOR, a->name,
@@ -354,34 +359,34 @@ int nv_write_config_file(const char *filename, CtrlHandles *h,
/* Only write out integer attributes, string and SDI CSC attributes
* aren't written here.
*/
- if (a->type != NV_PARSER_ATTRIBUTE_TYPE_INTEGER) {
+ if (a->type != CTRL_ATTRIBUTE_TYPE_INTEGER) {
continue;
}
/* Ignore display attributes, they are written later on */
- ret = nv_get_attribute_perms(h, a, &perms);
- if (!ret || (perms.permissions & ATTRIBUTE_TYPE_DISPLAY)) {
+ status = NvCtrlGetAttributePerms(t, a->type, a->attr, &perms);
+ if (status != NvCtrlSuccess ||
+ (perms.valid_targets & CTRL_TARGET_PERM_BIT(DISPLAY_TARGET))) {
continue;
}
/* Only write attributes that can be written */
- status = NvCtrlGetValidAttributeValues(t->h, a->attr, &valid);
+ status = NvCtrlGetValidAttributeValues(t, a->attr, &valid);
if (status != NvCtrlSuccess ||
!(valid.permissions & ATTRIBUTE_TYPE_WRITE) ||
(valid.permissions & ATTRIBUTE_TYPE_DISPLAY)) {;
continue;
}
- status = NvCtrlGetAttribute(t->h, a->attr, &val);
+ status = NvCtrlGetAttribute(t, a->attr, &val);
if (status != NvCtrlSuccess) {
continue;
}
if (a->f.int_flags.is_display_id) {
- const char *name =
- nv_get_display_target_config_name(h, val);
+ const char *name = NvCtrlGetDisplayConfigName(system, val);
if (name) {
fprintf(stream, "%s%c%s=%s\n", prefix,
DISPLAY_NAME_SEPARATOR, a->name, name);
@@ -400,9 +405,9 @@ int nv_write_config_file(const char *filename, CtrlHandles *h,
* Write attributes addressable to display targets
*/
- for (display = 0; display < h->targets[DISPLAY_TARGET].n; display++) {
+ for (node = system->targets[DISPLAY_TARGET]; node; node = node->next) {
- t = &h->targets[DISPLAY_TARGET].t[display];
+ t = node->t;
/* skip it if we don't have a handle for this display */
@@ -413,7 +418,7 @@ int nv_write_config_file(const char *filename, CtrlHandles *h,
* skip writing attributes if it is missing.
*/
- status = NvCtrlGetAttribute(t->h,
+ status = NvCtrlGetAttribute(t,
NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE,
&randr_gamma_available);
if (status != NvCtrlSuccess) {
@@ -442,12 +447,12 @@ int nv_write_config_file(const char *filename, CtrlHandles *h,
* for the display target we only write color attributes for now
*/
- if (a->type == NV_PARSER_ATTRIBUTE_TYPE_COLOR) {
+ if (a->type == CTRL_ATTRIBUTE_TYPE_COLOR) {
float c[3], b[3], g[3];
if (!randr_gamma_available) continue;
- status = NvCtrlGetColorAttributes(t->h, c, b, g);
+ status = NvCtrlGetColorAttributes(t, c, b, g);
if (status != NvCtrlSuccess) continue;
fprintf(stream, "%s%c%s=%f\n",
@@ -459,25 +464,26 @@ int nv_write_config_file(const char *filename, CtrlHandles *h,
/* Only write out integer attributes, string and SDI CSC attributes
* aren't written here.
*/
- if (a->type != NV_PARSER_ATTRIBUTE_TYPE_INTEGER) {
+ if (a->type != CTRL_ATTRIBUTE_TYPE_INTEGER) {
continue;
}
/* Make sure this is a display attribute */
- ret = nv_get_attribute_perms(h, a, &perms);
- if (!ret || !(perms.permissions & ATTRIBUTE_TYPE_DISPLAY)) {
+ status = NvCtrlGetAttributePerms(t, a->type, a->attr, &perms);
+ if (status != NvCtrlSuccess ||
+ !(perms.valid_targets & CTRL_TARGET_PERM_BIT(DISPLAY_TARGET))) {
continue;
}
- status = NvCtrlGetValidAttributeValues(t->h, a->attr, &valid);
+ status = NvCtrlGetValidAttributeValues(t, a->attr, &valid);
if (status != NvCtrlSuccess ||
!(valid.permissions & ATTRIBUTE_TYPE_WRITE) ||
!(valid.permissions & ATTRIBUTE_TYPE_DISPLAY)) {
continue;
}
- status = NvCtrlGetAttribute(t->h, a->attr, &val);
+ status = NvCtrlGetAttribute(t, a->attr, &val);
if (status == NvCtrlSuccess) {
fprintf(stream, "%s%c%s=%d\n", prefix,
DISPLAY_NAME_SEPARATOR, a->name, val);
@@ -514,15 +520,15 @@ int nv_write_config_file(const char *filename, CtrlHandles *h,
target_str[0] = '\0';
if (p->parser_flags.has_target &&
- (p->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN)) {
+ (p->target_type != X_SCREEN_TARGET)) {
- const TargetTypeEntry *targetTypeEntry;
+ const CtrlTargetTypeInfo *targetTypeInfo;
/* Find the target name of the target type */
- targetTypeEntry = nv_get_target_type_entry_by_nvctrl(p->target_type);
- if (targetTypeEntry) {
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(p->target_type);
+ if (targetTypeInfo) {
snprintf(target_str, 64, "[%s:%d]",
- targetTypeEntry->parsed_name, p->target_id);
+ targetTypeInfo->parsed_name, p->target_id);
}
}
@@ -668,7 +674,7 @@ static int process_config_file_attributes(const Options *op,
const char *file,
ParsedAttributeWrapper *w,
const char *display_name,
- CtrlHandlesArray *handles_array)
+ CtrlSystemList *systems)
{
int i;
@@ -689,19 +695,18 @@ static int process_config_file_attributes(const Options *op,
for (i = 0; w[i].line != -1; i++) {
nv_assign_default_display(&w[i].a, display_name);
}
-
- /* build the list of CtrlHandles */
-
+
+ /* connect to all the systems referenced in the config file */
+
for (i = 0; w[i].line != -1; i++) {
- w[i].h = nv_alloc_ctrl_handles_and_add_to_array(w[i].a.display,
- handles_array);
+ w[i].system = NvCtrlConnectToSystem(w[i].a.display, systems);
}
-
- /* now process each attribute, passing in the correct CtrlHandles */
+
+ /* now process each attribute, passing in the correct system */
for (i = 0; w[i].line != -1; i++) {
- nv_process_parsed_attribute(op, &w[i].a, w[i].h, NV_TRUE, NV_FALSE,
+ nv_process_parsed_attribute(op, &w[i].a, w[i].system, NV_TRUE, NV_FALSE,
"on line %d of configuration file "
"'%s'", w[i].line, file);
/*
@@ -902,7 +907,7 @@ static int parse_config_property(const char *file, const char *line, ConfigPrope
* each property is enabled or disabled.
*/
-static void write_config_properties(FILE *stream, ConfigProperties *conf, char *locale)
+static void write_config_properties(FILE *stream, const ConfigProperties *conf, char *locale)
{
ConfigPropertiesTableEntry *t;
TimerConfigProperty *c;
@@ -956,14 +961,13 @@ void init_config_properties(ConfigProperties *conf)
* to specify the display device target in the config file.
*/
-static char *create_display_device_target_string(CtrlHandleTarget *t,
- ConfigProperties *conf)
+static char *create_display_device_target_string(CtrlTarget *t,
+ const ConfigProperties *conf)
{
char *target_name = NULL;
char *target_prefix_name = NULL;
char *display_name = NULL;
char *s;
- int target_type;
if (t->protoNames[NV_DPY_PROTO_NAME_RANDR]) {
target_name = t->protoNames[NV_DPY_PROTO_NAME_RANDR];
@@ -977,19 +981,14 @@ static char *create_display_device_target_string(CtrlHandleTarget *t,
/* Get the display name if the user requested it to be used. */
if (conf->booleans &
CONFIG_PROPERTIES_INCLUDE_DISPLAY_NAME_IN_CONFIG_FILE) {
- display_name = NvCtrlGetDisplayName(t->h);
+ display_name = NvCtrlGetDisplayName(t);
}
/* Get the target type prefix. */
- target_type = NvCtrlGetTargetType(t->h);
- if (target_type >= 0) {
- target_prefix_name =
- nvstrdup(targetTypeTable[target_type].parsed_name);
- nvstrtoupper(target_prefix_name);
- }
+ target_prefix_name = nvstrdup(t->targetTypeInfo->parsed_name);
+ nvstrtoupper(target_prefix_name);
/* Build the string */
-
if (display_name && target_prefix_name) {
s = nvasprintf("%s[%s:%s]", display_name,
target_prefix_name, target_name);
diff --git a/src/config-file.h b/src/config-file.h
index 6f856b6..0ecc1fe 100644
--- a/src/config-file.h
+++ b/src/config-file.h
@@ -57,9 +57,9 @@ void init_config_properties(ConfigProperties *conf);
int nv_read_config_file(const Options *, const char *, const char *,
ParsedAttribute *, ConfigProperties *,
- CtrlHandlesArray *);
+ CtrlSystemList *);
-int nv_write_config_file(const char *, CtrlHandles *,
- ParsedAttribute *, ConfigProperties *);
+int nv_write_config_file(const char *, const CtrlSystem *,
+ const ParsedAttribute *, const ConfigProperties *);
#endif /* __CONFIG_FILE_H__ */
diff --git a/src/glxinfo.c b/src/glxinfo.c
index 364d640..00c9994 100644
--- a/src/glxinfo.c
+++ b/src/glxinfo.c
@@ -23,7 +23,7 @@
#include <unistd.h>
#include "NvCtrlAttributes.h"
-#include "query-assign.h" /* CtrlHandles */
+#include "query-assign.h"
#include "msg.h"
#include "glxinfo.h"
@@ -167,7 +167,7 @@ caveat_abbrev(int caveat)
static void
-print_fbconfig_attribs(GLXFBConfigAttr *fbca)
+print_fbconfig_attribs(const GLXFBConfigAttr *fbca)
{
int i; /* Iterator */
@@ -273,11 +273,10 @@ if ( (m) != NULL ) { \
#define NULL_TO_EMPTY(s) \
((s)!=NULL)?(s):""
-void print_glxinfo(const char *display_name, CtrlHandlesArray *handles_array)
+void print_glxinfo(const char *display_name, CtrlSystemList *systems)
{
- int screen;
- CtrlHandles *h;
- CtrlHandleTarget *t;
+ CtrlSystem *system;
+ CtrlTargetNode *node;
ReturnStatus status = NvCtrlSuccess;
char *direct_rendering = NULL;
@@ -297,15 +296,15 @@ void print_glxinfo(const char *display_name, CtrlHandlesArray *handles_array)
char *formated_ext_str = NULL;
- h = nv_alloc_ctrl_handles_and_add_to_array(display_name, handles_array);
- if ( h == NULL ) {
+ system = NvCtrlConnectToSystem(display_name, systems);
+ if (system == NULL) {
return;
}
/* Print information for each screen */
- for (screen = 0; screen < h->targets[X_SCREEN_TARGET].n; screen++) {
+ for (node = system->targets[X_SCREEN_TARGET]; node; node = node->next) {
- t = &h->targets[X_SCREEN_TARGET].t[screen];
+ CtrlTarget *t = node->t;
/* No screen, move on */
if ( !t->h ) continue;
@@ -313,12 +312,12 @@ void print_glxinfo(const char *display_name, CtrlHandlesArray *handles_array)
nv_msg(NULL, "GLX Information for %s:", t->name);
/* Get GLX information */
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_DIRECT_RENDERING,
&direct_rendering);
if ( status != NvCtrlSuccess &&
status != NvCtrlNoAttribute ) { goto finish; }
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_GLX_EXTENSIONS,
&glx_extensions);
if ( status != NvCtrlSuccess &&
@@ -331,17 +330,17 @@ void print_glxinfo(const char *display_name, CtrlHandlesArray *handles_array)
}
}
/* Get server GLX information */
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_SERVER_VENDOR,
&server_vendor);
if ( status != NvCtrlSuccess &&
status != NvCtrlNoAttribute ) { goto finish; }
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_SERVER_VERSION,
&server_version);
if ( status != NvCtrlSuccess &&
status != NvCtrlNoAttribute ) { goto finish; }
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_SERVER_EXTENSIONS,
&server_extensions);
if ( status != NvCtrlSuccess &&
@@ -354,17 +353,17 @@ void print_glxinfo(const char *display_name, CtrlHandlesArray *handles_array)
}
}
/* Get client GLX information */
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_CLIENT_VENDOR,
&client_vendor);
if ( status != NvCtrlSuccess &&
status != NvCtrlNoAttribute ) { goto finish; }
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_CLIENT_VERSION,
&client_version);
if ( status != NvCtrlSuccess &&
status != NvCtrlNoAttribute ) { goto finish; }
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_CLIENT_EXTENSIONS,
&client_extensions);
if ( status != NvCtrlSuccess &&
@@ -377,22 +376,22 @@ void print_glxinfo(const char *display_name, CtrlHandlesArray *handles_array)
}
}
/* Get OpenGL information */
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_OPENGL_VENDOR,
&opengl_vendor);
if ( status != NvCtrlSuccess &&
status != NvCtrlNoAttribute ) { goto finish; }
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_OPENGL_RENDERER,
&opengl_renderer);
if ( status != NvCtrlSuccess &&
status != NvCtrlNoAttribute ) { goto finish; }
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_OPENGL_VERSION,
&opengl_version);
if ( status != NvCtrlSuccess &&
status != NvCtrlNoAttribute ) { goto finish; }
- status = NvCtrlGetStringAttribute(t->h,
+ status = NvCtrlGetStringAttribute(t,
NV_CTRL_STRING_GLX_OPENGL_EXTENSIONS,
&opengl_extensions);
if ( status != NvCtrlSuccess &&
@@ -406,7 +405,7 @@ void print_glxinfo(const char *display_name, CtrlHandlesArray *handles_array)
}
/* Get FBConfig information */
- status = NvCtrlGetVoidAttribute(t->h,
+ status = NvCtrlGetVoidAttribute(t,
NV_CTRL_ATTR_GLX_FBCONFIG_ATTRIBS,
(void *)(&fbconfig_attribs));
if ( status != NvCtrlSuccess &&
@@ -487,6 +486,6 @@ void print_glxinfo(const char *display_name, CtrlHandlesArray *handles_array)
SAFE_FREE(opengl_extensions);
SAFE_FREE(fbconfig_attribs);
- nv_free_ctrl_handles_array(handles_array);
-
+ NvCtrlFreeAllSystems(systems);
+
} /* print_glxinfo() */
diff --git a/src/glxinfo.h b/src/glxinfo.h
index 6ad5d07..c4f84ec 100644
--- a/src/glxinfo.h
+++ b/src/glxinfo.h
@@ -34,7 +34,7 @@ const char * caveat_abbrev(int caveat);
#endif
-void print_glxinfo(const char *display_name, CtrlHandlesArray *handles_array);
+void print_glxinfo(const char *display_name, CtrlSystemList *systems);
#endif /* __GLXINFO_H__ */
diff --git a/src/gtk+-2.x/ctk3dvisionpro.c b/src/gtk+-2.x/ctk3dvisionpro.c
index 6dfa8d7..2be13c4 100644
--- a/src/gtk+-2.x/ctk3dvisionpro.c
+++ b/src/gtk+-2.x/ctk3dvisionpro.c
@@ -514,7 +514,8 @@ static void init_glasses_info_widgets(GlassesInfo *glasses)
glasses->image = NULL;
}
-static void callback_glasses_paired(GObject *object, gpointer arg1,
+static void callback_glasses_paired(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
int battery_level;
@@ -522,15 +523,18 @@ static void callback_glasses_paired(GObject *object, gpointer arg1,
unsigned int glasses_id;
GlassesInfo *glasses;
ReturnStatus ret;
- CtkEventStruct *event_struct;
char temp[64]; //scratchpad memory used to construct labels.
int index;
Ctk3DVisionPro *ctk_3d_vision_pro = CTK_3D_VISION_PRO(user_data);
+ CtrlTarget *ctrl_target = ctk_3d_vision_pro->ctrl_target;
AddGlassesDlg *dlg = ctk_3d_vision_pro->add_glasses_dlg;
- event_struct = (CtkEventStruct *) arg1;
- glasses_id = event_struct->value;
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ glasses_id = event->int_attr.value;
/* It is possible for the user to accidentally try pairing a glass even if
* it is already paired leading to multiple entries. To avoid this, return if
@@ -545,14 +549,14 @@ static void callback_glasses_paired(GObject *object, gpointer arg1,
}
}
- ret = NvCtrlGetStringDisplayAttribute(ctk_3d_vision_pro->handle, glasses_id,
+ ret = NvCtrlGetStringDisplayAttribute(ctrl_target, glasses_id,
NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME,
&glasses_name);
if (ret != NvCtrlSuccess) {
glasses_name = NULL;
}
- ret = NvCtrlGetDisplayAttribute(ctk_3d_vision_pro->handle, glasses_id,
+ ret = NvCtrlGetDisplayAttribute(ctrl_target, glasses_id,
NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL,
(int *)&battery_level);
if (ret != NvCtrlSuccess) {
@@ -612,20 +616,23 @@ static void callback_glasses_paired(GObject *object, gpointer arg1,
free(glasses_name);
}
-static void callback_glasses_unpaired(GObject *object, gpointer arg1,
+static void callback_glasses_unpaired(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
int j;
unsigned int glasses_id = 0;
GlassesInfo *glasses = NULL;
char temp[64]; //scratchpad memory used to construct labels.
- CtkEventStruct *event_struct;
int overwrite = FALSE;
Ctk3DVisionPro *ctk_3d_vision_pro = CTK_3D_VISION_PRO(user_data);
- event_struct = (CtkEventStruct *) arg1;
- glasses_id = event_struct->value;
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ glasses_id = event->int_attr.value;
for (j = 0; j < (HTU(0)->num_glasses); j++) {
if (!overwrite && HTU(0)->glasses_info[j]->glasses_id == glasses_id) {
@@ -664,6 +671,7 @@ static void callback_glasses_unpaired(GObject *object, gpointer arg1,
static gboolean poll_pairing(gpointer user_data)
{
Ctk3DVisionPro *ctk_3d_vision_pro = CTK_3D_VISION_PRO(user_data);
+ CtrlTarget *ctrl_target = ctk_3d_vision_pro->ctrl_target;
if (ctk_3d_vision_pro->add_glasses_dlg->pairing_attempts >
PAIRING_DURATION / POLL_PAIRING_CYCLE) {
@@ -672,13 +680,13 @@ static gboolean poll_pairing(gpointer user_data)
if (ctk_3d_vision_pro->add_glasses_dlg->in_pairing) {
/* Enable pairing for PAIRING_TIMEOUT seconds */
- NvCtrlSetAttribute(ctk_3d_vision_pro->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_3D_VISION_PRO_PAIR_GLASSES,
PAIRING_TIMEOUT);
- XFlush(NvCtrlGetDisplayPtr(ctk_3d_vision_pro->handle));
+ XFlush(NvCtrlGetDisplayPtr(ctrl_target));
}
- ctk_3d_vision_pro->add_glasses_dlg->in_pairing =
+ ctk_3d_vision_pro->add_glasses_dlg->in_pairing =
!(ctk_3d_vision_pro->add_glasses_dlg->in_pairing);
ctk_3d_vision_pro->add_glasses_dlg->pairing_attempts++;
return TRUE;
@@ -696,89 +704,99 @@ static void enable_widgets(Ctk3DVisionPro *ctk_3d_vision_pro, Bool enable)
gtk_widget_set_sensitive(ctk_3d_vision_pro->table.hscrollbar, enable);
}
-static void svp_config_changed(GObject *object, gpointer arg1,
+static void svp_config_changed(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
- CtkEventStruct *event_struct;
Ctk3DVisionPro *ctk_3d_vision_pro;
+ CtrlTarget *ctrl_target;
char temp[64];
- event_struct = (CtkEventStruct *) arg1;
ctk_3d_vision_pro = CTK_3D_VISION_PRO(user_data);
-
- switch (event_struct->attribute) {
- case NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL:
- if (HTU(0)->channel_num != event_struct->value) {
- HTU(0)->channel_num = event_struct->value;
- snprintf(temp, sizeof(temp), "%d", HTU(0)->channel_num);
- gtk_label_set_text(ctk_3d_vision_pro->channel_num_label, temp);
- gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->channel_num_label));
- }
- break;
- case NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE:
- {
- SVP_RANGE range;
- CtkDropDownMenu *menu = CTK_DROP_DOWN_MENU(ctk_3d_vision_pro->menu);
- range = ctk_drop_down_menu_get_current_value(menu);
-
- if (range != CHANNEL_RANGE_TO_OPTION_MENU_IDX(event_struct->value)) {
- g_signal_handlers_block_by_func(ctk_3d_vision_pro->menu,
- channel_range_changed, ctk_3d_vision_pro);
- HTU(0)->channel_range = event_struct->value;
- ctk_drop_down_menu_set_current_value(menu,
- CHANNEL_RANGE_TO_OPTION_MENU_IDX(event_struct->value));
- enable_widgets(ctk_3d_vision_pro,
- (HTU(0)->channel_range == SVP_LONG_RANGE ? FALSE : TRUE));
- g_signal_handlers_unblock_by_func(ctk_3d_vision_pro->menu,
- channel_range_changed, ctk_3d_vision_pro);
+ ctrl_target = ctk_3d_vision_pro->ctrl_target;
+
+ if (event->type == CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ gint value = event->int_attr.value;
+
+ switch (event->int_attr.attribute) {
+ case NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL:
+ if (HTU(0)->channel_num != value) {
+ HTU(0)->channel_num = value;
+ snprintf(temp, sizeof(temp), "%d", HTU(0)->channel_num);
+ gtk_label_set_text(ctk_3d_vision_pro->channel_num_label, temp);
+ gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->channel_num_label));
}
break;
- }
- case NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY:
- if (HTU(0)->signal_strength != event_struct->value) {
- const char **signal_strength_icon;
- GdkPixbuf *pixbuf;
+ case NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE:
+ {
+ SVP_RANGE range;
+ CtkDropDownMenu *menu = CTK_DROP_DOWN_MENU(ctk_3d_vision_pro->menu);
+ range = ctk_drop_down_menu_get_current_value(menu);
+
+ if (range != CHANNEL_RANGE_TO_OPTION_MENU_IDX(value)) {
+ g_signal_handlers_block_by_func(ctk_3d_vision_pro->menu,
+ channel_range_changed, ctk_3d_vision_pro);
+ HTU(0)->channel_range = value;
+ ctk_drop_down_menu_set_current_value(menu,
+ CHANNEL_RANGE_TO_OPTION_MENU_IDX(value));
+ enable_widgets(ctk_3d_vision_pro,
+ (HTU(0)->channel_range == SVP_LONG_RANGE ? FALSE : TRUE));
+ g_signal_handlers_unblock_by_func(ctk_3d_vision_pro->menu,
+ channel_range_changed, ctk_3d_vision_pro);
+ }
+ break;
+ }
+ case NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY:
+ if (HTU(0)->signal_strength != value) {
+ const char **signal_strength_icon;
+ GdkPixbuf *pixbuf;
- HTU(0)->signal_strength = event_struct->value;
- snprintf(temp, sizeof(temp), "[%d%%]", HTU(0)->signal_strength);
- gtk_label_set_text(ctk_3d_vision_pro->signal_strength_label, temp);
+ HTU(0)->signal_strength = value;
+ snprintf(temp, sizeof(temp), "[%d%%]", HTU(0)->signal_strength);
+ gtk_label_set_text(ctk_3d_vision_pro->signal_strength_label, temp);
- signal_strength_icon = get_signal_strength_icon(HTU(0)->signal_strength);
- pixbuf = gdk_pixbuf_new_from_xpm_data(signal_strength_icon);
- gtk_image_set_from_pixbuf(GTK_IMAGE(ctk_3d_vision_pro->signal_strength_image), pixbuf);
+ signal_strength_icon = get_signal_strength_icon(HTU(0)->signal_strength);
+ pixbuf = gdk_pixbuf_new_from_xpm_data(signal_strength_icon);
+ gtk_image_set_from_pixbuf(GTK_IMAGE(ctk_3d_vision_pro->signal_strength_image), pixbuf);
- gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->signal_strength_label));
- gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->signal_strength_image));
+ gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->signal_strength_label));
+ gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->signal_strength_image));
+ }
+ break;
+ default:
+ ;
}
- break;
- case NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME:
- {
- int i;
- for (i = 0; i < HTU(0)->num_glasses; i++) {
- ReturnStatus ret;
- char *glasses_name = NULL;
- GlassesInfo *glasses = glasses = HTU(0)->glasses_info[i];
+ }
+ else if (event->type == CTRL_EVENT_TYPE_STRING_ATTRIBUTE) {
+ switch (event->str_attr.attribute) {
+ case NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME:
+ {
+ int i;
+ for (i = 0; i < HTU(0)->num_glasses; i++) {
+ ReturnStatus ret;
+ char *glasses_name = NULL;
+ GlassesInfo *glasses = glasses = HTU(0)->glasses_info[i];
- ret = NvCtrlGetStringDisplayAttribute(ctk_3d_vision_pro->handle,
- glasses->glasses_id,
- NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME,
- &glasses_name);
+ ret = NvCtrlGetStringDisplayAttribute(ctrl_target,
+ glasses->glasses_id,
+ NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME,
+ &glasses_name);
- if (ret != NvCtrlSuccess || glasses_name == NULL) {
- continue;
+ if (ret != NvCtrlSuccess || glasses_name == NULL) {
+ continue;
+ }
+ strncpy(glasses->name, glasses_name, sizeof(glasses->name));
+ glasses->name[sizeof(glasses->name)-1] = '\0';
+ free(glasses_name);
}
- strncpy(glasses->name, glasses_name, sizeof(glasses->name));
- glasses->name[sizeof(glasses->name)-1] = '\0';
- free(glasses_name);
+ update_glasses_info_data_table(&(ctk_3d_vision_pro->table), HTU(0)->glasses_info);
+ gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->table.data_table));
+ break;
}
- update_glasses_info_data_table(&(ctk_3d_vision_pro->table), HTU(0)->glasses_info);
- gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->table.data_table));
- break;
+ default:
+ ;
}
- default:
- ;
}
-
}
/******************************************************************************
@@ -790,6 +808,7 @@ static void svp_config_changed(GObject *object, gpointer arg1,
static void refresh_button_clicked(GtkButton *button, gpointer user_data)
{
Ctk3DVisionPro *ctk_3d_vision_pro = CTK_3D_VISION_PRO(user_data);
+ CtrlTarget *ctrl_target = ctk_3d_vision_pro->ctrl_target;
int i;
char temp[64];
const char **signal_strength_icon;
@@ -800,7 +819,7 @@ static void refresh_button_clicked(GtkButton *button, gpointer user_data)
int battery_level;
GlassesInfo *glasses = glasses = HTU(0)->glasses_info[i];
- ret = NvCtrlGetDisplayAttribute(ctk_3d_vision_pro->handle,
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
glasses->glasses_id,
NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL,
(int *)&battery_level);
@@ -813,7 +832,7 @@ static void refresh_button_clicked(GtkButton *button, gpointer user_data)
update_glasses_info_data_table(&(ctk_3d_vision_pro->table), HTU(0)->glasses_info);
gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->table.data_table));
- ret = NvCtrlGetDisplayAttribute(ctk_3d_vision_pro->handle,
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
HTU(0)->channel_num,
NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY,
(int *)&(HTU(0)->signal_strength));
@@ -913,6 +932,7 @@ static AddGlassesDlg *create_add_glasses_dlg(Ctk3DVisionPro *ctk_3d_vision_pro)
static void add_glasses_button_clicked(GtkButton *button, gpointer user_data)
{
Ctk3DVisionPro *ctk_3d_vision_pro = CTK_3D_VISION_PRO(user_data);
+ CtrlTarget *ctrl_target = ctk_3d_vision_pro->ctrl_target;
AddGlassesDlg *dlg;
gint result;
int i;
@@ -966,7 +986,7 @@ static void add_glasses_button_clicked(GtkButton *button, gpointer user_data)
break;
default:
for (i = 0; i < dlg->new_glasses; i++) {
- NvCtrlSetAttribute(ctk_3d_vision_pro->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES,
dlg->glasses_info[i]->glasses_id);
}
@@ -1030,6 +1050,7 @@ static RemoveGlassesDlg *create_remove_glasses_dlg(Ctk3DVisionPro *ctk_3d_vision
static void remove_button_clicked(GtkButton *button, gpointer user_data)
{
Ctk3DVisionPro *ctk_3d_vision_pro = CTK_3D_VISION_PRO(user_data);
+ CtrlTarget *ctrl_target = ctk_3d_vision_pro->ctrl_target;
CtkDropDownMenu *menu;
RemoveGlassesDlg *dlg;
gint result;
@@ -1063,7 +1084,7 @@ static void remove_button_clicked(GtkButton *button, gpointer user_data)
dlg->glasses_selected_index < HTU(0)->num_glasses) {
unsigned int glasses_id = HTU(0)->glasses_info[dlg->glasses_selected_index]->glasses_id;
- NvCtrlSetAttribute(ctk_3d_vision_pro->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES,
glasses_id);
}
@@ -1128,6 +1149,7 @@ static IdentifyGlassesDlg *create_identify_glasses_dlg(Ctk3DVisionPro *ctk_3d_vi
static void identify_button_clicked(GtkButton *button, gpointer user_data)
{
Ctk3DVisionPro *ctk_3d_vision_pro = CTK_3D_VISION_PRO(user_data);
+ CtrlTarget *ctrl_target = ctk_3d_vision_pro->ctrl_target;
IdentifyGlassesDlg *dlg;
gint result;
unsigned int glasses_id;
@@ -1161,7 +1183,7 @@ static void identify_button_clicked(GtkButton *button, gpointer user_data)
dlg->glasses_selected_index < HTU(0)->num_glasses) {
glasses_id = HTU(0)->glasses_info[dlg->glasses_selected_index]->glasses_id;
- NvCtrlSetAttribute(ctk_3d_vision_pro->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_3D_VISION_PRO_IDENTIFY_GLASSES,
glasses_id);
}
@@ -1243,6 +1265,7 @@ static RenameGlassesDlg *create_rename_glasses_dlg(Ctk3DVisionPro *ctk_3d_vision
static void rename_button_clicked(GtkButton *button, gpointer user_data)
{
Ctk3DVisionPro *ctk_3d_vision_pro = CTK_3D_VISION_PRO(user_data);
+ CtrlTarget *ctrl_target = ctk_3d_vision_pro->ctrl_target;
RenameGlassesDlg *dlg;
gint result;
@@ -1289,11 +1312,10 @@ static void rename_button_clicked(GtkButton *button, gpointer user_data)
ReturnStatus ret;
unsigned int glasses_id = HTU(0)->glasses_info[dlg->glasses_selected_index]->glasses_id;
- ret = NvCtrlSetStringDisplayAttribute(ctk_3d_vision_pro->handle,
+ ret = NvCtrlSetStringDisplayAttribute(ctrl_target,
glasses_id,
NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME,
- dlg->glasses_new_name,
- NULL);
+ dlg->glasses_new_name);
if (ret != NvCtrlSuccess) {
continue;
}
@@ -1381,6 +1403,7 @@ static void channel_range_changed(
)
{
Ctk3DVisionPro *ctk_3d_vision_pro = CTK_3D_VISION_PRO(user_data);
+ CtrlTarget *ctrl_target = ctk_3d_vision_pro->ctrl_target;
CtkDropDownMenu *menu = CTK_DROP_DOWN_MENU(widget);
ChannelRangeDlg *dlg;
gint result;
@@ -1414,7 +1437,7 @@ static void channel_range_changed(
case GTK_RESPONSE_YES:
HTU(0)->channel_range = range;
/* Send NV-Control command */
- NvCtrlSetAttribute(ctk_3d_vision_pro->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE,
(HTU(0)->channel_range));
@@ -1434,8 +1457,9 @@ static void channel_range_changed(
//*****************************************************************************
-GtkWidget* ctk_3d_vision_pro_new(NvCtrlAttributeHandle *handle,
- CtkConfig *ctk_config, ParsedAttribute *p,
+GtkWidget* ctk_3d_vision_pro_new(CtrlTarget *ctrl_target,
+ CtkConfig *ctk_config,
+ ParsedAttribute *p,
CtkEvent *ctk_event)
{
GObject *object;
@@ -1464,7 +1488,7 @@ GtkWidget* ctk_3d_vision_pro_new(NvCtrlAttributeHandle *handle,
object = g_object_new(CTK_TYPE_3D_VISION_PRO, NULL);
ctk_3d_vision_pro = CTK_3D_VISION_PRO(object);
- ctk_3d_vision_pro->handle = handle;
+ ctk_3d_vision_pro->ctrl_target = ctrl_target;
ctk_3d_vision_pro->ctk_config = ctk_config;
ctk_3d_vision_pro->ctk_event = ctk_event;
ctk_3d_vision_pro->add_glasses_dlg = NULL;
@@ -1479,21 +1503,21 @@ GtkWidget* ctk_3d_vision_pro_new(NvCtrlAttributeHandle *handle,
HTU(i) = htu;
}
- ret = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL,
(int *)&(HTU(0)->channel_num));
if (ret != NvCtrlSuccess) {
HTU(0)->channel_num = 0;
}
- ret = NvCtrlGetDisplayAttribute(handle, HTU(0)->channel_num,
+ ret = NvCtrlGetDisplayAttribute(ctrl_target, HTU(0)->channel_num,
NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY,
(int *)&(HTU(0)->signal_strength));
if (ret != NvCtrlSuccess) {
HTU(0)->signal_strength = 0;
}
- ret = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE,
(int *)&(HTU(0)->channel_range));
if (ret != NvCtrlSuccess ||
@@ -1503,7 +1527,7 @@ GtkWidget* ctk_3d_vision_pro_new(NvCtrlAttributeHandle *handle,
HTU(0)->channel_range = SVP_SHORT_RANGE;
}
- ret = NvCtrlGetBinaryAttribute(handle, 0,
+ ret = NvCtrlGetBinaryAttribute(ctrl_target, 0,
NV_CTRL_BINARY_DATA_GLASSES_PAIRED_TO_3D_VISION_PRO_TRANSCEIVER,
&paired_glasses_list, &len);
@@ -1524,14 +1548,14 @@ GtkWidget* ctk_3d_vision_pro_new(NvCtrlAttributeHandle *handle,
HTU(0)->glasses_info[i] = glasses;
- ret = NvCtrlGetStringDisplayAttribute(handle, glasses_id,
+ ret = NvCtrlGetStringDisplayAttribute(ctrl_target, glasses_id,
NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME,
&glasses_name);
if (ret != NvCtrlSuccess) {
glasses_name = NULL;
}
- ret = NvCtrlGetDisplayAttribute(handle, glasses_id,
+ ret = NvCtrlGetDisplayAttribute(ctrl_target, glasses_id,
NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL,
(int *)&battery_level);
if (ret != NvCtrlSuccess) {
diff --git a/src/gtk+-2.x/ctk3dvisionpro.h b/src/gtk+-2.x/ctk3dvisionpro.h
index f87adf0..96b46eb 100644
--- a/src/gtk+-2.x/ctk3dvisionpro.h
+++ b/src/gtk+-2.x/ctk3dvisionpro.h
@@ -105,7 +105,7 @@ typedef struct _AddGlassesDlg {
struct _Ctk3DVisionPro
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
GtkWindow *parent_wnd;
CtkConfig *ctk_config;
CtkEvent *ctk_event;
@@ -134,9 +134,8 @@ struct _Ctk3DVisionProClass
};
GType ctk_3d_vision_pro_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_3d_vision_pro_new (NvCtrlAttributeHandle *,
- CtkConfig *, ParsedAttribute *,
- CtkEvent *);
+GtkWidget* ctk_3d_vision_pro_new (CtrlTarget *, CtkConfig *,
+ ParsedAttribute *, CtkEvent *);
GtkTextBuffer *ctk_3d_vision_pro_create_help (GtkTextTagTable *);
void ctk_3d_vision_pro_select (GtkWidget *w);
void ctk_3d_vision_pro_unselect (GtkWidget *w);
diff --git a/src/gtk+-2.x/ctkappprofile.c b/src/gtk+-2.x/ctkappprofile.c
index 70a2ecf..6e954bc 100644
--- a/src/gtk+-2.x/ctkappprofile.c
+++ b/src/gtk+-2.x/ctkappprofile.c
@@ -1340,26 +1340,17 @@ static gboolean rule_browse_button_clicked(GtkWidget *widget, gpointer user_data
{
EditRuleDialog *dialog = (EditRuleDialog *)user_data;
const gchar *filename = dialog->source_file->str;
- gint result;
-
- gtk_window_set_transient_for(GTK_WINDOW(dialog->file_sel),
- GTK_WINDOW(dialog->top_window));
-
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog->file_sel), filename);
+ gchar *selected_filename =
+ ctk_get_filename_from_dialog("Please select a source file for the rule",
+ GTK_WINDOW(dialog->top_window),
+ filename);
- result = gtk_dialog_run(GTK_DIALOG(dialog->file_sel));
-
- switch (result) {
- case GTK_RESPONSE_ACCEPT:
- case GTK_RESPONSE_OK:
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->file_sel));
+ if (selected_filename) {
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dialog->source_file_combo))),
- filename);
- default:
- break;
+ selected_filename);
+ g_free(selected_filename);
}
- gtk_widget_hide(dialog->file_sel);
return FALSE;
}
@@ -1367,26 +1358,16 @@ static gboolean profile_browse_button_clicked(GtkWidget *widget, gpointer user_d
{
EditProfileDialog *dialog = (EditProfileDialog *)user_data;
const gchar *filename = dialog->source_file->str;
- gint result;
+ gchar *selected_filename =
+ ctk_get_filename_from_dialog("Please select a source file for the profile",
+ GTK_WINDOW(dialog->top_window), filename);
- gtk_window_set_transient_for(GTK_WINDOW(dialog->file_sel),
- GTK_WINDOW(dialog->top_window));
-
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog->file_sel), filename);
-
- result = gtk_dialog_run(GTK_DIALOG(dialog->file_sel));
-
- switch (result) {
- case GTK_RESPONSE_ACCEPT:
- case GTK_RESPONSE_OK:
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->file_sel));
+ if (selected_filename) {
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dialog->source_file_combo))),
- filename);
- default:
- break;
+ selected_filename);
+ g_free(selected_filename);
}
- gtk_widget_hide(dialog->file_sel);
return FALSE;
}
@@ -2033,12 +2014,6 @@ static EditRuleDialog* edit_rule_dialog_new(CtkAppProfile *ctk_app_profile)
dialog->matches = g_string_new("");
dialog->profile_name = g_string_new("");
dialog->profile_settings_store = gtk_list_store_new(SETTING_LIST_STORE_NUM_COLS, G_TYPE_POINTER);
- dialog->file_sel = gtk_file_chooser_dialog_new("Please select a source file for the rule",
- GTK_WINDOW(NULL), GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
gtk_widget_set_size_request(dialog->top_window, 500, 480);
gtk_container_set_border_width(GTK_CONTAINER(dialog->top_window), 8);
@@ -3000,11 +2975,6 @@ static EditProfileDialog *edit_profile_dialog_new(CtkAppProfile *ctk_app_profile
dialog->settings = json_array();
dialog->settings_store = gtk_list_store_new(SETTING_LIST_STORE_NUM_COLS, G_TYPE_POINTER);
- dialog->file_sel = gtk_file_chooser_dialog_new("Please select a source file for the profile",
- GTK_WINDOW(NULL), GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
main_vbox = gtk_vbox_new(FALSE, 0);
gtk_box_set_spacing(GTK_BOX(main_vbox), 8);
@@ -4085,7 +4055,7 @@ static SaveAppProfileChangesDialog *save_app_profile_changes_dialog_new(CtkAppPr
hbox = gtk_hbox_new(FALSE, 8);
- dialog->preview_file_menu = menu = ctk_drop_down_menu_new(CTK_DROP_DOWN_MENU_FLAG_READWRITE);
+ dialog->preview_file_menu = menu = ctk_drop_down_menu_new(CTK_DROP_DOWN_MENU_FLAG_READONLY);
gtk_box_pack_start(GTK_BOX(hbox), menu, TRUE, TRUE, 0);
dialog->preview_changed_signal =
@@ -4402,8 +4372,8 @@ static void enabled_check_button_toggled(GtkToggleButton *toggle_button,
STATUSBAR_UPDATE_WARNING);
}
-GtkWidget* ctk_app_profile_new(CtkConfig *ctk_config,
- const gchar *driver_version)
+GtkWidget* ctk_app_profile_new(CtrlTarget *ctrl_target,
+ CtkConfig *ctk_config)
{
GObject *object;
CtkAppProfile *ctk_app_profile;
@@ -4415,6 +4385,7 @@ GtkWidget* ctk_app_profile_new(CtkConfig *ctk_config,
GtkWidget *rules_page, *profiles_page;
GtkWidget *toolbar;
+ gchar *driver_version;
char *global_config_file;
char *keys_file;
char **search_path;
@@ -4432,7 +4403,9 @@ GtkWidget* ctk_app_profile_new(CtkConfig *ctk_config,
gtk_box_set_spacing(GTK_BOX(ctk_app_profile), 10);
/* Load registry keys resource file */
+ driver_version = get_nvidia_driver_version(ctrl_target);
keys_file = get_default_keys_file(driver_version);
+ free(driver_version);
ctk_app_profile->key_docs = nv_app_profile_key_documentation_load(keys_file);
free(keys_file);
diff --git a/src/gtk+-2.x/ctkappprofile.h b/src/gtk+-2.x/ctkappprofile.h
index 6c1e8e6..3f59ca8 100644
--- a/src/gtk+-2.x/ctkappprofile.h
+++ b/src/gtk+-2.x/ctkappprofile.h
@@ -20,7 +20,6 @@
#ifndef __CTK_APP_PROFILE_H__
#define __CTK_APP_PROFILE_H__
-#include "NvCtrlAttributes.h"
#include "app-profiles.h"
#include "ctkevent.h"
#include "ctkconfig.h"
@@ -70,7 +69,6 @@ typedef struct _EditRuleDialog {
GtkEntry *matches_entry;
GtkWidget *profile_name_combo;
GtkListStore *profile_settings_store;
- GtkWidget *file_sel;
GtkWidget *add_edit_rule_button;
@@ -105,7 +103,6 @@ typedef struct _EditProfileDialog {
GtkWidget *generate_name_button;
GtkWidget *source_file_combo;
- GtkWidget *file_sel;
GtkWidget *add_edit_profile_button;
@@ -196,7 +193,7 @@ struct _CtkAppProfileClass
};
GType ctk_app_profile_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_app_profile_new (CtkConfig *, const gchar *);
+GtkWidget* ctk_app_profile_new (CtrlTarget *, CtkConfig *);
GtkTextBuffer* ctk_app_profile_create_help (CtkAppProfile *, GtkTextTagTable *);
char *serialize_settings(const json_t *settings, gboolean add_markup);
diff --git a/src/gtk+-2.x/ctkbanner.c b/src/gtk+-2.x/ctkbanner.c
index 0ed6678..368d5de 100644
--- a/src/gtk+-2.x/ctkbanner.c
+++ b/src/gtk+-2.x/ctkbanner.c
@@ -177,23 +177,14 @@ static gboolean ctk_banner_draw_event(
{
CtkBanner *ctk_banner = CTK_BANNER(widget);
cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget));
- cairo_rectangle_list_t *rects;
- int i;
/* copy the backing pixbuf into the exposed portion of the window */
- rects = cairo_copy_clip_rectangle_list(cr);
+ gdk_cairo_set_source_pixbuf(cr, ctk_banner->back.pixbuf, 0, 0);
+ cairo_paint(cr);
- for (i = 0; i < rects->num_rectangles; i++) {
- gdk_cairo_set_source_pixbuf(cr, ctk_banner->back.pixbuf,
- rects->rectangles[i].x,
- rects->rectangles[i].y);
- cairo_paint(cr);
- }
cairo_destroy(cr);
- g_free(rects);
-
return FALSE;
}
#else
diff --git a/src/gtk+-2.x/ctkclocks.c b/src/gtk+-2.x/ctkclocks.c
deleted file mode 100644
index 120b65c..0000000
--- a/src/gtk+-2.x/ctkclocks.c
+++ /dev/null
@@ -1,1343 +0,0 @@
-/*
- * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
- * and Linux systems.
- *
- * Copyright (C) 2004 NVIDIA Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses>.
- */
-
-/**** INCLUDES ***************************************************************/
-
-#include <gtk/gtk.h>
-#include <gdk/gdkx.h>
-
-#include "ctkbanner.h"
-
-#include "ctkclocks.h"
-
-#include "ctkscale.h"
-#include "ctkhelp.h"
-#include "ctkevent.h"
-#include "ctkconstants.h"
-#include "ctkdropdownmenu.h"
-#include "ctkutils.h"
-
-
-
-/**** DEFINES ****************************************************************/
-
-/* GUI padding space around frames */
-
-#define FRAME_PADDING 5
-
-
-
-/**** MACROS *****************************************************************/
-
-/* Setting/Getting GPU and Memory frequencies from packed int */
-
-#define GET_GPU_CLOCK(C) ( (C) >> 16 )
-#define GET_MEM_CLOCK(C) ( (C) & 0xFFFF )
-#define MAKE_CLOCKS(G, M) ( ((G) << 16) | ((M) & 0xFFFF) )
-
-
-
-/**** PROTOTYPES *************************************************************/
-
-static void overclocking_state_update_gui(CtkClocks *ctk_object);
-static void overclocking_state_toggled(GtkWidget *widget, gpointer user_data);
-static void overclocking_state_received(GObject *object, gpointer arg1,
- gpointer user_data);
-
-static void auto_detection_state_received(GObject *object, gpointer arg1,
- gpointer user_data);
-
-static void sync_gui_to_modify_clocks(CtkClocks *ctk_object, int which_clocks);
-
-static void set_clocks_value(CtkClocks *ctk_object, int clocks,
- int which_clocks);
-static void adjustment_value_changed(GtkAdjustment *adjustment,
- gpointer user_data);
-
-static void clock_menu_changed(GtkWidget *widget, gpointer user_data);
-
-static void apply_clocks_clicked(GtkWidget *widget, gpointer user_data);
-static void detect_clocks_clicked(GtkWidget *widget, gpointer user_data);
-static void reset_clocks_clicked(GtkWidget *widget, gpointer user_data);
-
-static void clocks_received(GObject *object, gpointer arg1,
- gpointer user_data);
-
-
-
-/**** GLOBALS ****************************************************************/
-
-/* Tooltips */
-
-static const char * __enable_button_help =
-"The Enable Overclocking checkbox enables access to GPU and graphics card "
-"memory interface overclocking functionality. Note that overclocking your "
-"GPU and/or graphics card memory interface is not recommended and is done "
-"at your own risk. You should never have to enable this.";
-
-static const char * __clock_menu_help =
-"Selects which clock frequencies to modify. Standard (2D) only affects 2D "
-"applications. Performance (3D) only affects 3D applications.";
-
-static const char * __graphics_clock_help =
-"The Graphics Clock Frequency is the core clock speed that the NVIDIA "
-"GPU will be set to when the graphics card is operating in this mode (2D/3D).";
-
-static const char * __mem_clock_help =
-"The Memory Clock Frequency is the clock speed of the memory interface on "
-"the graphics card. On some systems, the clock frequency is required to "
-"be the same for both 2D and 3D modes. For these systems, setting the 2D "
-"memory clock frequency will also set the 3D memory clock frequency.";
-
-static const char * __apply_button_help =
-"The Apply button allows you to set the desired clock frequencies for the "
-"GPU and graphics card memory interface. Slider positions are only applied "
-"after clicking this button.";
-
-static const char * __detect_button_help =
-"The Auto Detect button determines the maximum clock setting that is safe "
-"on your system at this instant. The maximum clock setting determined here "
-"can vary on consecutive runs and depends on how well the system handles the "
-"auto-detection stress tests. This is only available for 3D clock "
-"frequencies. You must click the Apply button to set the results found.";
-
-static const char * __cancel_button_help =
-"The Cancel Detection button allows you to cancel testing for the optimal 3D "
-"clock frequencies.";
-
-static const char * __reset_button_help =
-"The Reset Hardware Defaults button lets you restore the original GPU and "
-"memory interface clock frequencies.";
-
-
-/* Messages */
-
-static const char * __detect_confirm_msg =
-"To find the best 3D clock frequencies your system supports,\n"
-"a series of tests will take place. This testing may take several "
-"minutes.\n";
-
-
-static const char * __detect_wait_msg =
-"Optimal 3D clock frequencies are being probed, please wait...";
-
-static const char * __canceled_msg =
-"Probing for optimal 3D clock frequencies has been canceled.";
-
-
-
-/**** FUNCTIONS **************************************************************/
-
-/*****
- *
- * Returns the gpu overclocking ctk object type.
- *
- */
-GType ctk_clocks_get_type(void)
-{
- static GType ctk_object_type = 0;
-
- if (!ctk_object_type) {
- static const GTypeInfo ctk_object_info = {
- sizeof (CtkClocksClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- NULL, /* class_init */
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof(CtkClocks),
- 0, /* n_preallocs */
- NULL, /* instance_init */
- NULL /* value_table */
- };
-
- ctk_object_type = g_type_register_static
- (GTK_TYPE_VBOX, "CtkClocks", &ctk_object_info, 0);
- }
-
- return ctk_object_type;
-
-} /* ctk_clocks_get_type() */
-
-
-/*****
- *
- * Main CTK widget creation.
- *
- */
-GtkWidget* ctk_clocks_new(NvCtrlAttributeHandle *handle,
- CtkConfig *ctk_config,
- CtkEvent *ctk_event)
-{
- GObject *object;
- CtkClocks *ctk_object;
- GtkAdjustment *adjustment;
- GtkWidget *alignment;
- GtkWidget *scale;
- CtkDropDownMenu *menu;
-
- GtkWidget *label;
-
- GtkWidget *frame;
- GtkWidget *banner;
- GtkWidget *hbox;
- GtkWidget *vbox;
-
-
- ReturnStatus ret; /* NvCtrlxxx function return value */
- int value, i = 0;
- int clocks_2D;
- NVCTRLAttributeValidValuesRec ranges_2D;
- NVCTRLAttributeValidValuesRec range_detection;
- int clocks_3D;
- NVCTRLAttributeValidValuesRec ranges_3D;
-
- Bool overclocking_enabled;
- Bool auto_detection_available = FALSE;
- Bool probing_optimal = FALSE;
- Bool can_access_2d_clocks;
- Bool can_access_3d_clocks;
-
-
- /* Make sure we have a handle */
-
- g_return_val_if_fail(handle != NULL, NULL);
-
- /* If we can't query the overclocking state, don't load the page */
-
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_OVERCLOCKING_STATE,
- &value);
- if ( ret != NvCtrlSuccess )
- return NULL;
- overclocking_enabled =
- (value==NV_CTRL_GPU_OVERCLOCKING_STATE_MANUAL)?True:False;
-
- /* Check if overclocking is busy */
-
- if ( overclocking_enabled ) {
- ret = NvCtrlGetValidAttributeValues(handle,
- NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION,
- &range_detection);
- if ( ret == NvCtrlSuccess ) {
- ret = NvCtrlGetAttribute(handle,
- NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE,
- &value);
- if ( ret != NvCtrlSuccess )
- return NULL;
- probing_optimal =
- (value == NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_BUSY);
- auto_detection_available = TRUE;
- }
- }
-
- /* Can we access the 2D clocks? */
-
- can_access_2d_clocks = True;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_2D_CLOCK_FREQS, &clocks_2D);
- if ( ret != NvCtrlSuccess )
- can_access_2d_clocks = False;
- ret = NvCtrlGetValidAttributeValues(handle, NV_CTRL_GPU_2D_CLOCK_FREQS,
- &ranges_2D);
- if ( ret != NvCtrlSuccess )
- can_access_2d_clocks = False;
-
- /* Can we access the 3D clocks? */
-
- can_access_3d_clocks = True;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_3D_CLOCK_FREQS, &clocks_3D);
- if ( ret != NvCtrlSuccess )
- can_access_3d_clocks = False;
- ret = NvCtrlGetValidAttributeValues(handle, NV_CTRL_GPU_3D_CLOCK_FREQS,
- &ranges_3D);
- if ( ret != NvCtrlSuccess )
- can_access_3d_clocks = False;
-
- /* If we can't access either of the clocks, don't load the page */
-
- if ( !can_access_2d_clocks && !can_access_3d_clocks )
- return NULL;
-
- /* Create the ctk object */
-
- object = g_object_new(CTK_TYPE_CLOCKS, NULL);
- ctk_object = CTK_CLOCKS(object);
-
- /* Cache the handle and configuration */
-
- ctk_object->handle = handle;
- ctk_object->ctk_config = ctk_config;
- ctk_object->overclocking_enabled = overclocking_enabled;
- ctk_object->auto_detection_available = auto_detection_available;
- ctk_object->probing_optimal = probing_optimal;
-
- /* Create the Clock menu widget */
-
- menu = (CtkDropDownMenu *)
- ctk_drop_down_menu_new(CTK_DROP_DOWN_MENU_FLAG_READONLY);
- i = 0;
-
- if ( can_access_2d_clocks ) {
- ctk_drop_down_menu_append_item(menu, "2D Clock Frequencies", i++);
- }
-
- if ( can_access_3d_clocks ) {
- ctk_drop_down_menu_append_item(menu, "3D Clock Frequencies", i++);
- }
-
- ctk_object->clock_menu = GTK_WIDGET(menu);
-
- g_signal_connect(G_OBJECT(ctk_object->clock_menu), "changed",
- G_CALLBACK(clock_menu_changed),
- (gpointer) ctk_object);
-
- ctk_config_set_tooltip(ctk_config, ctk_object->clock_menu,
- __clock_menu_help);
-
- gtk_widget_set_sensitive(ctk_object->clock_menu,
- overclocking_enabled && !probing_optimal);
-
- /* Create the Graphics clock frequency slider widget */
-
- if ( can_access_2d_clocks ) {
- adjustment =
- GTK_ADJUSTMENT(gtk_adjustment_new(GET_GPU_CLOCK(clocks_2D),
- GET_GPU_CLOCK(ranges_2D.u.range.min),
- GET_GPU_CLOCK(ranges_2D.u.range.max),
- 1, 5, 0.0));
- ctk_object->clocks_being_modified = CLOCKS_2D;
- } else {
- adjustment =
- GTK_ADJUSTMENT(gtk_adjustment_new(GET_GPU_CLOCK(clocks_3D),
- GET_GPU_CLOCK(ranges_3D.u.range.min),
- GET_GPU_CLOCK(ranges_3D.u.range.max),
- 1, 5, 0.0));
- ctk_object->clocks_being_modified = CLOCKS_3D;
- }
-
- scale = ctk_scale_new(GTK_ADJUSTMENT(adjustment), "GPU (MHz)",
- ctk_config, G_TYPE_INT);
- ctk_object->gpu_clk_scale = scale;
-
- g_signal_connect(adjustment, "value_changed",
- G_CALLBACK(adjustment_value_changed),
- (gpointer) ctk_object);
-
- ctk_config_set_tooltip(ctk_config,
- CTK_SCALE(ctk_object->gpu_clk_scale)->gtk_scale,
- __graphics_clock_help);
-
- gtk_widget_set_sensitive(ctk_object->gpu_clk_scale,
- overclocking_enabled && !probing_optimal);
-
- /* Create the Memory clock frequency slider widget */
-
- if ( can_access_2d_clocks ) {
- adjustment =
- GTK_ADJUSTMENT(gtk_adjustment_new(GET_MEM_CLOCK(clocks_2D),
- GET_MEM_CLOCK(ranges_2D.u.range.min),
- GET_MEM_CLOCK(ranges_2D.u.range.max),
- 1, 5, 0.0));
- } else {
- adjustment =
- GTK_ADJUSTMENT(gtk_adjustment_new(GET_MEM_CLOCK(clocks_3D),
- GET_MEM_CLOCK(ranges_3D.u.range.min),
- GET_MEM_CLOCK(ranges_3D.u.range.max),
- 1, 5, 0.0));
- }
-
- scale = ctk_scale_new(GTK_ADJUSTMENT(adjustment), "Memory (MHz)",
- ctk_config, G_TYPE_INT);
- ctk_object->mem_clk_scale = scale;
-
- g_signal_connect(adjustment, "value_changed",
- G_CALLBACK(adjustment_value_changed),
- (gpointer) ctk_object);
-
- ctk_config_set_tooltip(ctk_config,
- CTK_SCALE(ctk_object->mem_clk_scale)->gtk_scale,
- __mem_clock_help);
-
- gtk_widget_set_sensitive(ctk_object->mem_clk_scale,
- overclocking_enabled && !probing_optimal);
-
- /* Create the Enable Overclocking checkbox widget */
-
- ctk_object->enable_checkbox =
- gtk_check_button_new_with_label("Enable Overclocking");
-
- gtk_toggle_button_set_active
- (GTK_TOGGLE_BUTTON(ctk_object->enable_checkbox),
- overclocking_enabled);
-
- gtk_widget_set_sensitive(ctk_object->enable_checkbox,
- overclocking_enabled && !probing_optimal);
-
- g_signal_connect(G_OBJECT(ctk_object->enable_checkbox), "toggled",
- G_CALLBACK(overclocking_state_toggled),
- (gpointer) ctk_object);
-
- ctk_config_set_tooltip(ctk_config, ctk_object->enable_checkbox,
- __enable_button_help);
-
- gtk_widget_set_sensitive(ctk_object->enable_checkbox, !probing_optimal);
-
- /* Create the Apply button widget */
-
- ctk_object->apply_button =
- gtk_button_new_with_label("Apply");
-
- g_signal_connect(G_OBJECT(ctk_object->apply_button), "clicked",
- G_CALLBACK(apply_clocks_clicked),
- (gpointer) ctk_object);
-
- ctk_config_set_tooltip(ctk_config, ctk_object->apply_button,
- __apply_button_help);
-
- gtk_widget_set_sensitive(ctk_object->apply_button, False);
-
- /* Create the Auto Detect button widget */
-
- ctk_object->detect_button =
- gtk_button_new_with_label("Auto Detect");
-
- g_signal_connect(G_OBJECT(ctk_object->detect_button), "clicked",
- G_CALLBACK(detect_clocks_clicked),
- (gpointer) ctk_object);
-
- ctk_config_set_tooltip(ctk_config, ctk_object->detect_button,
- __detect_button_help);
-
- if ( ctk_object->clocks_being_modified == CLOCKS_2D ) {
- gtk_widget_set_sensitive(ctk_object->detect_button, False);
- } else {
- gtk_widget_set_sensitive(ctk_object->detect_button,
- overclocking_enabled &&
- auto_detection_available && !probing_optimal);
- }
-
- /* Create the Reset hardware button widget */
-
- ctk_object->reset_button =
- gtk_button_new_with_label("Reset Hardware Defaults");
-
- g_signal_connect(G_OBJECT(ctk_object->reset_button), "clicked",
- G_CALLBACK(reset_clocks_clicked),
- (gpointer) ctk_object);
-
- ctk_config_set_tooltip(ctk_config, ctk_object->reset_button,
- __reset_button_help);
-
- gtk_widget_set_sensitive(ctk_object->reset_button, False);
-
- /* Create the auto detect dialog */
-
- ctk_object->detect_dialog =
- gtk_dialog_new_with_buttons("Auto Detect Optimal 3D Clock Frequencies?",
- GTK_WINDOW(gtk_widget_get_parent(GTK_WIDGET(ctk_object))),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_REJECT,
- NULL
- );
-
- label = gtk_label_new(__detect_confirm_msg);
- hbox = gtk_hbox_new(TRUE, 15);
-
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 15);
-
- gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area(
- GTK_DIALOG(ctk_object->detect_dialog))),
- hbox, FALSE, FALSE, 15);
-
- /*
- * Now that we've created all the widgets we care about, we're
- * ready to compose the panel
- */
-
- /* Set container properties of the ctk object */
-
- gtk_box_set_spacing(GTK_BOX(ctk_object), 10);
-
- banner = ctk_banner_image_new(BANNER_ARTWORK_CLOCK);
- gtk_box_pack_start(GTK_BOX(object), banner, FALSE, FALSE, 0);
-
- /* Add Overclocking checkbox */
-
- hbox = gtk_hbox_new(FALSE, 0);
-
- gtk_box_pack_start(GTK_BOX(object), hbox, FALSE, FALSE, 0);
-
- gtk_box_pack_start(GTK_BOX(hbox), ctk_object->enable_checkbox,
- FALSE, FALSE, 0);
-
- /* Add Clock frequency frame */
-
- frame = gtk_frame_new("Clock Frequencies");
- vbox = gtk_vbox_new(FALSE, 0);
- hbox = gtk_hbox_new(FALSE, 0);
-
- gtk_container_set_border_width(GTK_CONTAINER(vbox), FRAME_PADDING);
-
- gtk_box_pack_start(GTK_BOX(object), frame, FALSE, FALSE, 0);
- gtk_container_add(GTK_CONTAINER(frame), vbox);
-
-
- gtk_box_pack_start(GTK_BOX(hbox), ctk_object->clock_menu,
- FALSE, FALSE, 0);
-
- gtk_box_pack_start(GTK_BOX(vbox), hbox,
- FALSE, FALSE, 5);
-
- gtk_box_pack_start(GTK_BOX(vbox), ctk_object->gpu_clk_scale,
- FALSE, FALSE, 5);
-
- gtk_box_pack_start(GTK_BOX(vbox), ctk_object->mem_clk_scale,
- FALSE, FALSE, 5);
-
- /* Add the Apply, Auto Detect, and Reset buttons */
-
- hbox = gtk_hbox_new(FALSE, 5);
-
- gtk_box_pack_start(GTK_BOX(hbox), ctk_object->apply_button,
- FALSE, FALSE, 0);
- gtk_container_add(GTK_CONTAINER(hbox), ctk_object->detect_button);
- gtk_container_add(GTK_CONTAINER(hbox), ctk_object->reset_button);
-
- alignment = gtk_alignment_new(1, 1, 0, 0);
- gtk_container_add(GTK_CONTAINER(alignment), hbox);
- gtk_box_pack_start(GTK_BOX(object), alignment, TRUE, TRUE, 0);
-
- /* Setup the initial gui state */
-
- sync_gui_to_modify_clocks(ctk_object, ctk_object->clocks_being_modified);
-
- /* Handle events from other NV-CONTROL clients */
-
- g_signal_connect(G_OBJECT(ctk_event),
- CTK_EVENT_NAME(NV_CTRL_GPU_OVERCLOCKING_STATE),
- G_CALLBACK(overclocking_state_received),
- (gpointer) ctk_object);
-
- g_signal_connect(G_OBJECT(ctk_event),
- CTK_EVENT_NAME(NV_CTRL_GPU_2D_CLOCK_FREQS),
- G_CALLBACK(clocks_received),
- (gpointer) ctk_object);
-
- g_signal_connect(G_OBJECT(ctk_event),
- CTK_EVENT_NAME(NV_CTRL_GPU_3D_CLOCK_FREQS),
- G_CALLBACK(clocks_received),
- (gpointer) ctk_object);
-
- g_signal_connect(G_OBJECT(ctk_event),
- CTK_EVENT_NAME(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS),
- G_CALLBACK(clocks_received),
- (gpointer) ctk_object);
-
- g_signal_connect(G_OBJECT(ctk_event),
- CTK_EVENT_NAME(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE),
- G_CALLBACK(auto_detection_state_received),
- (gpointer) ctk_object);
-
- /* Show the widget */
-
- gtk_widget_show_all(GTK_WIDGET(ctk_object));
-
- return GTK_WIDGET(ctk_object);
-
-} /* ctk_clocks_new() */
-
-
-
-/*****
- *
- * GPU overclocking help screen.
- *
- */
-GtkTextBuffer *ctk_clocks_create_help(GtkTextTagTable *table,
- CtkClocks *ctk_object)
-{
- GtkTextIter i;
- GtkTextBuffer *b;
-
- b = gtk_text_buffer_new(table);
-
- gtk_text_buffer_get_iter_at_offset(b, &i, 0);
-
- ctk_help_title(b, &i, "Clock Frequency Overclocking Help");
- ctk_help_para(b, &i,
- "WARNING: Overclocking has the potential of destroying your "
- "graphics card, CPU, RAM and any other component. It may "
- "also reduce the life expectancy of your components and "
- "void manufacturer warranties. DO THIS AT YOUR OWN RISK."
- );
- ctk_help_heading(b, &i, "Enabling Clock Frequencies");
- ctk_help_para(b, &i, "%s", __enable_button_help);
- ctk_help_para(b, &i,
- "GPU Overclocking functionality is currently limited to "
- "GeForce FX and newer non-mobile GPUs."
- );
- ctk_help_heading(b, &i, "2D/3D Clock Frequencies");
- ctk_help_para(b, &i,
- "The 2D clock frequencies are the standard clock "
- "frequencies used when only 2D applications are running."
- );
- ctk_help_para(b, &i,
- "The 3D clock frequencies are the performance clock "
- "frequencies used when running 3D applications."
- );
- ctk_help_heading(b, &i, "Graphics Clock Frequency");
- ctk_help_para(b, &i, "%s", __graphics_clock_help);
- ctk_help_heading(b, &i, "Memory Clock Frequency");
- ctk_help_para(b, &i, "%s", __mem_clock_help);
- ctk_help_heading(b, &i, "Applying Custom Clock Frequencies");
- ctk_help_para(b, &i, "%s", __apply_button_help);
- ctk_help_heading(b, &i, "Auto Detect Optimal 3D Clock Frequencies");
- ctk_help_para(b, &i, "%s", __detect_button_help);
- ctk_help_heading(b, &i, "Canceling Optimal 3D Clock Frequency Auto-"
- "detection.");
- ctk_help_para(b, &i, "%s", __cancel_button_help);
- ctk_help_para(b, &i,
- "This button is only available if the Optimal "
- "clocks are currently being probed.");
- ctk_help_heading(b, &i, "Restoring Hardware Default Frequencies");
- ctk_help_para(b, &i, "%s", __reset_button_help);
-
- ctk_help_finish(b);
-
- return b;
-
-} /* ctk_clocks_create_help() */
-
-
-
-/****
- *
- * Updates sensitivity of widgets in relation to the state
- * of overclocking.
- *
- */
-static void sync_gui_sensitivity(CtkClocks *ctk_object)
-{
- gboolean enabled = ctk_object->overclocking_enabled;
- gboolean probing = ctk_object->probing_optimal;
- gboolean modified = ctk_object->clocks_modified;
- gboolean moved = ctk_object->clocks_moved;
-
-
- /* Update the enable checkbox */
-
- g_signal_handlers_block_by_func(G_OBJECT(ctk_object->enable_checkbox),
- G_CALLBACK(overclocking_state_toggled),
- (gpointer) ctk_object);
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctk_object->enable_checkbox),
- enabled);
-
- g_signal_handlers_unblock_by_func(G_OBJECT(ctk_object->enable_checkbox),
- G_CALLBACK(overclocking_state_toggled),
- (gpointer) ctk_object);
-
- gtk_widget_set_sensitive(ctk_object->enable_checkbox,
- !probing);
-
-
- /* Update the clock selection dropdown */
-
- gtk_widget_set_sensitive(ctk_object->clock_menu, enabled && !probing);
-
- /* Update the Graphics clock slider */
-
- gtk_widget_set_sensitive(ctk_object->gpu_clk_scale, enabled && !probing);
-
- /* Update the Memory clock slider */
-
- gtk_widget_set_sensitive(ctk_object->mem_clk_scale, enabled && !probing);
-
- /* Update the Apply button */
-
- gtk_widget_set_sensitive(ctk_object->apply_button,
- enabled && !probing && moved);
-
-
- /* Enable the Auto Detect button for 3D clocks only */
-
- if ( probing ) {
- gtk_button_set_label(GTK_BUTTON(ctk_object->detect_button), "Cancel Detection");
- gtk_widget_set_sensitive(ctk_object->detect_button, True);
- ctk_config_set_tooltip(ctk_object->ctk_config, ctk_object->detect_button,
- __cancel_button_help);
-
- } else {
- gboolean set_sensitive;
- gtk_button_set_label(GTK_BUTTON(ctk_object->detect_button), "Auto Detect");
- set_sensitive = ((ctk_object->auto_detection_available) &&
- (ctk_object->clocks_being_modified == CLOCKS_3D))
- ? enabled : False;
- gtk_widget_set_sensitive(ctk_object->detect_button, set_sensitive);
- ctk_config_set_tooltip(ctk_object->ctk_config, ctk_object->detect_button,
- __detect_button_help);
- }
-
- /* Update the Reset hardware defaults button */
-
- gtk_widget_set_sensitive(ctk_object->reset_button,
- enabled && !probing && (moved || modified));
-
-} /* sync_gui_sensitivity() */
-
-
-
-/****
- *
- * Updates widgets in relation to current overclocking state.
- *
- */
-static void overclocking_state_update_gui(CtkClocks *ctk_object)
-{
- ReturnStatus ret;
- int value;
- NVCTRLAttributeValidValuesRec range_detection;
- gboolean probing_optimal = TRUE;
- gboolean enabled;
-
-
- /* We need to check the overclocking state status with
- * the server every time someone tries to change the state
- * because the set might have failed.
- */
-
- ret = NvCtrlGetAttribute(ctk_object->handle,
- NV_CTRL_GPU_OVERCLOCKING_STATE,
- &value);
- if ( ret != NvCtrlSuccess )
- enabled = False;
- else
- enabled = (value==NV_CTRL_GPU_OVERCLOCKING_STATE_MANUAL)?True:False;
-
- ctk_object->overclocking_enabled = enabled;
-
-
- /* We need to also make sure the server is not busy probing
- * for the optimal clocks.
- */
-
- if ( enabled ) {
- ret = NvCtrlGetValidAttributeValues(ctk_object->handle,
- NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION,
- &range_detection);
- if ( ret == NvCtrlSuccess ) {
- ret = NvCtrlGetAttribute(ctk_object->handle,
- NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE,
- &value);
- if ( ret == NvCtrlSuccess ) {
- probing_optimal =
- (value == NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_BUSY);
- }
- ctk_object->probing_optimal = probing_optimal;
-
- ctk_object->auto_detection_available = TRUE;
- }
- }
-
- /* Sync the gui to be able to modify the clocks */
-
- sync_gui_to_modify_clocks(ctk_object, ctk_object->clocks_being_modified);
-
- /* Update the status bar */
-
- ctk_config_statusbar_message(ctk_object->ctk_config,
- "GPU overclocking %sabled.",
- enabled?"en":"dis");
-
-} /* overclocking_state_update_gui() */
-
-
-
-/*****
- *
- * Signal handler - Called when the user toggles the "Enable Overclocking"
- * button.
- *
- */
-static void overclocking_state_toggled(GtkWidget *widget, gpointer user_data)
-{
- CtkClocks *ctk_object = CTK_CLOCKS(user_data);
- gboolean enabled;
- int value;
-
- /* Get enabled state */
-
- enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
-
- value = (enabled==1) ? NV_CTRL_GPU_OVERCLOCKING_STATE_MANUAL :
- NV_CTRL_GPU_OVERCLOCKING_STATE_NONE;
-
- /* Update the server */
-
- NvCtrlSetAttribute(ctk_object->handle,
- NV_CTRL_GPU_OVERCLOCKING_STATE, value);
-
- /* Update the GUI */
-
- overclocking_state_update_gui(ctk_object);
-
-} /* enable_overclocking_toggled() */
-
-
-
-/*****
- *
- * Signal handler - Called when another NV-CONTROL client has set the
- * overclocking state.
- *
- */
-static void overclocking_state_received(GObject *object,
- gpointer arg1, gpointer user_data)
-{
- CtkClocks *ctk_object = CTK_CLOCKS(user_data);
-
- /* Update GUI with enable status */
-
- overclocking_state_update_gui(ctk_object);
-
-} /* overclocking_state_update_received() */
-
-
-
-/*****
- *
- * Signal handler - Called when overclocking becomes busy due to
- * an NV-CONTROL client probing for the optimal clocks.
- *
- */
-static void auto_detection_state_received(GObject *object,
- gpointer arg1, gpointer user_data)
-{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
- CtkClocks *ctk_object = CTK_CLOCKS(user_data);
-
-
- /* Update GUI with probing status */
-
- ctk_object->probing_optimal =
- (event_struct->value == NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_BUSY);
- sync_gui_sensitivity(ctk_object);
-
- /* Update the status bar */
-
- if ( ctk_object->probing_optimal ) {
- ctk_config_statusbar_message(ctk_object->ctk_config, "%s",
- __detect_wait_msg);
- } else {
- ctk_config_statusbar_message(ctk_object->ctk_config, "%s",
- __canceled_msg);
- }
-
-} /* auto_detection_state_received() */
-
-
-
-/*****
- *
- * Syncs the gui to properly display the correct clocks the user wants to
- * modify, or has modified with another NV_CONTROL client.
- *
- */
-static void sync_gui_to_modify_clocks(CtkClocks *ctk_object, int which_clocks)
-{
- GtkRange *gtk_range;
- GtkAdjustment *gtk_adjustment_gpu;
- GtkAdjustment *gtk_adjustment_mem;
-
- ReturnStatus ret;
- int clk_values;
- int default_clk_values;
- NVCTRLAttributeValidValuesRec clk_ranges;
- CtkDropDownMenu *menu;
-
- menu = CTK_DROP_DOWN_MENU(ctk_object->clock_menu);
-
-
- /* Obtain the current value and range of the desired clocks */
-
- switch (which_clocks) {
- case CLOCKS_2D:
- ret = NvCtrlGetAttribute(ctk_object->handle,
- NV_CTRL_GPU_2D_CLOCK_FREQS, &clk_values);
- if ( ret != NvCtrlSuccess )
- return;
- ret = NvCtrlGetValidAttributeValues(ctk_object->handle,
- NV_CTRL_GPU_2D_CLOCK_FREQS,
- &clk_ranges);
- if ( ret != NvCtrlSuccess )
- return;
- break;
-
- case CLOCKS_3D:
- ret = NvCtrlGetAttribute(ctk_object->handle,
- NV_CTRL_GPU_3D_CLOCK_FREQS, &clk_values);
- if ( ret != NvCtrlSuccess )
- return;
- ret = NvCtrlGetValidAttributeValues(ctk_object->handle,
- NV_CTRL_GPU_3D_CLOCK_FREQS,
- &clk_ranges);
- if ( ret != NvCtrlSuccess )
- return;
- break;
-
- case CLOCKS_NONE:
- default:
- return;
- }
-
-
- /* See if the clocks were modified */
-
- ret = NvCtrlGetAttribute(ctk_object->handle,
- which_clocks==CLOCKS_2D?
- NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS:
- NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS,
- &default_clk_values);
-
- ctk_object->clocks_modified =
- ((ret == NvCtrlSuccess) && (default_clk_values != clk_values));
-
- if ( ctk_object->clocks_being_modified != which_clocks ) {
- ctk_object->clocks_moved = False;
- }
-
- ctk_object->clocks_being_modified = which_clocks;
-
-
- /* Make sure the dropdown reflects the right clock set */
-
- g_signal_handlers_block_by_func(G_OBJECT(ctk_object->clock_menu),
- G_CALLBACK(clock_menu_changed),
- (gpointer) ctk_object);
-
- ctk_drop_down_menu_set_current_value(menu, (which_clocks==CLOCKS_2D)?0:1);
-
- g_signal_handlers_unblock_by_func(G_OBJECT(ctk_object->clock_menu),
- G_CALLBACK(clock_menu_changed),
- (gpointer) ctk_object);
-
-
- /* Make GPU and Memory clocks reflect the right range/values */
-
- gtk_range = GTK_RANGE(CTK_SCALE(ctk_object->gpu_clk_scale)->gtk_scale);
- gtk_adjustment_gpu = gtk_range_get_adjustment(gtk_range);
-
- g_signal_handlers_block_by_func(G_OBJECT(gtk_adjustment_gpu),
- G_CALLBACK(adjustment_value_changed),
- (gpointer) ctk_object);
- gtk_range_set_range(gtk_range,
- GET_GPU_CLOCK(clk_ranges.u.range.min),
- GET_GPU_CLOCK(clk_ranges.u.range.max));
-
- g_signal_handlers_unblock_by_func(G_OBJECT(gtk_adjustment_gpu),
- G_CALLBACK(adjustment_value_changed),
- (gpointer) ctk_object);
-
- gtk_range = GTK_RANGE(CTK_SCALE(ctk_object->mem_clk_scale)->gtk_scale);
- gtk_adjustment_mem = gtk_range_get_adjustment(gtk_range);
-
- g_signal_handlers_block_by_func(G_OBJECT(gtk_adjustment_mem),
- G_CALLBACK(adjustment_value_changed),
- (gpointer) ctk_object);
- gtk_range_set_range(gtk_range,
- GET_MEM_CLOCK(clk_ranges.u.range.min),
- GET_MEM_CLOCK(clk_ranges.u.range.max));
-
- set_clocks_value(ctk_object, clk_values, which_clocks);
-
- g_signal_handlers_unblock_by_func(G_OBJECT(gtk_adjustment_mem),
- G_CALLBACK(adjustment_value_changed),
- (gpointer) ctk_object);
-
- /* Update the gui sensitivity */
-
- sync_gui_sensitivity(ctk_object);
-
-} /* sync_gui_to_modify_clocks() */
-
-
-
-/*****
- *
- * Helper function - Sets the value of the clock frequencies scales
- *
- */
-static void set_clocks_value(CtkClocks *ctk_object, int clocks,
- int which_clocks)
-{
- GtkRange *gtk_range;
-
-
- /* Update the clock values */
-
- if ( ctk_object->gpu_clk_scale ) {
- gtk_range = GTK_RANGE(CTK_SCALE(ctk_object->gpu_clk_scale)->gtk_scale);
- gtk_range_set_value(gtk_range, GET_GPU_CLOCK(clocks));
- }
-
- if ( ctk_object->mem_clk_scale ) {
- gtk_range = GTK_RANGE(CTK_SCALE(ctk_object->mem_clk_scale)->gtk_scale);
- gtk_range_set_value(gtk_range, GET_MEM_CLOCK(clocks));
- }
-
-} /* set_clocks_value() */
-
-
-
-/*****
- *
- * Signal handler - Handles slider adjustments by the user.
- *
- */
-static void adjustment_value_changed(GtkAdjustment *adjustment,
- gpointer user_data)
-{
- CtkClocks *ctk_object = CTK_CLOCKS(user_data);
-
-
- /* Enable the apply button */
-
- gtk_widget_set_sensitive(ctk_object->apply_button, True);
-
-
- /* Enable the reset button */
-
- gtk_widget_set_sensitive(ctk_object->reset_button, True);
-
-
- /* Set the clocks moved flag */
-
- ctk_object->clocks_moved = True;
-
-} /* adjustment_value_changed() */
-
-
-
-/*****
- *
- * Signal handler - User selected a clock set from the clock menu.
- *
- */
-static void clock_menu_changed(GtkWidget *widget, gpointer user_data)
-{
- CtkClocks *ctk_object = CTK_CLOCKS(user_data);
- CtkDropDownMenu *menu = CTK_DROP_DOWN_MENU(widget);
- gint history;
-
-
- /* Sync to allow user to modify the clocks */
-
- history = ctk_drop_down_menu_get_current_value(menu);
- switch (history) {
- default:
- /* Fall through */
- case 0: /* 2D */
- sync_gui_to_modify_clocks(ctk_object, CLOCKS_2D);
- break;
- case 1: /* 3D */
- sync_gui_to_modify_clocks(ctk_object, CLOCKS_3D);
- break;
- }
-
-} /* clock_menu_changed() */
-
-
-
-/*****
- *
- * Signal handler - User clicked the "apply" button.
- *
- */
-static void apply_clocks_clicked(GtkWidget *widget, gpointer user_data)
-{
- CtkClocks *ctk_object = CTK_CLOCKS(user_data);
- GtkRange *gtk_range;
-
- ReturnStatus ret;
- int gpu_clk;
- int mem_clk;
- int clocks;
-
-
- /* Update server clocks with values from scales */
-
- if ( !ctk_object->gpu_clk_scale || !ctk_object->mem_clk_scale )
- return;
-
-
- /* Get new clock values from sliders */
-
- gtk_range = GTK_RANGE(CTK_SCALE(ctk_object->gpu_clk_scale)->gtk_scale);
- gpu_clk = gtk_range_get_value(gtk_range);
- gtk_range = GTK_RANGE(CTK_SCALE(ctk_object->mem_clk_scale)->gtk_scale);
- mem_clk = gtk_range_get_value(gtk_range);
- clocks = MAKE_CLOCKS(gpu_clk, mem_clk);
-
-
- /* Set clocks on server */
-
- ret = NvCtrlSetAttribute(ctk_object->handle,
- (ctk_object->clocks_being_modified==CLOCKS_2D) ?
- NV_CTRL_GPU_2D_CLOCK_FREQS :
- NV_CTRL_GPU_3D_CLOCK_FREQS,
- clocks);
- if ( ret != NvCtrlSuccess ) {
- ctk_config_statusbar_message(ctk_object->ctk_config,
- "Failed to set clock frequencies!");
- return;
- }
-
-
- /* Clear the clocks moved flag */
-
- ctk_object->clocks_moved = False;
-
-
- /* Sync up with the server */
-
- sync_gui_to_modify_clocks(ctk_object, ctk_object->clocks_being_modified);
-
- gtk_range = GTK_RANGE(CTK_SCALE(ctk_object->gpu_clk_scale)->gtk_scale);
- gpu_clk = gtk_range_get_value(gtk_range);
- gtk_range = GTK_RANGE(CTK_SCALE(ctk_object->mem_clk_scale)->gtk_scale);
- mem_clk = gtk_range_get_value(gtk_range);
-
- ctk_config_statusbar_message(ctk_object->ctk_config,
- "Set %s clocks to (GPU) %i MHz, "
- "(Memory) %i MHz",
- (ctk_object->clocks_being_modified==CLOCKS_2D)?
- "2D":"3D",
- gpu_clk,
- mem_clk);
-
-} /* apply_clocks_clicked() */
-
-
-
-/*****
- *
- * Signal handler - User clicked the 'reset hardware defaults' button.
- *
- */
-static void reset_clocks_clicked(GtkWidget *widget, gpointer user_data)
-{
- CtkClocks *ctk_object = CTK_CLOCKS(user_data);
- int clocks;
- ReturnStatus ret;
-
-
- /* Get the default clock frequencies */
-
- ret = NvCtrlGetAttribute(ctk_object->handle,
- (ctk_object->clocks_being_modified==CLOCKS_2D) ?
- NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS :
- NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS,
- &clocks);
- if ( ret != NvCtrlSuccess )
- goto fail;
-
- /* Set clock frequencies to use default values */
-
- ret = NvCtrlSetAttribute(ctk_object->handle,
- (ctk_object->clocks_being_modified==CLOCKS_2D) ?
- NV_CTRL_GPU_2D_CLOCK_FREQS :
- NV_CTRL_GPU_3D_CLOCK_FREQS,
- clocks);
- if ( ret != NvCtrlSuccess )
- goto fail;
-
- /* Set slider positions */
-
- set_clocks_value(ctk_object, clocks, ctk_object->clocks_being_modified);
-
- ctk_config_statusbar_message(ctk_object->ctk_config,
- "Reset %s clock frequency "
- "hardware defaults.",
- (ctk_object->clocks_being_modified==CLOCKS_2D)?
- "2D":"3D");
-
- /* Disable the apply button */
-
- gtk_widget_set_sensitive(ctk_object->apply_button, False);
-
- /* Disable the reset button */
-
- gtk_widget_set_sensitive(ctk_object->reset_button, False);
-
- return;
-
-
- fail:
- ctk_config_statusbar_message(ctk_object->ctk_config,
- "Failed to reset clock frequencies!");
- return;
-
-} /* reset_clocks_clicked() */
-
-
-
-/*****
- *
- * Signal handler - User clicked the 'auto detect/cancel' button.
- *
- */
-static void detect_clocks_clicked(GtkWidget *widget, gpointer user_data)
-{
- CtkClocks *ctk_object = CTK_CLOCKS(user_data);
- gint result;
-
-
- if ( ctk_object->probing_optimal ) {
-
- /* Stop the test for optimal clock freqs */
- NvCtrlSetAttribute(ctk_object->handle,
- NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION,
- NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_CANCEL);
- } else {
-
- /* User must hit the OK button to start the testing */
-
- gtk_widget_show_all(ctk_object->detect_dialog);
- result = gtk_dialog_run (GTK_DIALOG (ctk_object->detect_dialog));
- gtk_widget_hide(ctk_object->detect_dialog);
-
- switch (result)
- {
- case GTK_RESPONSE_ACCEPT:
-
- /* Start the test for optimal clock freqs */
- NvCtrlSetAttribute(ctk_object->handle,
- NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION,
- NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_START);
- break;
-
- case GTK_RESPONSE_REJECT:
- default:
- /* Do nothing. */
- return;
- }
- }
-
- return;
-
-} /* detect_clocks_clicked() */
-
-
-
-/*****
- *
- * Signal handler - Handles incoming NV-CONTROL messages caused by clocks
- * being changed.
- *
- */
-static void clocks_received(GObject *object, gpointer arg1,
- gpointer user_data)
-{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
- CtkClocks *ctk_object = CTK_CLOCKS(user_data);
- int clocks = event_struct->value;
-
- /* Some hardware requires that the memory clocks be the same for
- * both the 2D and 3D clock frequency setting. Therefore, we
- * always need to check what the current clocks we're modifying
- * have been set to on clock events.
- */
-
- switch (event_struct->attribute) {
- case NV_CTRL_GPU_2D_CLOCK_FREQS:
- sync_gui_to_modify_clocks(ctk_object, CLOCKS_2D);
-
- ctk_config_statusbar_message(ctk_object->ctk_config,
- "Set 2D clocks to (GPU) %i MHz, "
- "(Memory) %i MHz",
- GET_GPU_CLOCK(clocks),
- GET_MEM_CLOCK(clocks));
- break;
- case NV_CTRL_GPU_3D_CLOCK_FREQS:
- sync_gui_to_modify_clocks(ctk_object, CLOCKS_3D);
-
- ctk_config_statusbar_message(ctk_object->ctk_config,
- "Set 3D clocks to (GPU) %i MHz, "
- "(Memory) %i MHz",
- GET_GPU_CLOCK(clocks),
- GET_MEM_CLOCK(clocks));
- break;
- case NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS:
- ctk_object->probing_optimal = False;
-
- ctk_config_statusbar_message(ctk_object->ctk_config,
- "Found optimal 3D clocks: (GPU) %i MHz, "
- "(Memory) %i MHz",
- GET_GPU_CLOCK(clocks),
- GET_MEM_CLOCK(clocks));
-
- /* Only update gui if user is on 3D clocks */
-
- if ( ctk_object->clocks_being_modified == CLOCKS_3D ) {
-
- /* Update clock values */
-
- set_clocks_value(ctk_object, clocks, CLOCKS_3D);
-
- /* Allow user to apply the settings */
-
- if ( ctk_object->apply_button )
- gtk_widget_set_sensitive(ctk_object->apply_button, True);
- }
-
- break;
- default:
- break;
- }
-
-} /* clocks_received() */
-
-
-
-/*****
- *
- * Callback Function - This function gets called when the GPU Overclocking
- * page gets selected from the tree view.
- *
- */
-void ctk_clocks_select(GtkWidget *widget)
-{
- CtkClocks *ctk_object = CTK_CLOCKS(widget);
- ReturnStatus ret;
- int value;
-
- /* See if we're busy probing for optimal clocks so we can tell the user */
-
- ret = NvCtrlGetAttribute(ctk_object->handle,
- NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE,
- &value);
-
- if ( ret == NvCtrlSuccess &&
- value == NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_BUSY ) {
- ctk_config_statusbar_message(ctk_object->ctk_config, "%s",
- __detect_wait_msg);
- }
-}
diff --git a/src/gtk+-2.x/ctkclocks.h b/src/gtk+-2.x/ctkclocks.h
deleted file mode 100644
index 872a04e..0000000
--- a/src/gtk+-2.x/ctkclocks.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
- * and Linux systems.
- *
- * Copyright (C) 2004 NVIDIA Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses>.
- */
-
-#ifndef __CTK_CLOCKS_H__
-#define __CTK_CLOCKS_H__
-
-#include "ctkevent.h"
-#include "ctkconfig.h"
-
-G_BEGIN_DECLS
-
-#define CTK_TYPE_CLOCKS (ctk_clocks_get_type())
-
-#define CTK_CLOCKS(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), CTK_TYPE_CLOCKS, CtkClocks))
-
-#define CTK_CLOCKS_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), CTK_TYPE_CLOCKS, CtkClocksClass))
-
-#define CTK_IS_CLOCKS(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CTK_TYPE_CLOCKS))
-
-#define CTK_IS_CLOCKS_CLASS(class) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), CTK_TYPE_CLOCKS))
-
-#define CTK_CLOCKS_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), CTK_TYPE_CLOCKS, CtkClocksClass))
-
-#define CLOCKS_NONE 0
-#define CLOCKS_2D 2
-#define CLOCKS_3D 3
-
-
-typedef struct _CtkClocks CtkClocks;
-typedef struct _CtkClocksClass CtkClocksClass;
-
-struct _CtkClocks
-{
- GtkVBox parent;
-
- NvCtrlAttributeHandle *handle;
- CtkConfig *ctk_config;
-
- GtkWidget *detect_dialog;
-
- GtkWidget *enable_checkbox; /* Overclocking available */
- GtkWidget *clock_menu; /* 2D/3D dropdown selector */
-
- GtkWidget *gpu_clk_scale; /* Current 2D or 3D clock sliders */
- GtkWidget *mem_clk_scale;
-
- GtkWidget *apply_button; /* Apply target clock frequencies */
- GtkWidget *detect_button; /* Auto detects best 3D clock frequencies */
- GtkWidget *reset_button; /* Reset hardware default frequencies */
-
- int clocks_being_modified; /* Wether we're editing the 2D or 3D clocks */
- Bool clocks_modified; /* The clocks were modified by the user */
- Bool clocks_moved; /* The clock sliders were moved by the user */
-
- Bool overclocking_enabled; /* Overclocking is enabled */
- Bool auto_detection_available; /* Optimal clock detection is available */
- Bool probing_optimal; /* Optimal clocks being probed */
-};
-
-struct _CtkClocksClass
-{
- GtkVBoxClass parent_class;
-};
-
-GType ctk_clocks_get_type (void) G_GNUC_CONST;
-GtkWidget *ctk_clocks_new (NvCtrlAttributeHandle *, CtkConfig *,
- CtkEvent *);
-
-GtkTextBuffer *ctk_clocks_create_help (GtkTextTagTable *, CtkClocks *);
-
-void ctk_clocks_select (GtkWidget *widget);
-
-G_END_DECLS
-
-#endif /* __CTK_CLOCKS_H__ */
diff --git a/src/gtk+-2.x/ctkcolorcontrols.c b/src/gtk+-2.x/ctkcolorcontrols.c
index b3249f8..c57bf56 100644
--- a/src/gtk+-2.x/ctkcolorcontrols.c
+++ b/src/gtk+-2.x/ctkcolorcontrols.c
@@ -57,7 +57,7 @@ static void color_space_menu_changed(GtkWidget *widget,
static void color_range_menu_changed(GtkWidget *widget,
gpointer user_data);
-static void color_control_update_received(GObject *object, gpointer arg1,
+static void color_control_update_received(GObject *object, CtrlEvent *event,
gpointer user_data);
static void setup_color_range_dropdown(CtkColorControls *ctk_color_controls);
static
@@ -137,7 +137,7 @@ static void ctk_color_controls_finalize(GObject *object)
-GtkWidget* ctk_color_controls_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_color_controls_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
CtkEvent *ctk_event,
GtkWidget *reset_button,
@@ -153,10 +153,10 @@ GtkWidget* ctk_color_controls_new(NvCtrlAttributeHandle *handle,
gint i;
/* check if color configuration is supported */
- ret1 = NvCtrlGetValidAttributeValues(handle,
+ ret1 = NvCtrlGetValidAttributeValues(ctrl_target,
NV_CTRL_COLOR_SPACE,
&valid1);
- ret2 = NvCtrlGetValidAttributeValues(handle,
+ ret2 = NvCtrlGetValidAttributeValues(ctrl_target,
NV_CTRL_COLOR_RANGE,
&valid2);
@@ -171,7 +171,7 @@ GtkWidget* ctk_color_controls_new(NvCtrlAttributeHandle *handle,
}
ctk_color_controls = CTK_COLOR_CONTROLS(object);
- ctk_color_controls->handle = handle;
+ ctk_color_controls->ctrl_target = ctrl_target;
ctk_color_controls->ctk_config = ctk_config;
ctk_color_controls->ctk_event = ctk_event;
ctk_color_controls->reset_button = reset_button;
@@ -373,11 +373,12 @@ void ctk_color_controls_setup(CtkColorControls *ctk_color_controls)
static gboolean update_color_space_menu_info(CtkColorControls *ctk_color_controls)
{
+ CtrlTarget *ctrl_target = ctk_color_controls->ctrl_target;
gint color_space = NV_CTRL_COLOR_SPACE_RGB;
/* color space */
if (NvCtrlSuccess !=
- NvCtrlGetAttribute(ctk_color_controls->handle,
+ NvCtrlGetAttribute(ctrl_target,
NV_CTRL_COLOR_SPACE,
&color_space)) {
return FALSE;
@@ -444,13 +445,14 @@ static void color_range_menu_changed(GtkWidget *widget,
{
CtkColorControls *ctk_color_controls =
CTK_COLOR_CONTROLS(user_data);
+ CtrlTarget *ctrl_target = ctk_color_controls->ctrl_target;
CtkDropDownMenu *menu = CTK_DROP_DOWN_MENU(widget);
gint history, color_range = NV_CTRL_COLOR_RANGE_FULL;
history = ctk_drop_down_menu_get_current_value(menu);
color_range = ctk_color_controls->color_range_table[history];
- NvCtrlSetAttribute(ctk_color_controls->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_COLOR_RANGE,
color_range);
@@ -465,6 +467,7 @@ static void color_space_menu_changed(GtkWidget *widget,
{
CtkColorControls *ctk_color_controls =
CTK_COLOR_CONTROLS(user_data);
+ CtrlTarget *ctrl_target = ctk_color_controls->ctrl_target;
CtkDropDownMenu *menu = CTK_DROP_DOWN_MENU(widget);
gint history, color_space = NV_CTRL_COLOR_SPACE_RGB;
@@ -472,7 +475,7 @@ static void color_space_menu_changed(GtkWidget *widget,
color_space = ctk_color_controls->color_space_table[history];
- NvCtrlSetAttribute(ctk_color_controls->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_COLOR_SPACE,
color_space);
@@ -493,15 +496,19 @@ static void color_space_menu_changed(GtkWidget *widget,
*/
void ctk_color_controls_reset(CtkColorControls *ctk_color_controls)
{
+ CtrlTarget *ctrl_target;
+
if (!ctk_color_controls) {
return;
}
- NvCtrlSetAttribute(ctk_color_controls->handle,
+ ctrl_target = ctk_color_controls->ctrl_target;
+
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_COLOR_SPACE,
NV_CTRL_COLOR_SPACE_RGB);
- NvCtrlSetAttribute(ctk_color_controls->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_COLOR_RANGE,
NV_CTRL_COLOR_RANGE_FULL);
@@ -536,20 +543,26 @@ void add_color_controls_help(CtkColorControls *ctk_color_controls,
* we should update the GUI to reflect the current color range
* and color space.
*/
-static void color_control_update_received(GObject *object, gpointer arg1,
+static void color_control_update_received(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
CtkColorControls *ctk_object = CTK_COLOR_CONTROLS(user_data);
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
+
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
ctk_color_controls_setup(ctk_object);
/* update status bar message */
- switch (event_struct->attribute) {
+ switch (event->int_attr.attribute) {
case NV_CTRL_COLOR_RANGE:
- post_color_range_update(ctk_object, event_struct->value); break;
+ post_color_range_update(ctk_object, event->int_attr.value);
+ break;
case NV_CTRL_COLOR_SPACE:
- post_color_space_update(ctk_object, event_struct->value); break;
+ post_color_space_update(ctk_object, event->int_attr.value);
+ break;
}
} /* color_control_update_received() */
@@ -600,6 +613,7 @@ static gboolean build_color_space_table(CtkColorControls *ctk_color_controls,
*/
static void setup_color_range_dropdown(CtkColorControls *ctk_color_controls)
{
+ CtrlTarget *ctrl_target = ctk_color_controls->ctrl_target;
gint i, n = 0, color_range_count = 0;
gint mask, val;
gboolean enable = FALSE;
@@ -607,7 +621,7 @@ static void setup_color_range_dropdown(CtkColorControls *ctk_color_controls)
NVCTRLAttributeValidValuesRec valid;
CtkDropDownMenu *d;
- ret = NvCtrlGetValidAttributeValues(ctk_color_controls->handle,
+ ret = NvCtrlGetValidAttributeValues(ctrl_target,
NV_CTRL_COLOR_RANGE,
&valid);
if (ret != NvCtrlSuccess) {
@@ -666,7 +680,7 @@ static void setup_color_range_dropdown(CtkColorControls *ctk_color_controls)
/* color range */
if (NvCtrlSuccess !=
- NvCtrlGetAttribute(ctk_color_controls->handle,
+ NvCtrlGetAttribute(ctrl_target,
NV_CTRL_COLOR_RANGE,
&val)) {
val = NV_CTRL_COLOR_RANGE_FULL;
diff --git a/src/gtk+-2.x/ctkcolorcontrols.h b/src/gtk+-2.x/ctkcolorcontrols.h
index 8888af0..abeb9f5 100644
--- a/src/gtk+-2.x/ctkcolorcontrols.h
+++ b/src/gtk+-2.x/ctkcolorcontrols.h
@@ -52,7 +52,7 @@ struct _CtkColorControls
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
CtkEvent *ctk_event;
GtkWidget *reset_button;
@@ -76,7 +76,7 @@ struct _CtkColorControlsClass
};
GType ctk_color_controls_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_color_controls_new (NvCtrlAttributeHandle *,
+GtkWidget* ctk_color_controls_new (CtrlTarget *,
CtkConfig *, CtkEvent *,
GtkWidget *,
char *);
diff --git a/src/gtk+-2.x/ctkcolorcorrection.c b/src/gtk+-2.x/ctkcolorcorrection.c
index 1ad24cc..d94b310 100644
--- a/src/gtk+-2.x/ctkcolorcorrection.c
+++ b/src/gtk+-2.x/ctkcolorcorrection.c
@@ -92,7 +92,7 @@ apply_parsed_attribute_list(CtkColorCorrection *, ParsedAttribute *);
static gboolean
do_confirm_countdown (gpointer);
-static void callback_palette_update(GObject *object, gpointer arg1,
+static void callback_palette_update(GObject *object, CtrlEvent *event,
gpointer user_data);
static void
@@ -183,6 +183,7 @@ ctk_color_correction_class_init(CtkColorCorrectionClass
static void ctk_color_correction_finalize(GObject *object)
{
CtkColorCorrection *ctk_color_correction = CTK_COLOR_CORRECTION(object);
+ CtrlTarget *ctrl_target = ctk_color_correction->ctrl_target;
if (ctk_color_correction->confirm_timer) {
/*
@@ -214,7 +215,7 @@ static void ctk_color_correction_finalize(GObject *object)
}
}
- NvCtrlSetColorAttributes(ctk_color_correction->handle,
+ NvCtrlSetColorAttributes(ctrl_target,
ctk_color_correction->cur_slider_val[CONTRAST],
ctk_color_correction->cur_slider_val[BRIGHTNESS],
ctk_color_correction->cur_slider_val[GAMMA],
@@ -234,8 +235,9 @@ static void ctk_color_correction_finalize(GObject *object)
-GtkWidget* ctk_color_correction_new(NvCtrlAttributeHandle *handle,
- CtkConfig *ctk_config, ParsedAttribute *p,
+GtkWidget* ctk_color_correction_new(CtrlTarget *ctrl_target,
+ CtkConfig *ctk_config,
+ ParsedAttribute *p,
CtkEvent *ctk_event)
{
GObject *object;
@@ -265,7 +267,7 @@ GtkWidget* ctk_color_correction_new(NvCtrlAttributeHandle *handle,
object = g_object_new(CTK_TYPE_COLOR_CORRECTION, NULL);
ctk_color_correction = CTK_COLOR_CORRECTION(object);
- ctk_color_correction->handle = handle;
+ ctk_color_correction->ctrl_target = ctrl_target;
ctk_color_correction->ctk_config = ctk_config;
ctk_color_correction->ctk_event = ctk_event;
ctk_color_correction->confirm_timer = 0;
@@ -362,7 +364,7 @@ GtkWidget* ctk_color_correction_new(NvCtrlAttributeHandle *handle,
alignment = gtk_alignment_new(0, 0, 1.0, 1.0);
gtk_box_pack_start(GTK_BOX(leftvbox), alignment, TRUE, TRUE, 0);
- curve = ctk_curve_new(handle, GTK_WIDGET(ctk_color_correction));
+ curve = ctk_curve_new(ctrl_target, GTK_WIDGET(ctk_color_correction));
eventbox = gtk_event_box_new();
gtk_container_add(GTK_CONTAINER(eventbox), curve);
gtk_container_add(GTK_CONTAINER(alignment), eventbox);
@@ -909,14 +911,14 @@ static void flush_attribute_channel_values(
gint channel
)
{
- NvCtrlAttributeHandle *handle = ctk_color_correction->handle;
-
- NvCtrlSetColorAttributes(handle,
+ CtrlTarget *ctrl_target = ctk_color_correction->ctrl_target;
+
+ NvCtrlSetColorAttributes(ctrl_target,
ctk_color_correction->cur_slider_val[CONTRAST],
ctk_color_correction->cur_slider_val[BRIGHTNESS],
ctk_color_correction->cur_slider_val[GAMMA],
attribute | channel);
-
+
gtk_widget_hide(ctk_color_correction->warning_container);
g_signal_emit(ctk_color_correction, signals[CHANGED], 0);
@@ -928,10 +930,12 @@ static void apply_parsed_attribute_list(
ParsedAttribute *p
)
{
+ CtrlTarget *ctrl_target = ctk_color_correction->ctrl_target;
int target_type, target_id;
unsigned int attr = 0;
+
ctk_color_correction->num_expected_updates = 0;
-
+
set_color_state(ctk_color_correction, CONTRAST, ALL_CHANNELS,
CONTRAST_DEFAULT, TRUE);
set_color_state(ctk_color_correction, BRIGHTNESS, ALL_CHANNELS,
@@ -939,21 +943,21 @@ static void apply_parsed_attribute_list(
set_color_state(ctk_color_correction, GAMMA, ALL_CHANNELS,
GAMMA_DEFAULT, TRUE);
- target_type = NvCtrlGetTargetType(ctk_color_correction->handle);
- target_id = NvCtrlGetTargetId(ctk_color_correction->handle);
+ target_type = NvCtrlGetTargetType(ctrl_target);
+ target_id = NvCtrlGetTargetId(ctrl_target);
while (p) {
- CtrlHandleTargetNode *node;
+ CtrlTargetNode *node;
const AttributeTableEntry *a = p->attr_entry;
if (!p->next) goto next_attribute;
- if (a->type != NV_PARSER_ATTRIBUTE_TYPE_COLOR) {
+ if (a->type != CTRL_ATTRIBUTE_TYPE_COLOR) {
if (a->attr == NV_CTRL_COLOR_SPACE ||
a->attr == NV_CTRL_COLOR_RANGE) {
for (node = p->targets; node ; node = node->next) {
- int attr_target_type = NvCtrlGetTargetType(node->t->h);
- int attr_target_id = NvCtrlGetTargetId(node->t->h);
+ int attr_target_type = NvCtrlGetTargetType(node->t);
+ int attr_target_id = NvCtrlGetTargetId(node->t);
if ((attr_target_type == target_type) &&
(attr_target_id == target_id)) {
@@ -972,8 +976,8 @@ static void apply_parsed_attribute_list(
for (node = p->targets; node; node = node->next) {
- int attr_target_type = NvCtrlGetTargetType(node->t->h);
- int attr_target_id = NvCtrlGetTargetId(node->t->h);
+ int attr_target_type = NvCtrlGetTargetType(node->t);
+ int attr_target_id = NvCtrlGetTargetId(node->t);
if ((attr_target_type != target_type) ||
(attr_target_id != target_id)) {
@@ -1057,7 +1061,7 @@ static void apply_parsed_attribute_list(
ctk_color_correction->num_expected_updates++;
- NvCtrlSetColorAttributes(ctk_color_correction->handle,
+ NvCtrlSetColorAttributes(ctrl_target,
ctk_color_correction->cur_slider_val[CONTRAST],
ctk_color_correction->cur_slider_val[BRIGHTNESS],
ctk_color_correction->cur_slider_val[GAMMA],
@@ -1209,11 +1213,13 @@ void ctk_color_correction_tab_help(GtkTextBuffer *b, GtkTextIter *i,
}
-static void callback_palette_update(GObject *object, gpointer arg1,
+static void callback_palette_update(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
gboolean reload_needed;
CtkColorCorrection *ctk_color_correction = (CtkColorCorrection *)user_data;
+ CtrlTarget *ctrl_target = ctk_color_correction->ctrl_target;
reload_needed = (ctk_color_correction->num_expected_updates <= 0);
@@ -1222,7 +1228,7 @@ static void callback_palette_update(GObject *object, gpointer arg1,
}
if (reload_needed) {
- NvCtrlReloadColorRamp(ctk_color_correction->handle);
+ NvCtrlReloadColorRamp(ctrl_target);
ctk_curve_color_changed(ctk_color_correction->curve);
gtk_widget_set_sensitive(ctk_color_correction->reset_button, TRUE);
diff --git a/src/gtk+-2.x/ctkcolorcorrection.h b/src/gtk+-2.x/ctkcolorcorrection.h
index e148cbb..5c90d8a 100644
--- a/src/gtk+-2.x/ctkcolorcorrection.h
+++ b/src/gtk+-2.x/ctkcolorcorrection.h
@@ -53,7 +53,7 @@ typedef struct _CtkColorCorrectionClass CtkColorCorrectionClass;
struct _CtkColorCorrection
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
CtkEvent *ctk_event;
GtkWidget *color_channel;
@@ -81,7 +81,7 @@ struct _CtkColorCorrectionClass
};
GType ctk_color_correction_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_color_correction_new (NvCtrlAttributeHandle *,
+GtkWidget* ctk_color_correction_new (CtrlTarget *,
CtkConfig *, ParsedAttribute *,
CtkEvent *);
GtkTextBuffer *ctk_color_correction_create_help(GtkTextTagTable *);
diff --git a/src/gtk+-2.x/ctkcolorcorrectionpage.c b/src/gtk+-2.x/ctkcolorcorrectionpage.c
index 46b0d2f..75abb74 100644
--- a/src/gtk+-2.x/ctkcolorcorrectionpage.c
+++ b/src/gtk+-2.x/ctkcolorcorrectionpage.c
@@ -62,7 +62,7 @@ GType ctk_color_correction_page_get_type(
}
-GtkWidget* ctk_color_correction_page_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_color_correction_page_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
ParsedAttribute *p,
CtkEvent *ctk_event)
@@ -76,22 +76,22 @@ GtkWidget* ctk_color_correction_page_new(NvCtrlAttributeHandle *handle,
/* check if the VidMode extension is present */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_ATTR_EXT_VM_PRESENT, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_ATTR_EXT_VM_PRESENT, &val);
if ((ret != NvCtrlSuccess) || (val == FALSE)) {
return NULL;
}
/* check if the noScanout mode enabled */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_NO_SCANOUT, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_NO_SCANOUT, &val);
if ((ret == NvCtrlSuccess) && (val == NV_CTRL_NO_SCANOUT_ENABLED)) {
return NULL;
}
/* allocate the color correction widget */
- ctk_color_correction =
- ctk_color_correction_new(handle, ctk_config, p, ctk_event);
+ ctk_color_correction = ctk_color_correction_new(ctrl_target, ctk_config,
+ p, ctk_event);
if (ctk_color_correction == NULL) {
return NULL;
diff --git a/src/gtk+-2.x/ctkcolorcorrectionpage.h b/src/gtk+-2.x/ctkcolorcorrectionpage.h
index a90e198..9627c4a 100644
--- a/src/gtk+-2.x/ctkcolorcorrectionpage.h
+++ b/src/gtk+-2.x/ctkcolorcorrectionpage.h
@@ -53,7 +53,6 @@ typedef struct _CtkColorCorrectionPageClass CtkColorCorrectionPageClass;
struct _CtkColorCorrectionPage
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
CtkConfig *ctk_config;
GtkWidget *option_menu;
GtkAdjustment *brightness_adjustment;
@@ -76,9 +75,8 @@ struct _CtkColorCorrectionPageClass
};
GType ctk_color_correction_page_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_color_correction_page_new (NvCtrlAttributeHandle *,
- CtkConfig *, ParsedAttribute *,
- CtkEvent *);
+GtkWidget* ctk_color_correction_page_new (CtrlTarget *, CtkConfig *,
+ ParsedAttribute *, CtkEvent *);
GtkTextBuffer *ctk_color_correction_page_create_help(GtkTextTagTable *);
G_END_DECLS
diff --git a/src/gtk+-2.x/ctkconfig.c b/src/gtk+-2.x/ctkconfig.c
index 5e78021..b07b6e8 100644
--- a/src/gtk+-2.x/ctkconfig.c
+++ b/src/gtk+-2.x/ctkconfig.c
@@ -154,7 +154,7 @@ void ctk_statusbar_init(CtkStatusBar *status_bar)
#endif
}
-GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlHandles *pCtrlHandles)
+GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlSystem *pCtrlSystem)
{
gint i;
GObject *object;
@@ -221,7 +221,7 @@ GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlHandles *pCtrlHandles)
ctk_config = CTK_CONFIG(object);
ctk_config->conf = conf;
- ctk_config->pCtrlHandles = pCtrlHandles;
+ ctk_config->pCtrlSystem = pCtrlSystem;
gtk_box_set_spacing(GTK_BOX(ctk_config), 10);
@@ -314,24 +314,15 @@ GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlHandles *pCtrlHandles)
gtk_box_pack_start(GTK_BOX(ctk_config), alignment, TRUE, TRUE, 0);
/* Create the file selector for rc file */
- ctk_config->rc_file_selector =
- gtk_file_chooser_dialog_new("Please select a file to save to",
- GTK_WINDOW(ctk_get_parent_window(GTK_WIDGET(ctk_config))),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- "Cancel", GTK_RESPONSE_CANCEL,
- "Open", GTK_RESPONSE_ACCEPT,
- NULL);
-
g_signal_connect(G_OBJECT(ctk_config->button_save_rc), "clicked",
G_CALLBACK(save_rc_clicked),
(gpointer) ctk_config);
- gtk_file_chooser_set_filename
- (GTK_FILE_CHOOSER(ctk_config->rc_file_selector), DEFAULT_RC_FILE);
-
ctk_config_set_tooltip(ctk_config, ctk_config->button_save_rc,
__save_current_config_help);
+ ctk_config->rc_filename = NULL;
+
gtk_widget_show_all(GTK_WIDGET(ctk_config));
return GTK_WIDGET(ctk_config);
@@ -344,28 +335,28 @@ GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlHandles *pCtrlHandles)
static void save_rc_clicked(GtkWidget *widget, gpointer user_data)
{
- gint result;
- const gchar *rc_filename = NULL;
+ gchar *filename = NULL;
CtkConfig *ctk_config = CTK_CONFIG(user_data);
CtkWindow *ctk_window =
CTK_WINDOW(ctk_get_parent_window(GTK_WIDGET(ctk_config)));
- result = gtk_dialog_run(GTK_DIALOG(ctk_config->rc_file_selector));
- gtk_widget_hide(ctk_config->rc_file_selector);
+ filename =
+ ctk_get_filename_from_dialog("Please select a file to save to.",
+ GTK_WINDOW(ctk_window),
+ ctk_config->rc_filename ?
+ ctk_config->rc_filename :
+ DEFAULT_RC_FILE);
- switch (result) {
- case GTK_RESPONSE_ACCEPT:
- case GTK_RESPONSE_OK:
- rc_filename = gtk_file_chooser_get_filename
- (GTK_FILE_CHOOSER(ctk_config->rc_file_selector));
- break;
- default:
+ if (!filename) {
return;
}
+ g_free(ctk_config->rc_filename);
+ ctk_config->rc_filename = filename;
+
/* write the configuration file */
add_special_config_file_attributes(ctk_window);
- nv_write_config_file(rc_filename, ctk_config->pCtrlHandles,
+ nv_write_config_file(ctk_config->rc_filename, ctk_config->pCtrlSystem,
ctk_window->attribute_list, ctk_config->conf);
}
diff --git a/src/gtk+-2.x/ctkconfig.h b/src/gtk+-2.x/ctkconfig.h
index c631bbc..fb1a148 100644
--- a/src/gtk+-2.x/ctkconfig.h
+++ b/src/gtk+-2.x/ctkconfig.h
@@ -89,9 +89,9 @@ struct _CtkConfig
GtkWidget *timer_list;
GtkWidget *timer_list_box;
GtkWidget *button_save_rc;
- GtkWidget *rc_file_selector;
+ gchar *rc_filename;
gboolean timer_list_visible;
- CtrlHandles *pCtrlHandles;
+ CtrlSystem *pCtrlSystem;
GList *help_data;
};
@@ -101,7 +101,7 @@ struct _CtkConfigClass
};
GType ctk_config_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_config_new (ConfigProperties *, CtrlHandles*);
+GtkWidget* ctk_config_new (ConfigProperties *, CtrlSystem *);
void ctk_config_statusbar_message (CtkConfig *, const char *, ...) NV_ATTRIBUTE_PRINTF(2, 3);
GtkWidget* ctk_config_get_statusbar (CtkConfig *);
void ctk_config_set_tooltip (CtkConfig *, GtkWidget *,
diff --git a/src/gtk+-2.x/ctkcurve.c b/src/gtk+-2.x/ctkcurve.c
index e843ac6..cac3828 100644
--- a/src/gtk+-2.x/ctkcurve.c
+++ b/src/gtk+-2.x/ctkcurve.c
@@ -324,7 +324,7 @@ void ctk_curve_color_changed(GtkWidget *widget)
}
}
-GtkWidget* ctk_curve_new(NvCtrlAttributeHandle *handle, GtkWidget *color)
+GtkWidget* ctk_curve_new(CtrlTarget *ctrl_target, GtkWidget *color)
{
GObject *object;
CtkCurve *ctk_curve;
@@ -337,7 +337,7 @@ GtkWidget* ctk_curve_new(NvCtrlAttributeHandle *handle, GtkWidget *color)
ctk_curve = CTK_CURVE(object);
- ctk_curve->handle = handle;
+ ctk_curve->ctrl_target = ctrl_target;
ctk_curve->color = color;
#ifdef CTK_GTK3
@@ -378,6 +378,7 @@ GtkWidget* ctk_curve_new(NvCtrlAttributeHandle *handle, GtkWidget *color)
static void draw(CtkCurve *ctk_curve)
{
+ CtrlTarget *ctrl_target = ctk_curve->ctrl_target;
gushort *lut;
gint n_lut_entries;
@@ -394,17 +395,17 @@ static void draw(CtkCurve *ctk_curve)
cairo_set_operator(ctk_curve->c_context, CAIRO_OPERATOR_ADD);
cairo_set_source_rgba(ctk_curve->c_context, 1.0, 0.0, 0.0, 1.0);
- NvCtrlGetColorRamp(ctk_curve->handle, RED_CHANNEL, &lut, &n_lut_entries);
+ NvCtrlGetColorRamp(ctrl_target, RED_CHANNEL, &lut, &n_lut_entries);
plot_color_ramp(ctk_curve->c_context, lut, n_lut_entries,
ctk_curve->width, ctk_curve->height);
cairo_set_source_rgba(ctk_curve->c_context, 0.0, 1.0, 0.0, 1.0);
- NvCtrlGetColorRamp(ctk_curve->handle, GREEN_CHANNEL, &lut, &n_lut_entries);
+ NvCtrlGetColorRamp(ctrl_target, GREEN_CHANNEL, &lut, &n_lut_entries);
plot_color_ramp(ctk_curve->c_context, lut, n_lut_entries,
ctk_curve->width, ctk_curve->height);
cairo_set_source_rgba(ctk_curve->c_context, 0.0, 0.0, 1.0, 1.0);
- NvCtrlGetColorRamp(ctk_curve->handle, BLUE_CHANNEL, &lut, &n_lut_entries);
+ NvCtrlGetColorRamp(ctrl_target, BLUE_CHANNEL, &lut, &n_lut_entries);
plot_color_ramp(ctk_curve->c_context, lut, n_lut_entries,
ctk_curve->width, ctk_curve->height);
#else
@@ -418,17 +419,17 @@ static void draw(CtkCurve *ctk_curve)
gdk_gc_set_function(ctk_curve->gdk_gc, GDK_XOR);
gdk_gc_set_foreground(ctk_curve->gdk_gc, &ctk_curve->gdk_color_red);
- NvCtrlGetColorRamp(ctk_curve->handle, RED_CHANNEL, &lut, &n_lut_entries);
+ NvCtrlGetColorRamp(ctrl_target, RED_CHANNEL, &lut, &n_lut_entries);
plot_color_ramp(ctk_curve->gdk_pixmap, ctk_curve->gdk_gc,
lut, n_lut_entries, ctk_curve->width, ctk_curve->height);
gdk_gc_set_foreground(ctk_curve->gdk_gc, &ctk_curve->gdk_color_green);
- NvCtrlGetColorRamp(ctk_curve->handle, GREEN_CHANNEL, &lut, &n_lut_entries);
+ NvCtrlGetColorRamp(ctrl_target, GREEN_CHANNEL, &lut, &n_lut_entries);
plot_color_ramp(ctk_curve->gdk_pixmap, ctk_curve->gdk_gc,
lut, n_lut_entries, ctk_curve->width, ctk_curve->height);
gdk_gc_set_foreground(ctk_curve->gdk_gc, &ctk_curve->gdk_color_blue);
- NvCtrlGetColorRamp(ctk_curve->handle, BLUE_CHANNEL, &lut, &n_lut_entries);
+ NvCtrlGetColorRamp(ctrl_target, BLUE_CHANNEL, &lut, &n_lut_entries);
plot_color_ramp(ctk_curve->gdk_pixmap, ctk_curve->gdk_gc,
lut, n_lut_entries, ctk_curve->width, ctk_curve->height);
#endif
diff --git a/src/gtk+-2.x/ctkcurve.h b/src/gtk+-2.x/ctkcurve.h
index 3bb8875..443f424 100644
--- a/src/gtk+-2.x/ctkcurve.h
+++ b/src/gtk+-2.x/ctkcurve.h
@@ -49,7 +49,7 @@ struct _CtkCurve
{
GtkDrawingArea parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
GtkWidget *color;
#ifdef CTK_GTK3
@@ -75,7 +75,7 @@ struct _CtkCurveClass
};
GType ctk_curve_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_curve_new (NvCtrlAttributeHandle *, GtkWidget *);
+GtkWidget* ctk_curve_new (CtrlTarget *, GtkWidget *);
void ctk_curve_color_changed(GtkWidget *);
G_END_DECLS
diff --git a/src/gtk+-2.x/ctkdisplayconfig-utils.c b/src/gtk+-2.x/ctkdisplayconfig-utils.c
index 48ab4ae..5e6987b 100644
--- a/src/gtk+-2.x/ctkdisplayconfig-utils.c
+++ b/src/gtk+-2.x/ctkdisplayconfig-utils.c
@@ -331,10 +331,12 @@ static nvModeLinePtr modeline_parse(nvDisplayPtr display,
else {
nv_warning_msg("Invalid modeline keyword '%s' in modeline '%s'",
tmp, modeline_str);
+ free(tmp);
goto fail;
}
free(tmp);
}
+ free(tmp);
modeline->refresh_rate = 0;
if (display->is_sdi && gpu->num_gvo_modes) {
@@ -905,15 +907,17 @@ static gchar *mode_get_str(nvModePtr mode, int force_target_id_name)
gchar *mode_str;
gchar *tmp;
gchar *flags_str;
- nvDisplayPtr display = mode->display;
+ nvDisplayPtr display;
nvScreenPtr screen;
nvGpuPtr gpu;
/* Make sure the mode has everything it needs to be displayed */
- if (!mode || !mode->metamode || !display) {
+ if (!mode || !mode->metamode || !mode->display) {
return NULL;
}
+ display = mode->display;
+
/* Don't include dummy modes */
if (mode->dummy && !mode->modeline) {
return NULL;
@@ -1429,6 +1433,7 @@ Bool display_add_modelines_from_server(nvDisplayPtr display, nvGpuPtr gpu,
ReturnStatus ret, ret1;
int major = 0, minor = 0;
int broken_doublescan_modelines;
+ CtrlTarget *ctrl_target = display->ctrl_target;
/*
* check the version of the NV-CONTROL protocol -- versions <=
@@ -1440,9 +1445,9 @@ Bool display_add_modelines_from_server(nvDisplayPtr display, nvGpuPtr gpu,
*/
broken_doublescan_modelines = 1;
- ret = NvCtrlGetAttribute(display->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_ATTR_NV_MAJOR_VERSION, &major);
- ret1 = NvCtrlGetAttribute(display->handle,
+ ret1 = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_ATTR_NV_MINOR_VERSION, &minor);
if ((ret == NvCtrlSuccess) && (ret1 == NvCtrlSuccess) &&
@@ -1456,13 +1461,13 @@ Bool display_add_modelines_from_server(nvDisplayPtr display, nvGpuPtr gpu,
/* Get the validated modelines for the display */
- ret = NvCtrlGetBinaryAttribute(display->handle, 0,
+ ret = NvCtrlGetBinaryAttribute(ctrl_target, 0,
NV_CTRL_BINARY_DATA_MODELINES,
(unsigned char **)&modeline_strs, &len);
if (ret != NvCtrlSuccess) {
*err_str = g_strdup_printf("Failed to query modelines of display "
"device %d '%s'.",
- NvCtrlGetTargetId(display->handle),
+ NvCtrlGetTargetId(ctrl_target),
display->logName);
nv_error_msg("%s", *err_str);
goto fail;
@@ -1479,7 +1484,7 @@ Bool display_add_modelines_from_server(nvDisplayPtr display, nvGpuPtr gpu,
*err_str = g_strdup_printf("Failed to parse the following "
"modeline of display device\n"
"%d '%s' :\n\n%s",
- NvCtrlGetTargetId(display->handle),
+ NvCtrlGetTargetId(ctrl_target),
display->logName,
str);
nv_error_msg("%s", *err_str);
@@ -1495,14 +1500,14 @@ Bool display_add_modelines_from_server(nvDisplayPtr display, nvGpuPtr gpu,
str += strlen(str) +1;
}
- XFree(modeline_strs);
+ free(modeline_strs);
return TRUE;
/* Handle the failure case */
fail:
display_remove_modelines(display);
- XFree(modeline_strs);
+ free(modeline_strs);
return FALSE;
} /* display_add_modelines_from_server() */
@@ -1594,13 +1599,13 @@ static void display_free(nvDisplayPtr display)
if (display) {
display_remove_modes(display);
display_remove_modelines(display);
- XFree(display->logName);
- XFree(display->typeBaseName);
- XFree(display->typeIdName);
- XFree(display->dpGuidName);
- XFree(display->edidHashName);
- XFree(display->targetIdName);
- XFree(display->randrName);
+ free(display->logName);
+ free(display->typeBaseName);
+ free(display->typeIdName);
+ free(display->dpGuidName);
+ free(display->edidHashName);
+ free(display->targetIdName);
+ free(display->randrName);
free(display);
}
@@ -1818,39 +1823,28 @@ void screen_unlink_display(nvDisplayPtr display)
static void screen_link_displays(nvScreenPtr screen)
{
- ReturnStatus ret;
- int *pData;
- int len;
- int i;
+ CtrlTargetNode *node;
- ret = NvCtrlGetBinaryAttribute
- (screen->handle, 0, NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN,
- (unsigned char **)(&pData), &len);
-
- if (ret != NvCtrlSuccess) {
- nv_warning_msg("Failed to query list of displays assigned to X screen "
- " %d.",
- NvCtrlGetTargetId(screen->handle));
- return;
- }
-
- // For each id in pData
- for (i = 0; i < pData[0]; i++) {
+ for (node = screen->ctrl_target->relations; node; node = node->next) {
+ CtrlTarget *ctrl_target = node->t;
nvDisplayPtr display;
- display = layout_get_display(screen->layout, pData[i+1]);
+ if (NvCtrlGetTargetType(ctrl_target) != DISPLAY_TARGET) {
+ continue;
+ }
+
+ display = layout_get_display(screen->layout,
+ NvCtrlGetTargetId(ctrl_target));
if (!display) {
nv_warning_msg("Failed to find display %d assigned to X screen "
" %d.",
- pData[i+1],
- NvCtrlGetTargetId(screen->handle));
+ NvCtrlGetTargetId(ctrl_target),
+ NvCtrlGetTargetId(screen->ctrl_target));
continue;
}
screen_link_display(screen, display);
}
-
- XFree(pData);
}
@@ -1970,15 +1964,11 @@ gchar *screen_get_metamode_str(nvScreenPtr screen, int metamode_idx,
void cleanup_metamode(nvMetaModePtr metamode)
{
- if (metamode->cpl_str) {
- free(metamode->cpl_str);
- metamode->cpl_str = NULL;
- }
+ free(metamode->cpl_str);
+ metamode->cpl_str = NULL;
- if (metamode->x_str) {
- XFree(metamode->x_str);
- metamode->x_str = NULL;
- }
+ free(metamode->x_str);
+ metamode->x_str = NULL;
metamode->x_str_entry = NULL;
}
@@ -2326,7 +2316,7 @@ static Bool screen_add_metamodes(nvScreenPtr screen, gchar **err_str)
/* Get the list of metamodes for the screen */
- ret = NvCtrlGetBinaryAttribute(screen->handle, 0,
+ ret = NvCtrlGetBinaryAttribute(screen->ctrl_target, 0,
NV_CTRL_BINARY_DATA_METAMODES_VERSION_2,
(unsigned char **)&metamode_strs,
&len);
@@ -2339,7 +2329,7 @@ static Bool screen_add_metamodes(nvScreenPtr screen, gchar **err_str)
/* Get the current metamode for the screen */
- ret = NvCtrlGetStringAttribute(screen->handle,
+ ret = NvCtrlGetStringAttribute(screen->ctrl_target,
NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2,
&cur_metamode_str);
if (ret != NvCtrlSuccess) {
@@ -2379,7 +2369,7 @@ static Bool screen_add_metamodes(nvScreenPtr screen, gchar **err_str)
/* Make sure each display device gets a mode */
screen_check_metamodes(screen);
}
- XFree(metamode_strs);
+ free(metamode_strs);
metamode_strs = NULL;
if (!screen->metamodes) {
@@ -2419,7 +2409,7 @@ static Bool screen_add_metamodes(nvScreenPtr screen, gchar **err_str)
/* Remove modes we may have added */
screen_remove_metamodes(screen);
- XFree(metamode_strs);
+ free(metamode_strs);
return FALSE;
} /* screen_add_metamodes() */
@@ -2434,19 +2424,16 @@ static Bool screen_add_metamodes(nvScreenPtr screen, gchar **err_str)
static void screen_free(nvScreenPtr screen)
{
if (screen) {
+ ctk_event_destroy(G_OBJECT(screen->ctk_event));
screen_remove_metamodes(screen);
screen_remove_displays(screen);
- if (screen->handle) {
- NvCtrlAttributeClose(screen->handle);
- }
-
nvfree(screen->gpus);
screen->num_gpus = 0;
- XFree(screen->sli_mode);
- XFree(screen->multigpu_mode);
+ free(screen->sli_mode);
+ free(screen->multigpu_mode);
free(screen);
}
@@ -2490,7 +2477,7 @@ void link_screen_to_gpu(nvScreenPtr screen, nvGpuPtr gpu)
/* Set the display owner GPU. */
if (screen->display_owner_gpu_id >= 0) {
/* Link to the multi GPU display owner, if it is specified */
- if (screen->display_owner_gpu_id == NvCtrlGetTargetId(gpu->handle)) {
+ if (screen->display_owner_gpu_id == NvCtrlGetTargetId(gpu->ctrl_target)) {
screen->display_owner_gpu = gpu;
}
} else if (gpu->multigpu_master_possible &&
@@ -2647,15 +2634,15 @@ static Bool gpu_query_gvo_mode_info(nvGpuPtr gpu, int mode_id, int table_idx)
data = &(gpu->gvo_mode_data[table_idx]);
- ret1 = NvCtrlGetDisplayAttribute(gpu->handle,
+ ret1 = NvCtrlGetDisplayAttribute(gpu->ctrl_target,
mode_id,
NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE,
- &(rate));
+ &rate);
- ret2 = NvCtrlGetStringDisplayAttribute(gpu->handle,
+ ret2 = NvCtrlGetStringDisplayAttribute(gpu->ctrl_target,
mode_id,
NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME,
- &(name));
+ &name);
if ((ret1 == NvCtrlSuccess) && (ret2 == NvCtrlSuccess)) {
data->id = mode_id;
@@ -2664,7 +2651,7 @@ static Bool gpu_query_gvo_mode_info(nvGpuPtr gpu, int mode_id, int table_idx)
return TRUE;
}
- XFree(name);
+ free(name);
return FALSE;
}
@@ -2705,7 +2692,7 @@ static Bool display_add_name_from_server(nvDisplayPtr display,
ReturnStatus ret;
char *str;
- ret = NvCtrlGetStringAttribute(display->handle,
+ ret = NvCtrlGetStringAttribute(display->ctrl_target,
displayNameInfo->attr,
&str);
if (ret == NvCtrlSuccess) {
@@ -2715,7 +2702,7 @@ static Bool display_add_name_from_server(nvDisplayPtr display,
*err_str = g_strdup_printf("Failed to query name '%s' of display "
"device DPY-%d.",
displayNameInfo->nameDescription,
- NvCtrlGetTargetId(display->handle));
+ NvCtrlGetTargetId(display->ctrl_target));
nv_error_msg("%s", *err_str);
return FALSE;
}
@@ -2730,9 +2717,9 @@ static Bool display_add_name_from_server(nvDisplayPtr display,
* Adds the display with the device id given to the GPU structure.
*
**/
-nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
- unsigned int display_id,
- gchar **err_str)
+static nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
+ CtrlTarget *ctrl_target,
+ gchar **err_str)
{
ReturnStatus ret;
nvDisplayPtr display;
@@ -2743,21 +2730,7 @@ nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
display = (nvDisplayPtr)calloc(1, sizeof(nvDisplay));
if (!display) goto fail;
-
- /* Make an NV-CONTROL handle to talk to the display */
- display->handle =
- NvCtrlAttributeInit(NvCtrlGetDisplayPtr(gpu->handle),
- NV_CTRL_TARGET_TYPE_DISPLAY,
- display_id,
- NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM);
- if (!display->handle) {
- *err_str = g_strdup_printf("Failed to create NV-CONTROL handle for\n"
- "display %d (on GPU-%d).",
- display_id,
- NvCtrlGetTargetId(gpu->handle));
- nv_error_msg("%s", *err_str);
- goto fail;
- }
+ display->ctrl_target = ctrl_target;
/* Query the display information */
@@ -2770,14 +2743,15 @@ nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
/* Query if this display is an SDI display */
- ret = NvCtrlGetAttribute(display->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_IS_GVO_DISPLAY,
&(display->is_sdi));
if (ret != NvCtrlSuccess) {
nv_warning_msg("Failed to query if display device\n"
"%d connected to GPU-%d '%s' is an\n"
"SDI device.",
- display_id, NvCtrlGetTargetId(gpu->handle),
+ NvCtrlGetTargetId(ctrl_target),
+ NvCtrlGetTargetId(gpu->ctrl_target),
gpu->name);
display->is_sdi = FALSE;
}
@@ -2790,7 +2764,7 @@ nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
unsigned int valid3 = 0;
NVCTRLAttributeValidValuesRec valid;
- ret = NvCtrlGetValidAttributeValues(gpu->handle,
+ ret = NvCtrlGetValidAttributeValues(gpu->ctrl_target,
NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT,
&valid);
if ((ret != NvCtrlSuccess) ||
@@ -2800,7 +2774,7 @@ nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
valid1 = valid.u.bits.ints;
}
- ret = NvCtrlGetValidAttributeValues(gpu->handle,
+ ret = NvCtrlGetValidAttributeValues(gpu->ctrl_target,
NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2,
&valid);
if ((ret != NvCtrlSuccess) ||
@@ -2810,7 +2784,7 @@ nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
valid2 = valid.u.bits.ints;
}
- ret = NvCtrlGetValidAttributeValues(gpu->handle,
+ ret = NvCtrlGetValidAttributeValues(gpu->ctrl_target,
NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3,
&valid);
if ((ret != NvCtrlSuccess) ||
@@ -2868,8 +2842,8 @@ nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
if (!display_add_modelines_from_server(display, gpu, err_str)) {
nv_warning_msg("Failed to add modelines to display device %d "
"'%s'\nconnected to GPU-%d '%s'.",
- display_id, display->logName,
- NvCtrlGetTargetId(gpu->handle), gpu->name);
+ NvCtrlGetTargetId(ctrl_target), display->logName,
+ NvCtrlGetTargetId(gpu->ctrl_target), gpu->name);
goto fail;
}
@@ -2895,45 +2869,27 @@ nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
**/
static Bool gpu_add_displays_from_server(nvGpuPtr gpu, gchar **err_str)
{
- ReturnStatus ret;
- int *pData;
- int len;
- int i;
-
+ CtrlTargetNode *node;
- /* Clean up the GPU list */
gpu_remove_displays(gpu);
- /* Get list of displays connected to this GPU */
- ret = NvCtrlGetBinaryAttribute(gpu->handle, 0,
- NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU,
- (unsigned char **)(&pData), &len);
- if (ret != NvCtrlSuccess) {
- *err_str = g_strdup_printf("Failed to query list of displays \n"
- "connected to GPU-%d '%s'.",
- NvCtrlGetTargetId(gpu->handle), gpu->name);
- nv_error_msg("%s", *err_str);
- goto fail;
- }
-
- /* Add each connected display */
- for (i = 0; i < pData[0]; i++) {
- if (!gpu_add_display_from_server(gpu, pData[i+1], err_str)) {
- nv_warning_msg("Failed to add display device %d to GPU-%d "
-
-
-
+ for (node = gpu->ctrl_target->relations; node; node = node->next) {
+ CtrlTarget *ctrl_target = node->t;
+ if (NvCtrlGetTargetType(ctrl_target) != DISPLAY_TARGET ||
+ !(ctrl_target->display.connected)) {
+ continue;
+ }
+ if (!gpu_add_display_from_server(gpu, ctrl_target, err_str)) {
+ nv_warning_msg("Failed to add display device %d to GPU-%d "
"'%s'.",
- pData[i+1], NvCtrlGetTargetId(gpu->handle),
+ NvCtrlGetTargetId(ctrl_target),
+ NvCtrlGetTargetId(gpu->ctrl_target),
gpu->name);
- XFree(pData);
goto fail;
}
}
-
- XFree(pData);
return TRUE;
fail:
@@ -2993,15 +2949,13 @@ static void gpu_free(nvGpuPtr gpu)
if (gpu) {
gpu_remove_displays(gpu);
- XFree(gpu->name);
- XFree(gpu->uuid);
- XFree(gpu->flags_memory);
+ ctk_event_destroy(G_OBJECT(gpu->ctk_event));
+
+ free(gpu->name);
+ free(gpu->uuid);
+ free(gpu->flags_memory);
g_free(gpu->pci_bus_id);
free(gpu->gvo_mode_data);
-
- if (gpu->handle) {
- NvCtrlAttributeClose(gpu->handle);
- }
free(gpu);
}
@@ -3080,11 +3034,13 @@ void layout_add_screen(nvLayoutPtr layout, nvScreenPtr screen)
void layout_remove_and_free_screen(nvScreenPtr screen)
{
- nvLayoutPtr layout = screen->layout;
+ nvLayoutPtr layout;
nvScreenPtr other;
if (!screen) return;
+ layout = screen->layout;
+
/* Make sure other screens in the layout aren't relative
* to this screen
@@ -3146,11 +3102,11 @@ static void layout_remove_gpus(nvLayoutPtr layout)
* Adds a GPU to the layout structure.
*
**/
-static Bool layout_add_gpu_from_server(nvLayoutPtr layout, unsigned int gpu_id,
+static Bool layout_add_gpu_from_server(nvLayoutPtr layout,
+ CtrlTarget *ctrl_target,
gchar **err_str)
{
ReturnStatus ret;
- Display *dpy;
nvGpuPtr gpu = NULL;
unsigned int *pData;
int len;
@@ -3161,84 +3117,80 @@ static Bool layout_add_gpu_from_server(nvLayoutPtr layout, unsigned int gpu_id,
gpu = (nvGpuPtr)calloc(1, sizeof(nvGpu));
if (!gpu) goto fail;
-
- /* Make an NV-CONTROL handle to talk to the GPU */
- dpy = NvCtrlGetDisplayPtr(layout->handle);
gpu->layout = layout;
- gpu->handle = NvCtrlAttributeInit(dpy, NV_CTRL_TARGET_TYPE_GPU, gpu_id,
- NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM);
- if (!gpu->handle) {
- *err_str = g_strdup_printf("Failed to create NV-CONTROL handle for "
- "GPU-%d.", gpu_id);
- nv_error_msg("%s", *err_str);
- goto fail;
- }
-
- gpu->ctk_event = CTK_EVENT(ctk_event_new(gpu->handle));
+ gpu->ctrl_target = ctrl_target;
+ gpu->ctk_event = CTK_EVENT(ctk_event_new(ctrl_target));
/* Query the GPU information */
- ret = NvCtrlGetStringAttribute(gpu->handle, NV_CTRL_STRING_PRODUCT_NAME,
+ ret = NvCtrlGetStringAttribute(ctrl_target, NV_CTRL_STRING_PRODUCT_NAME,
&gpu->name);
if (ret != NvCtrlSuccess) {
*err_str = g_strdup_printf("Failed to query GPU name of GPU-%d.",
- gpu_id);
+ NvCtrlGetTargetId(ctrl_target));
nv_error_msg("%s", *err_str);
goto fail;
}
- ret = NvCtrlGetStringAttribute(gpu->handle, NV_CTRL_STRING_GPU_UUID,
+ ret = NvCtrlGetStringAttribute(ctrl_target, NV_CTRL_STRING_GPU_UUID,
&gpu->uuid);
if (ret != NvCtrlSuccess) {
nv_warning_msg("Failed to query GPU UUID of GPU-%d '%s'. GPU UUID "
"qualifiers will not be used.",
- gpu_id, gpu->name);
+ NvCtrlGetTargetId(ctrl_target),
+ gpu->name);
gpu->uuid = NULL;
}
- gpu->pci_bus_id = get_bus_id_str(gpu->handle);
+ gpu->pci_bus_id = get_bus_id_str(ctrl_target);
- ret = NvCtrlGetAttribute(gpu->handle, NV_CTRL_MAX_SCREEN_WIDTH,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_MAX_SCREEN_WIDTH,
(int *)&(gpu->max_width));
if (ret != NvCtrlSuccess) {
*err_str = g_strdup_printf("Failed to query MAX SCREEN WIDTH on "
- "GPU-%d '%s'.", gpu_id, gpu->name);
+ "GPU-%d '%s'.",
+ NvCtrlGetTargetId(ctrl_target),
+ gpu->name);
nv_error_msg("%s", *err_str);
goto fail;
}
- ret = NvCtrlGetAttribute(gpu->handle, NV_CTRL_MAX_SCREEN_HEIGHT,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_MAX_SCREEN_HEIGHT,
(int *)&(gpu->max_height));
if (ret != NvCtrlSuccess) {
*err_str = g_strdup_printf("Failed to query MAX SCREEN HEIGHT on "
- "GPU-%d '%s'.", gpu_id, gpu->name);
+ "GPU-%d '%s'.",
+ NvCtrlGetTargetId(ctrl_target),
+ gpu->name);
nv_error_msg("%s", *err_str);
goto fail;
}
- ret = NvCtrlGetAttribute(gpu->handle, NV_CTRL_MAX_DISPLAYS,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_MAX_DISPLAYS,
(int *)&(gpu->max_displays));
if (ret != NvCtrlSuccess) {
*err_str = g_strdup_printf("Failed to query MAX DISPLAYS on "
- "GPU-%d '%s'.", gpu_id, gpu->name);
+ "GPU-%d '%s'.",
+ NvCtrlGetTargetId(ctrl_target),
+ gpu->name);
nv_error_msg("%s", *err_str);
goto fail;
}
- ret = NvCtrlGetAttribute(gpu->handle, NV_CTRL_DEPTH_30_ALLOWED,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_DEPTH_30_ALLOWED,
&(gpu->allow_depth_30));
if (ret != NvCtrlSuccess) {
gpu->allow_depth_30 = FALSE;
}
- ret = NvCtrlGetAttribute(gpu->handle, NV_CTRL_MULTIGPU_MASTER_POSSIBLE,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_MULTIGPU_MASTER_POSSIBLE,
&(gpu->multigpu_master_possible));
if (ret != NvCtrlSuccess) {
gpu->multigpu_master_possible = FALSE;
}
- ret = NvCtrlGetBinaryAttribute(gpu->handle,
+ ret = NvCtrlGetBinaryAttribute(ctrl_target,
0,
NV_CTRL_BINARY_DATA_GPU_FLAGS,
(unsigned char **)&pData,
@@ -3259,7 +3211,7 @@ static Bool layout_add_gpu_from_server(nvLayoutPtr layout, unsigned int gpu_id,
gpu->mosaic_type = MOSAIC_TYPE_UNSUPPORTED;
gpu->mosaic_enabled = FALSE;
- ret = NvCtrlGetAttribute(gpu->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE,
&(val));
@@ -3269,20 +3221,20 @@ static Bool layout_add_gpu_from_server(nvLayoutPtr layout, unsigned int gpu_id,
gpu->mosaic_type = MOSAIC_TYPE_SLI_MOSAIC;
- ret = NvCtrlGetStringAttribute(gpu->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_SLI_MODE,
&sli_str);
if ((ret == NvCtrlSuccess) && sli_str) {
if (!strcasecmp(sli_str, "Mosaic")) {
gpu->mosaic_enabled = TRUE;
}
- XFree(sli_str);
+ free(sli_str);
}
} else {
NVCTRLAttributeValidValuesRec valid;
- ret = NvCtrlGetValidAttributeValues(gpu->handle,
+ ret = NvCtrlGetValidAttributeValues(ctrl_target,
NV_CTRL_BASE_MOSAIC,
&valid);
if ((ret == NvCtrlSuccess) &&
@@ -3295,7 +3247,7 @@ static Bool layout_add_gpu_from_server(nvLayoutPtr layout, unsigned int gpu_id,
}
if (gpu->mosaic_type != MOSAIC_TYPE_UNSUPPORTED) {
- ret = NvCtrlGetAttribute(gpu->handle, NV_CTRL_BASE_MOSAIC,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_BASE_MOSAIC,
&(val));
if ((ret == NvCtrlSuccess) &&
(val == NV_CTRL_BASE_MOSAIC_FULL ||
@@ -3309,7 +3261,8 @@ static Bool layout_add_gpu_from_server(nvLayoutPtr layout, unsigned int gpu_id,
/* Add the display devices to the GPU */
if (!gpu_add_displays_from_server(gpu, err_str)) {
nv_warning_msg("Failed to add displays to GPU-%d '%s'.",
- gpu_id, gpu->name);
+ NvCtrlGetTargetId(ctrl_target),
+ gpu->name);
goto fail;
}
@@ -3335,30 +3288,16 @@ static Bool layout_add_gpu_from_server(nvLayoutPtr layout, unsigned int gpu_id,
**/
static int layout_add_gpus_from_server(nvLayoutPtr layout, gchar **err_str)
{
- ReturnStatus ret;
- int ngpus;
- int i;
-
+ CtrlTargetNode *node;
- /* Clean up the GPU list */
layout_remove_gpus(layout);
+ for (node = layout->system->targets[GPU_TARGET]; node; node = node->next) {
+ CtrlTarget *ctrl_target = node->t;
- /* Query the number of GPUs on the server */
- ret = NvCtrlQueryTargetCount(layout->handle, NV_CTRL_TARGET_TYPE_GPU,
- &ngpus);
- if (ret != NvCtrlSuccess || !ngpus) {
- *err_str = g_strdup("Failed to query number of GPUs (or no GPUs "
- "found) in the system.");
- nv_error_msg("%s", *err_str);
- goto fail;
- }
-
-
- /* Add each GPU */
- for (i = 0; i < ngpus; i++) {
- if (!layout_add_gpu_from_server(layout, i, err_str)) {
- nv_warning_msg("Failed to add GPU-%d to layout.", i);
+ if (!layout_add_gpu_from_server(layout, ctrl_target, err_str)) {
+ nv_warning_msg("Failed to add GPU-%d to layout.",
+ NvCtrlGetTargetId(ctrl_target));
goto fail;
}
}
@@ -3366,7 +3305,6 @@ static int layout_add_gpus_from_server(nvLayoutPtr layout, gchar **err_str)
return layout->num_gpus;
- /* Failure case */
fail:
layout_remove_gpus(layout);
return 0;
@@ -3405,19 +3343,20 @@ static Bool link_screen_to_gpus(nvLayoutPtr layout, nvScreenPtr screen)
int *pData = NULL;
int len;
int i;
- int scrnum = NvCtrlGetTargetId(screen->handle);
+ int scrnum = NvCtrlGetTargetId(screen->ctrl_target);
/* Link the screen to the display owner GPU. If there is no display owner,
* which is the case when SLI Mosaic is configured, link the screen to the
* first (multi gpu master possible) GPU we find.
*/
- ret = NvCtrlGetAttribute(screen->handle, NV_CTRL_MULTIGPU_DISPLAY_OWNER,
+ ret = NvCtrlGetAttribute(screen->ctrl_target,
+ NV_CTRL_MULTIGPU_DISPLAY_OWNER,
&(screen->display_owner_gpu_id));
if (ret != NvCtrlSuccess) {
screen->display_owner_gpu_id = -1;
}
- ret = NvCtrlGetBinaryAttribute(screen->handle,
+ ret = NvCtrlGetBinaryAttribute(screen->ctrl_target,
0,
NV_CTRL_BINARY_DATA_GPUS_USED_BY_XSCREEN,
(unsigned char **)(&pData),
@@ -3432,7 +3371,7 @@ static Bool link_screen_to_gpus(nvLayoutPtr layout, nvScreenPtr screen)
nvGpuPtr gpu;
for (gpu = layout->gpus; gpu; gpu = gpu->next_in_layout) {
- int gpuid = NvCtrlGetTargetId(gpu->handle);
+ int gpuid = NvCtrlGetTargetId(gpu->ctrl_target);
if (gpuid != pData[1+i]) {
continue;
@@ -3451,9 +3390,7 @@ static Bool link_screen_to_gpus(nvLayoutPtr layout, nvScreenPtr screen)
status = TRUE;
done:
- if (pData) {
- XFree(pData);
- }
+ free(pData);
return status;
}
@@ -3466,10 +3403,9 @@ static Bool link_screen_to_gpus(nvLayoutPtr layout, nvScreenPtr screen)
*
**/
static Bool layout_add_screen_from_server(nvLayoutPtr layout,
- unsigned int screen_id,
+ CtrlTarget *ctrl_target,
gchar **err_str)
{
- Display *display;
nvScreenPtr screen;
int val, tmp;
ReturnStatus ret;
@@ -3479,30 +3415,12 @@ static Bool layout_add_screen_from_server(nvLayoutPtr layout,
screen = (nvScreenPtr)calloc(1, sizeof(nvScreen));
if (!screen) goto fail;
- screen->scrnum = screen_id;
-
-
- /* Make an NV-CONTROL handle to talk to the screen (use the
- * first gpu's display)
- */
- display = NvCtrlGetDisplayPtr(layout->gpus->handle);
- screen->handle =
- NvCtrlAttributeInit(display,
- NV_CTRL_TARGET_TYPE_X_SCREEN,
- screen_id,
- NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM);
-
- if (!screen->handle) {
- *err_str = g_strdup_printf("Failed to create NV-CONTROL handle for\n"
- "screen %d.",
- screen_id);
- nv_error_msg("%s", *err_str);
- goto fail;
- }
+ screen->ctrl_target = ctrl_target;
+ screen->scrnum = NvCtrlGetTargetId(ctrl_target);
/* Query the current stereo mode */
- ret = NvCtrlGetAttribute(screen->handle, NV_CTRL_STEREO, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_STEREO, &val);
if (ret == NvCtrlSuccess) {
screen->stereo_supported = TRUE;
screen->stereo = val;
@@ -3511,14 +3429,14 @@ static Bool layout_add_screen_from_server(nvLayoutPtr layout,
}
/* Query the current overlay state */
- ret = NvCtrlGetAttribute(screen->handle, NV_CTRL_OVERLAY, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_OVERLAY, &val);
if (ret == NvCtrlSuccess) {
screen->overlay = val;
} else {
screen->overlay = NV_CTRL_OVERLAY_OFF;
}
- ret = NvCtrlGetAttribute(screen->handle, NV_CTRL_HWOVERLAY, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_HWOVERLAY, &val);
if (ret == NvCtrlSuccess) {
screen->hw_overlay = val;
} else {
@@ -3526,7 +3444,7 @@ static Bool layout_add_screen_from_server(nvLayoutPtr layout,
}
/* Query the current UBB state */
- ret = NvCtrlGetAttribute(screen->handle, NV_CTRL_UBB, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_UBB, &val);
if (ret == NvCtrlSuccess) {
screen->ubb = val;
} else {
@@ -3534,7 +3452,7 @@ static Bool layout_add_screen_from_server(nvLayoutPtr layout,
}
/* See if the screen is set to not scanout */
- ret = NvCtrlGetAttribute(screen->handle, NV_CTRL_NO_SCANOUT, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_NO_SCANOUT, &val);
if (ret != NvCtrlSuccess) {
/* Don't make it a fatal error if NV_CTRL_NO_SCANOUT can't be
* queried, since some drivers may not support this attribute. */
@@ -3543,7 +3461,7 @@ static Bool layout_add_screen_from_server(nvLayoutPtr layout,
*err_str = g_strdup_printf("Failed to query NoScanout for "
"screen %d.",
- screen_id);
+ NvCtrlGetTargetId(ctrl_target));
nv_warning_msg("%s", *err_str);
g_free(*err_str);
@@ -3555,20 +3473,20 @@ static Bool layout_add_screen_from_server(nvLayoutPtr layout,
/* Link screen to the GPUs driving it */
if (!link_screen_to_gpus(layout, screen)) {
*err_str = g_strdup_printf("Failed to find GPU that drives screen %d.",
- screen_id);
+ NvCtrlGetTargetId(ctrl_target));
nv_warning_msg("%s", *err_str);
goto fail;
}
/* Query SLI status */
- ret = NvCtrlGetAttribute(screen->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_SHOW_SLI_VISUAL_INDICATOR,
&tmp);
screen->sli = (ret == NvCtrlSuccess);
/* Query SLI mode */
- ret = NvCtrlGetStringAttribute(screen->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_SLI_MODE,
&screen->sli_mode);
if (ret != NvCtrlSuccess) {
@@ -3576,7 +3494,7 @@ static Bool layout_add_screen_from_server(nvLayoutPtr layout,
}
/* Query MULTIGPU mode */
- ret = NvCtrlGetStringAttribute(screen->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_MULTIGPU_MODE,
&screen->multigpu_mode);
if (ret != NvCtrlSuccess) {
@@ -3584,14 +3502,14 @@ static Bool layout_add_screen_from_server(nvLayoutPtr layout,
}
/* Listen to NV-CONTROL events on this screen handle */
- screen->ctk_event = CTK_EVENT(ctk_event_new(screen->handle));
+ screen->ctk_event = CTK_EVENT(ctk_event_new(ctrl_target));
/* Query the depth of the screen */
- screen->depth = NvCtrlGetScreenPlanes(screen->handle);
+ screen->depth = NvCtrlGetScreenPlanes(ctrl_target);
/* Initialize the virtual X screen size */
- screen->dim.width = NvCtrlGetScreenWidth(screen->handle);
- screen->dim.height = NvCtrlGetScreenHeight(screen->handle);
+ screen->dim.width = NvCtrlGetScreenWidth(ctrl_target);
+ screen->dim.height = NvCtrlGetScreenHeight(ctrl_target);
/* Add the screen to the layout */
layout_add_screen(layout, screen);
@@ -3603,13 +3521,13 @@ static Bool layout_add_screen_from_server(nvLayoutPtr layout,
if (!screen->no_scanout) {
if (!screen_add_metamodes(screen, err_str)) {
nv_warning_msg("Failed to add metamodes to screen %d.",
- screen_id);
+ NvCtrlGetTargetId(ctrl_target));
goto fail;
}
/* Query & parse the screen's primary display */
screen->primaryDisplay = NULL;
- ret = NvCtrlGetStringAttribute(screen->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER,
&primary_str);
@@ -3626,7 +3544,7 @@ static Bool layout_add_screen_from_server(nvLayoutPtr layout,
} else {
str = nvstrndup(primary_str, str-primary_str);
}
- XFree(primary_str);
+ free(primary_str);
screen->primaryDisplay = screen_find_named_display(screen, str);
nvfree(str);
@@ -3657,37 +3575,24 @@ static Bool layout_add_screen_from_server(nvLayoutPtr layout,
**/
static int layout_add_screens_from_server(nvLayoutPtr layout, gchar **err_str)
{
- ReturnStatus ret;
- int i, nscreens;
-
+ CtrlTargetNode *node;
layout_remove_screens(layout);
+ for (node = layout->system->physical_screens;
+ node;
+ node = node->next) {
+ CtrlTarget *ctrl_target = node->t;
- ret = NvCtrlQueryTargetCount(layout->handle, NV_CTRL_TARGET_TYPE_X_SCREEN,
- &nscreens);
- if (ret != NvCtrlSuccess || !nscreens) {
- *err_str = g_strdup("Failed to query number of X screens (or no X "
- "screens found) in the system.");
- nv_error_msg("%s", *err_str);
- nscreens = 0;
- goto fail;
- }
-
- for (i = 0; i < nscreens; i++) {
- if (!layout_add_screen_from_server(layout, i, err_str)) {
- nv_warning_msg("Failed to add X screen %d to layout.", i);
+ if (!layout_add_screen_from_server(layout, ctrl_target, err_str)) {
+ nv_warning_msg("Failed to add X screen %d to layout.",
+ NvCtrlGetTargetId(ctrl_target));
g_free(*err_str);
*err_str = NULL;
}
}
- return nscreens;
-
-
- fail:
- layout_remove_screens(layout);
- return 0;
+ return layout->num_screens;
} /* layout_add_screens_from_server() */
@@ -3708,7 +3613,7 @@ static Bool layout_add_screenless_modes_to_displays(nvLayoutPtr layout)
/* Add fake modes to screenless display devices */
if (!gpu_add_screenless_modes_to_displays(gpu)) {
nv_warning_msg("Failed to add screenless modes to GPU-%d '%s'.",
- NvCtrlGetTargetId(gpu->handle), gpu->name);
+ NvCtrlGetTargetId(gpu->ctrl_target), gpu->name);
return FALSE;
}
}
@@ -3728,6 +3633,7 @@ void layout_free(nvLayoutPtr layout)
{
if (layout) {
layout_remove_gpus(layout);
+ NvCtrlFreeAllSystems(&layout->systems);
free(layout);
}
@@ -3740,7 +3646,7 @@ void layout_free(nvLayoutPtr layout)
* Loads layout information from the X server.
*
**/
-nvLayoutPtr layout_load_from_server(NvCtrlAttributeHandle *handle,
+nvLayoutPtr layout_load_from_server(CtrlTarget *ctrl_target,
gchar **err_str)
{
nvLayoutPtr layout = NULL;
@@ -3751,13 +3657,15 @@ nvLayoutPtr layout_load_from_server(NvCtrlAttributeHandle *handle,
layout = (nvLayoutPtr)calloc(1, sizeof(nvLayout));
if (!layout) goto fail;
-
- /* Cache the handle for talking to the X server */
- layout->handle = handle;
-
+ /* Duplicate the connection to the system */
+ layout->system = NvCtrlConnectToSystem(ctrl_target->system->display,
+ &(layout->systems));
+ if (layout->system == NULL) {
+ goto fail;
+ }
/* Is Xinerama enabled? */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_XINERAMA,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_XINERAMA,
&layout->xinerama_enabled);
if (ret != NvCtrlSuccess) {
*err_str = g_strdup("Failed to query status of Xinerama.");
@@ -3766,9 +3674,9 @@ nvLayoutPtr layout_load_from_server(NvCtrlAttributeHandle *handle,
}
/* does the driver know about NV_CTRL_CURRENT_METAMODE_ID? */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_CURRENT_METAMODE_ID, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_CURRENT_METAMODE_ID, &tmp);
if (ret != NvCtrlSuccess) {
- char *displayName = NvCtrlGetDisplayName(handle);
+ char *displayName = NvCtrlGetDisplayName(ctrl_target);
*err_str = g_strdup_printf("The NVIDIA X driver on %s is not new\n"
"enough to support the nvidia-settings "
"Display Configuration page.",
@@ -3863,12 +3771,16 @@ nvDisplayPtr layout_get_display(const nvLayoutPtr layout,
nvGpuPtr gpu;
nvDisplayPtr display;
+ if (!layout) {
+ return NULL;
+ }
+
for (gpu = layout->gpus; gpu; gpu = gpu->next_in_layout) {
for (display = gpu->displays;
display;
display = display->next_on_gpu) {
- if (NvCtrlGetTargetId(display->handle) == display_id) {
+ if (NvCtrlGetTargetId(display->ctrl_target) == display_id) {
return display;
}
}
@@ -4089,7 +4001,7 @@ static void update_xconfig_save_buffer(SaveXConfDlg *dlg)
XConfigPtr xconfGen = NULL;
XConfigError xconfErr;
- char *tmp_filename;
+ char *tmp_filename = NULL;
int tmp_fd;
struct stat st;
void *buf;
@@ -4243,17 +4155,32 @@ static void update_xconfig_save_buffer(SaveXConfDlg *dlg)
tmp_fd = mkstemp(tmp_filename);
if (!tmp_fd) {
err_msg = g_strdup_printf("Failed to create temp X config file '%s' "
- "for display.",
+ "for preview.",
tmp_filename);
- g_free(tmp_filename);
goto fail;
}
xconfigWriteConfigFile(tmp_filename, xconfGen);
xconfigFreeConfig(&xconfGen);
- lseek(tmp_fd, 0, SEEK_SET);
- fstat(tmp_fd, &st);
+ if (lseek(tmp_fd, 0, SEEK_SET) == (off_t)-1) {
+ err_msg = g_strdup_printf("Failed lseek() on temp X config file '%s' "
+ "for preview.",
+ tmp_filename);
+ goto fail;
+ }
+ if (fstat(tmp_fd, &st) == -1) {
+ err_msg = g_strdup_printf("Failed fstat() on temp X config file '%s' "
+ "for preview.",
+ tmp_filename);
+ goto fail;
+ }
buf = mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, tmp_fd, 0);
+ if (buf == MAP_FAILED) {
+ err_msg = g_strdup_printf("Failed mmap() on temp X config file '%s' "
+ "for preview.",
+ tmp_filename);
+ goto fail;
+ }
/* Clear the GTK buffer */
gtk_text_buffer_get_bounds
@@ -4297,6 +4224,8 @@ static void update_xconfig_save_buffer(SaveXConfDlg *dlg)
xconfigFreeConfig(&xconfCur);
}
+ g_free(tmp_filename);
+
return;
} /* update_xconfig_save_buffer() */
@@ -4361,32 +4290,20 @@ static void xconfig_file_clicked(GtkWidget *widget, gpointer user_data)
SaveXConfDlg *dlg = (SaveXConfDlg *)user_data;
const gchar *filename =
gtk_entry_get_text(GTK_ENTRY(dlg->txt_xconfig_file));
- gint result;
-
+ gchar *selected_filename;
/* Ask user for a filename */
- gtk_window_set_transient_for
- (GTK_WINDOW(dlg->dlg_xconfig_file),
- GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(dlg->parent))));
-
- gtk_file_chooser_set_filename
- (GTK_FILE_CHOOSER(dlg->dlg_xconfig_file), filename);
-
- result = gtk_dialog_run(GTK_DIALOG(dlg->dlg_xconfig_file));
- gtk_widget_hide(dlg->dlg_xconfig_file);
-
- switch (result) {
- case GTK_RESPONSE_ACCEPT:
- case GTK_RESPONSE_OK:
- filename = gtk_file_chooser_get_filename
- (GTK_FILE_CHOOSER(dlg->dlg_xconfig_file));
+ selected_filename =
+ ctk_get_filename_from_dialog("Please select the X configuration file",
+ GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(dlg->parent))),
+ filename);
- gtk_entry_set_text(GTK_ENTRY(dlg->txt_xconfig_file), filename);
+ if (selected_filename) {
+ gtk_entry_set_text(GTK_ENTRY(dlg->txt_xconfig_file), selected_filename);
update_xconfig_save_buffer(dlg);
- break;
- default:
- return;
+
+ g_free(selected_filename);
}
} /* xconfig_file_clicked() */
@@ -4406,7 +4323,7 @@ void run_save_xconfig_dialog(SaveXConfDlg *dlg)
{
void *buf;
GtkTextIter buf_start, buf_end;
- gchar *filename;
+ gchar *filename = NULL;
const gchar *tmp_filename;
struct stat st;
@@ -4476,7 +4393,6 @@ void run_save_xconfig_dialog(SaveXConfDlg *dlg)
nv_info_msg("", "Writing X config file '%s'", filename);
save_xconfig_file(dlg, filename, (char *)buf, 0644);
g_free(buf);
- g_free(filename);
break;
case GTK_RESPONSE_REJECT:
@@ -4485,6 +4401,8 @@ void run_save_xconfig_dialog(SaveXConfDlg *dlg)
break;
}
+ g_free(filename);
+
} /* run_save_xconfig_dialog() */
@@ -4574,12 +4492,6 @@ SaveXConfDlg *create_save_xconfig_dialog(GtkWidget *parent,
g_signal_connect(G_OBJECT(dlg->btn_xconfig_file), "clicked",
G_CALLBACK(xconfig_file_clicked),
(gpointer) dlg);
- dlg->dlg_xconfig_file =
- gtk_file_chooser_dialog_new("Please select the X configuration file",
- NULL, GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
/* Create the merge checkbox */
dlg->btn_xconfig_merge =
@@ -4594,14 +4506,13 @@ SaveXConfDlg *create_save_xconfig_dialog(GtkWidget *parent,
/* Pack the preview button */
hbox = gtk_hbox_new(FALSE, 0);
- hbox2 = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), dlg->btn_xconfig_preview,
FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(ctk_dialog_get_content_area(GTK_DIALOG(dlg->dlg_xconfig_save))),
hbox, FALSE, FALSE, 5);
- /* Pack the preview window */
+ /* Pack the save window */
hbox = gtk_hbox_new(TRUE, 0);
gtk_container_add(GTK_CONTAINER(dlg->scr_xconfig_save),
diff --git a/src/gtk+-2.x/ctkdisplayconfig-utils.h b/src/gtk+-2.x/ctkdisplayconfig-utils.h
index 0e74a62..28444e9 100644
--- a/src/gtk+-2.x/ctkdisplayconfig-utils.h
+++ b/src/gtk+-2.x/ctkdisplayconfig-utils.h
@@ -107,9 +107,6 @@ Bool screen_has_gpu(nvScreenPtr screen, nvGpuPtr match_gpu);
/* GPU functions */
void gpu_remove_and_free_display(nvDisplayPtr display);
-nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu,
- unsigned int display_id,
- gchar **err_str);
Bool gpu_add_screenless_modes_to_displays(nvGpuPtr gpu);
@@ -118,7 +115,7 @@ Bool gpu_add_screenless_modes_to_displays(nvGpuPtr gpu);
void layout_free(nvLayoutPtr layout);
void layout_add_screen(nvLayoutPtr layout, nvScreenPtr screen);
-nvLayoutPtr layout_load_from_server(NvCtrlAttributeHandle *handle,
+nvLayoutPtr layout_load_from_server(CtrlTarget *ctrl_target,
gchar **err_str);
nvScreenPtr layout_get_a_screen(nvLayoutPtr layout, nvGpuPtr preferred_gpu);
nvDisplayPtr layout_get_display(const nvLayoutPtr layout,
@@ -152,8 +149,7 @@ typedef struct _SaveXConfDlg {
GtkWidget *btn_xconfig_merge; /* Merge with existing X config */
GtkWidget *btn_xconfig_preview; /* Show/Hide button */
GtkWidget *box_xconfig_save; /* Show/Hide this box */
-
- GtkWidget *dlg_xconfig_file; /* File save dialog */
+
GtkWidget *btn_xconfig_file;
GtkWidget *txt_xconfig_file;
diff --git a/src/gtk+-2.x/ctkdisplayconfig.c b/src/gtk+-2.x/ctkdisplayconfig.c
index 4ecc105..bd5d657 100644
--- a/src/gtk+-2.x/ctkdisplayconfig.c
+++ b/src/gtk+-2.x/ctkdisplayconfig.c
@@ -108,8 +108,9 @@ static void advanced_clicked(GtkWidget *widget, gpointer user_data);
static void reset_clicked(GtkWidget *widget, gpointer user_data);
static void validation_details_clicked(GtkWidget *widget, gpointer user_data);
-static void display_config_attribute_changed(GtkWidget *object, gpointer arg1,
- gpointer user_data);
+static void display_config_attribute_changed(GtkWidget *object,
+ CtrlEvent *event,
+ gpointer user_data);
static void reset_layout(CtkDisplayConfig *ctk_object);
static gboolean force_layout_reset(gpointer user_data);
static void user_changed_attributes(CtkDisplayConfig *ctk_object);
@@ -421,7 +422,9 @@ static void register_layout_events(CtkDisplayConfig *ctk_object)
/* Register for GPU events */
for (gpu = layout->gpus; gpu; gpu = gpu->next_in_layout) {
- if (!gpu->handle) continue;
+ if (gpu->ctrl_target == NULL) {
+ continue;
+ }
g_signal_connect(G_OBJECT(gpu->ctk_event),
CTK_EVENT_NAME(NV_CTRL_PROBE_DISPLAYS),
@@ -437,7 +440,9 @@ static void register_layout_events(CtkDisplayConfig *ctk_object)
/* Register for X screen events */
for (screen = layout->screens; screen; screen = screen->next_in_layout) {
- if (!screen->handle) continue;
+ if (screen->ctrl_target == NULL) {
+ continue;
+ }
g_signal_connect(G_OBJECT(screen->ctk_event),
CTK_EVENT_NAME(NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER),
@@ -478,7 +483,9 @@ static void unregister_layout_events(CtkDisplayConfig *ctk_object)
/* Unregister GPU events */
for (gpu = layout->gpus; gpu; gpu = gpu->next_in_layout) {
- if (!gpu->handle) continue;
+ if (gpu->ctrl_target == NULL) {
+ continue;
+ }
g_signal_handlers_disconnect_matched(G_OBJECT(gpu->ctk_event),
G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
@@ -492,7 +499,9 @@ static void unregister_layout_events(CtkDisplayConfig *ctk_object)
/* Unregister X screen events */
for (screen = layout->screens; screen; screen = screen->next_in_layout) {
- if (!screen->handle) continue;
+ if (screen->ctrl_target == NULL) {
+ continue;
+ }
g_signal_handlers_disconnect_matched(G_OBJECT(screen->ctk_event),
G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
@@ -625,6 +634,7 @@ static int generate_xconf_metamode_str(CtkDisplayConfig *ctk_object,
gchar **pMetamode_strs)
{
nvLayoutPtr layout = screen->layout;
+ CtrlTarget *ctrl_target;
gchar *metamode_strs = NULL;
gchar *metamode_str;
gchar *tmp;
@@ -634,12 +644,19 @@ static int generate_xconf_metamode_str(CtkDisplayConfig *ctk_object,
int start_width;
int start_height;
- int vendrel = NvCtrlGetVendorRelease(layout->handle);
- char *vendstr = NvCtrlGetServerVendor(layout->handle);
+ int vendrel;
+ char *vendstr;
int xorg_major;
int xorg_minor;
Bool longStringsOK;
+ ctrl_target = NvCtrlGetDefaultTarget(layout->system);
+ if (ctrl_target == NULL) {
+ return XCONFIG_GEN_ABORT;
+ }
+
+ vendrel = NvCtrlGetVendorRelease(ctrl_target);
+ vendstr = NvCtrlGetServerVendor(ctrl_target);
/* Only X.Org 7.2 or > supports long X config lines */
xorg_major = (vendrel / 10000000);
@@ -801,9 +818,9 @@ static void assign_screen_positions(CtkDisplayConfig *ctk_object)
for (screen = layout->screens; screen; screen = screen->next_in_layout) {
screen_info = NULL;
- if (screen->handle) {
+ if (screen->ctrl_target != NULL) {
ret = NvCtrlGetStringAttribute
- (screen->handle,
+ (screen->ctrl_target,
NV_CTRL_STRING_SCREEN_RECTANGLE,
&screen_info);
@@ -835,7 +852,7 @@ static void assign_screen_positions(CtkDisplayConfig *ctk_object)
screen_parsed_info.x,
screen_parsed_info.y);
}
- XFree(screen_info);
+ free(screen_info);
} else if (prev_screen) {
/* Set this screen right of the previous */
@@ -1154,7 +1171,7 @@ static void update_gui(CtkDisplayConfig *ctk_object)
*
**/
-GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_display_config_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config)
{
GObject *object;
@@ -1188,17 +1205,15 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle,
* load this page
*
*/
- ret = NvCtrlGetStringAttribute(handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_SLI_MODE,
&sli_mode);
if (ret == NvCtrlSuccess && !g_ascii_strcasecmp(sli_mode, "Mosaic")) {
- XFree(sli_mode);
+ free(sli_mode);
return NULL;
}
- if (sli_mode) {
- XFree(sli_mode);
- }
+ free(sli_mode);
/*
* Create the ctk object
@@ -1208,7 +1223,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle,
object = g_object_new(CTK_TYPE_DISPLAY_CONFIG, NULL);
ctk_object = CTK_DISPLAY_CONFIG(object);
- ctk_object->handle = handle;
+ ctk_object->ctrl_target = ctrl_target;
ctk_object->ctk_config = ctk_config;
ctk_object->apply_possible = TRUE;
@@ -1233,9 +1248,9 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle,
* Create the display configuration widgets
*
*/
-
+
/* Load the layout structure from the X server */
- ctk_object->layout = layout_load_from_server(handle, &err_str);
+ ctk_object->layout = layout_load_from_server(ctrl_target, &err_str);
/* If we failed to load, tell the user why */
if (err_str || !ctk_object->layout) {
@@ -1265,7 +1280,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle,
register_layout_events(ctk_object);
/* Create the layout widget */
- ctk_object->obj_layout = ctk_display_layout_new(handle, ctk_config,
+ ctk_object->obj_layout = ctk_display_layout_new(ctk_config,
ctk_object->layout,
300, /* min width */
225); /* min height */
@@ -1533,7 +1548,7 @@ GtkWidget* ctk_display_config_new(NvCtrlAttributeHandle *handle,
(gpointer) ctk_object);
/* Screen Stereo Mode */
- ret = NvCtrlGetValidAttributeValues(handle, NV_CTRL_STEREO, &valid);
+ ret = NvCtrlGetValidAttributeValues(ctrl_target, NV_CTRL_STEREO, &valid);
if (ret == NvCtrlSuccess) {
@@ -2546,7 +2561,7 @@ static void generate_selected_item_dropdown(CtkDisplayConfig *ctk_object,
if (show_gpu_info) {
tmp = str;
str = g_strdup_printf("%s on GPU-%d", tmp,
- NvCtrlGetTargetId(gpu->handle));
+ NvCtrlGetTargetId(gpu->ctrl_target));
g_free(tmp);
}
tmp = str;
@@ -5552,7 +5567,8 @@ static void do_disable_display(CtkDisplayConfig *ctk_object,
str = g_strdup_printf("Disable the display device %s (%s) "
"on GPU-%d (%s)?",
display->logName, display->typeIdName,
- NvCtrlGetTargetId(gpu->handle), gpu->name);
+ NvCtrlGetTargetId(gpu->ctrl_target),
+ gpu->name);
} else {
str = g_strdup_printf("Disable the display device %s (%s)?",
display->logName, display->typeIdName);
@@ -5591,10 +5607,10 @@ static Bool display_build_modepool(nvDisplayPtr display, Bool *updated)
char *tokens = NULL;
gchar *err_str = NULL;
- NvCtrlStringOperation(display->handle, 0,
+ NvCtrlStringOperation(display->ctrl_target, 0,
NV_CTRL_STRING_OPERATION_BUILD_MODEPOOL,
"", &tokens);
- XFree(tokens);
+ free(tokens);
*updated = TRUE;
if (!display_add_modelines_from_server(display, display->gpu,
&err_str)) {
@@ -7037,7 +7053,10 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object,
Bool modified_current_metamode;
- if (!screen->handle || !screen->cur_metamode) goto fail;
+ if (screen->ctrl_target == NULL ||
+ screen->cur_metamode == NULL) {
+ goto fail;
+ }
metamode = screen->cur_metamode;
@@ -7056,7 +7075,8 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object,
* mode switch fails, or the user does not confirm.
*/
- ret = NvCtrlGetAttribute(screen->handle, NV_CTRL_CURRENT_METAMODE_ID,
+ ret = NvCtrlGetAttribute(screen->ctrl_target,
+ NV_CTRL_CURRENT_METAMODE_ID,
(int *)&old_rate);
if (ret != NvCtrlSuccess) {
nv_warning_msg("Failed to get current (fallback) mode for "
@@ -7074,7 +7094,7 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object,
nv_info_msg(TAB, "Switching to mode: %dx%d (id: %d)...",
new_width, new_height, new_rate);
- ret = NvCtrlSetAttribute(screen->handle,
+ ret = NvCtrlSetAttribute(screen->ctrl_target,
NV_CTRL_CURRENT_METAMODE_ID,
new_rate);
modified_current_metamode = FALSE;
@@ -7082,10 +7102,9 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object,
nv_info_msg(TAB, "Modifying current MetaMode to: %s...",
metamode->cpl_str);
- ret = NvCtrlSetStringAttribute(screen->handle,
+ ret = NvCtrlSetStringAttribute(screen->ctrl_target,
NV_CTRL_STRING_CURRENT_METAMODE,
- metamode->cpl_str,
- NULL);
+ metamode->cpl_str);
if (ret == NvCtrlSuccess) {
metamode->id = old_rate;
}
@@ -7099,7 +7118,7 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object,
screen->cur_metamode_idx+1, metamode->cpl_str,
new_width,
new_height, new_rate,
- NvCtrlGetTargetId(screen->handle));
+ NvCtrlGetTargetId(screen->ctrl_target));
if (screen->num_metamodes > 1) {
msg = g_strdup_printf("Failed to set MetaMode (%d) '%s' "
@@ -7108,7 +7127,7 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object,
screen->cur_metamode_idx+1,
metamode->cpl_str,
new_width, new_height, new_rate,
- NvCtrlGetTargetId(screen->handle));
+ NvCtrlGetTargetId(screen->ctrl_target));
dlg = gtk_message_dialog_new
(GTK_WINDOW(parent),
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -7121,7 +7140,7 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object,
screen->cur_metamode_idx+1,
metamode->cpl_str,
new_width, new_height, new_rate,
- NvCtrlGetTargetId(screen->handle));
+ NvCtrlGetTargetId(screen->ctrl_target));
dlg = gtk_message_dialog_new
(GTK_WINDOW(parent),
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -7140,7 +7159,7 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object,
nv_info_msg(TAB, "Removed MetaMode %d on Screen %d.\n",
screen->cur_metamode_idx+1,
- NvCtrlGetTargetId(screen));
+ NvCtrlGetTargetId(screen->ctrl_target));
/* Update the GUI */
setup_display_page(ctk_object);
@@ -7161,7 +7180,7 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object,
/* Setup the counter callback data */
info.ctk_object = ctk_object;
- info.screen = NvCtrlGetTargetId(screen->handle);
+ info.screen = NvCtrlGetTargetId(screen->ctrl_target);
/* Start the countdown timer */
ctk_object->display_confirm_countdown = DEFAULT_SWITCH_MODE_TIMEOUT;
@@ -7194,23 +7213,22 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object,
if (!modified_current_metamode) {
nv_info_msg(TAB, "Switching back to mode (id: %d)...", old_rate);
- ret = NvCtrlSetAttribute(screen->handle,
+ ret = NvCtrlSetAttribute(screen->ctrl_target,
NV_CTRL_CURRENT_METAMODE_ID,
old_rate);
} else {
nv_info_msg(TAB, "Re-writing previous current MetaMode to: %s...",
cur_metamode_str);
- ret = NvCtrlSetStringAttribute(screen->handle,
+ ret = NvCtrlSetStringAttribute(screen->ctrl_target,
NV_CTRL_STRING_CURRENT_METAMODE,
- cur_metamode_str,
- NULL);
+ cur_metamode_str);
if (ret != NvCtrlSuccess) {
nv_warning_msg("Failed to re-write current MetaMode (%d) to "
"'%s' on X screen %d!",
old_rate,
cur_metamode_str,
- NvCtrlGetTargetId(screen->handle));
+ NvCtrlGetTargetId(screen->ctrl_target));
}
}
goto fail;
@@ -7268,7 +7286,7 @@ static Bool add_cpl_metamode_to_X(nvScreenPtr screen, nvMetaModePtr metamode,
ReturnStatus ret;
char *tokens;
- ret = NvCtrlStringOperation(screen->handle, 0,
+ ret = NvCtrlStringOperation(screen->ctrl_target, 0,
NV_CTRL_STRING_OPERATION_ADD_METAMODE,
metamode->cpl_str, &tokens);
@@ -7282,7 +7300,7 @@ static Bool add_cpl_metamode_to_X(nvScreenPtr screen, nvMetaModePtr metamode,
parse_token_value_pairs(tokens, apply_metamode_token,
metamode);
- XFree(tokens);
+ free(tokens);
metamode->x_idx = metamode_idx;
@@ -7342,7 +7360,7 @@ static void setup_metamodes_for_apply(nvScreenPtr screen,
}
/* Parse CPL string into X metamode string */
- ret = NvCtrlStringOperation(screen->handle, 0,
+ ret = NvCtrlStringOperation(screen->ctrl_target, 0,
NV_CTRL_STRING_OPERATION_PARSE_METAMODE,
metamode->cpl_str, &metamode->x_str);
if ((ret != NvCtrlSuccess) ||
@@ -7567,9 +7585,9 @@ static Bool screen_move_metamode(nvScreenPtr screen, nvMetaModePtr metamode,
snprintf(update_str, len, "index=%d :: %s", metamode_idx,
metamode->cpl_str);
- ret = NvCtrlSetStringAttribute(screen->handle,
+ ret = NvCtrlSetStringAttribute(screen->ctrl_target,
NV_CTRL_STRING_MOVE_METAMODE,
- update_str, NULL);
+ update_str);
if (ret != NvCtrlSuccess) {
goto fail;
}
@@ -7673,9 +7691,9 @@ static void postprocess_metamodes(nvScreenPtr screen, char *metamode_strs)
if (!tmp) continue;
/* Delete the metamode */
- ret = NvCtrlSetStringAttribute(screen->handle,
+ ret = NvCtrlSetStringAttribute(screen->ctrl_target,
NV_CTRL_STRING_DELETE_METAMODE,
- tmp, NULL);
+ tmp);
if (ret == NvCtrlSuccess) {
nvMetaModePtr metamode;
@@ -7728,13 +7746,13 @@ static int update_screen_metamodes(CtkDisplayConfig *ctk_object,
ReturnStatus ret;
- /* Make sure the screen has a valid handle to make the updates */
- if (!screen->handle) {
+ /* Make sure the screen has a valid target to make the updates */
+ if (screen->ctrl_target == NULL) {
return 1;
}
nv_info_msg("", "Updating Screen %d's MetaModes:",
- NvCtrlGetTargetId(screen->handle));
+ NvCtrlGetTargetId(screen->ctrl_target));
/* To update the metamode list of the screen:
*
@@ -7752,7 +7770,7 @@ static int update_screen_metamodes(CtkDisplayConfig *ctk_object,
/* Get the list of the current metamodes */
- ret = NvCtrlGetBinaryAttribute(screen->handle,
+ ret = NvCtrlGetBinaryAttribute(screen->ctrl_target,
0,
NV_CTRL_BINARY_DATA_METAMODES_VERSION_2,
(unsigned char **)&metamode_strs,
@@ -7761,14 +7779,14 @@ static int update_screen_metamodes(CtkDisplayConfig *ctk_object,
/* Get the current metamode for the screen */
- ret = NvCtrlGetStringAttribute(screen->handle,
+ ret = NvCtrlGetStringAttribute(screen->ctrl_target,
NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2,
&cur_full_metamode_str);
if (ret != NvCtrlSuccess) goto done;
/* Get the current metamode index for the screen */
- ret = NvCtrlGetAttribute(screen->handle,
+ ret = NvCtrlGetAttribute(screen->ctrl_target,
NV_CTRL_CURRENT_METAMODE_ID,
&cur_metamode_id);
if (ret != NvCtrlSuccess) goto done;
@@ -7866,8 +7884,8 @@ static int update_screen_metamodes(CtkDisplayConfig *ctk_object,
done:
- XFree(metamode_strs);
- XFree(cur_full_metamode_str);
+ free(metamode_strs);
+ free(cur_full_metamode_str);
return clear_apply;
@@ -7907,14 +7925,15 @@ static void apply_clicked(GtkWidget *widget, gpointer user_data)
screen;
screen = screen->next_in_layout) {
- if (!screen->handle) continue;
+ if (screen->ctrl_target == NULL) {
+ continue;
+ }
if (screen->no_scanout) continue;
if (screen->primaryDisplay && ctk_object->primary_display_changed) {
- ret = NvCtrlSetStringAttribute(screen->handle,
+ ret = NvCtrlSetStringAttribute(screen->ctrl_target,
NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER,
- screen->primaryDisplay->typeIdName,
- NULL);
+ screen->primaryDisplay->typeIdName);
if (ret != NvCtrlSuccess) {
nv_error_msg("Failed to set primary display for screen %d",
screen->scrnum);
@@ -8082,7 +8101,7 @@ static Bool add_monitor_to_xconfig(nvDisplayPtr display, XConfigPtr config,
/* Get the Horizontal Sync ranges from nv-control */
- ret = NvCtrlGetStringAttribute(display->handle,
+ ret = NvCtrlGetStringAttribute(display->ctrl_target,
NV_CTRL_STRING_VALID_HORIZ_SYNC_RANGES,
&range_str);
if (ret != NvCtrlSuccess) {
@@ -8117,7 +8136,7 @@ static Bool add_monitor_to_xconfig(nvDisplayPtr display, XConfigPtr config,
/* Get the Horizontal Sync ranges from nv-control */
- ret = NvCtrlGetStringAttribute(display->handle,
+ ret = NvCtrlGetStringAttribute(display->ctrl_target,
NV_CTRL_STRING_VALID_VERT_REFRESH_RANGES,
&range_str);
if (ret != NvCtrlSuccess) {
@@ -8696,6 +8715,7 @@ static Bool add_layout_to_xconfig(nvLayoutPtr layout, XConfigPtr config)
static int generateXConfig(CtkDisplayConfig *ctk_object, XConfigPtr *pConfig)
{
nvLayoutPtr layout = ctk_object->layout;
+ CtrlTarget *ctrl_target;
XConfigPtr config = NULL;
GenerateOptions go;
char *server_vendor;
@@ -8710,7 +8730,8 @@ static int generateXConfig(CtkDisplayConfig *ctk_object, XConfigPtr *pConfig)
xconfigGetXServerInUse(&go);
/* Query actual server X.Org/XFree86 */
- server_vendor = NvCtrlGetServerVendor(layout->handle);
+ ctrl_target = NvCtrlGetDefaultTarget(layout->system);
+ server_vendor = NvCtrlGetServerVendor(ctrl_target);
if (server_vendor && g_strrstr(server_vendor, "X.Org")) {
go.xserver = X_IS_XORG;
} else {
@@ -8923,13 +8944,15 @@ static void probe_clicked(GtkWidget *widget, gpointer user_data)
/* Probe each GPU for display changes */
for (gpu = layout->gpus; gpu; gpu = gpu->next_in_layout) {
- if (!gpu->handle) continue;
+ if (gpu->ctrl_target == NULL) {
+ continue;
+ }
- ret = NvCtrlGetAttribute(gpu->handle, NV_CTRL_PROBE_DISPLAYS,
+ ret = NvCtrlGetAttribute(gpu->ctrl_target, NV_CTRL_PROBE_DISPLAYS,
(int *)&probed_displays);
if (ret != NvCtrlSuccess) {
nv_error_msg("Failed to probe for display devices on GPU-%d '%s'.",
- NvCtrlGetTargetId(gpu->handle), gpu->name);
+ NvCtrlGetTargetId(gpu->ctrl_target), gpu->name);
continue;
}
@@ -8967,7 +8990,8 @@ static gboolean layout_change_is_applyable(const nvLayoutPtr old,
/* This display device had an active mode in the old layout. See if
* it's still connected in the new layout. */
- if (!layout_get_display(new, NvCtrlGetTargetId(dpy->handle))) {
+ if (!layout_get_display(new,
+ NvCtrlGetTargetId(dpy->ctrl_target))) {
return True;
}
}
@@ -8982,18 +9006,14 @@ static gboolean layout_change_is_applyable(const nvLayoutPtr old,
*
**/
-static void reset_layout(CtkDisplayConfig *ctk_object)
+static void reset_layout(CtkDisplayConfig *ctk_object)
{
gchar *err_str = NULL;
nvLayoutPtr layout;
gboolean allow_apply;
/* Load the current layout */
- layout = layout_load_from_server(ctk_object->handle, &err_str);
-
- /* See if we should allow the user to press the Apply button to make the new
- * layout take effect, e.g. if an active display device disappeared. */
- allow_apply = layout_change_is_applyable(ctk_object->layout, layout);
+ layout = layout_load_from_server(ctk_object->ctrl_target, &err_str);
/* Handle errors loading the new layout */
if (!layout || err_str) {
@@ -9004,6 +9024,9 @@ static void reset_layout(CtkDisplayConfig *ctk_object)
return;
}
+ /* See if we should allow the user to press the Apply button to make the new
+ * layout take effect, e.g. if an active display device disappeared. */
+ allow_apply = layout_change_is_applyable(ctk_object->layout, layout);
/* Free existing layout */
unregister_layout_events(ctk_object);
@@ -9183,7 +9206,8 @@ done:
*
**/
-static void display_config_attribute_changed(GtkWidget *object, gpointer arg1,
+static void display_config_attribute_changed(GtkWidget *object,
+ CtrlEvent *event,
gpointer user_data)
{
CtkDisplayConfig *ctk_object = (CtkDisplayConfig *) user_data;
diff --git a/src/gtk+-2.x/ctkdisplayconfig.h b/src/gtk+-2.x/ctkdisplayconfig.h
index 73b411f..149a845 100644
--- a/src/gtk+-2.x/ctkdisplayconfig.h
+++ b/src/gtk+-2.x/ctkdisplayconfig.h
@@ -78,7 +78,7 @@ typedef struct _CtkDisplayConfig
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
gboolean page_selected; /* Is the display config page selected in the UI */
@@ -243,8 +243,7 @@ typedef struct _CtkDisplayConfigClass
GType ctk_display_config_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_display_config_new (NvCtrlAttributeHandle *,
- CtkConfig *);
+GtkWidget* ctk_display_config_new (CtrlTarget *, CtkConfig *);
GtkTextBuffer *ctk_display_config_create_help(GtkTextTagTable *,
CtkDisplayConfig *);
diff --git a/src/gtk+-2.x/ctkdisplaydevice.c b/src/gtk+-2.x/ctkdisplaydevice.c
index 80bbbde..4b4e62d 100644
--- a/src/gtk+-2.x/ctkdisplaydevice.c
+++ b/src/gtk+-2.x/ctkdisplaydevice.c
@@ -45,13 +45,13 @@ static void update_device_info(CtkDisplayDevice *ctk_object);
static void display_device_setup(CtkDisplayDevice *ctk_object);
-static void enabled_displays_received(GObject *object, gpointer arg1,
+static void enabled_displays_received(GObject *object, CtrlEvent *event,
gpointer user_data);
-static void callback_link_changed(GObject *object, gpointer arg1,
+static void callback_link_changed(GObject *object, CtrlEvent *event,
gpointer user_data);
-static void callback_refresh_rate_changed(GObject *object, gpointer arg1,
+static void callback_refresh_rate_changed(GObject *object, CtrlEvent *event,
gpointer user_data);
static gboolean update_guid_info(InfoEntry *entry);
@@ -223,7 +223,7 @@ static void ctk_display_device_finalize(
* ctk_display_device_new() - constructor for the dissplay device page.
*/
-GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_display_device_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
CtkEvent *ctk_event,
CtkEvent *ctk_event_gpu,
@@ -250,7 +250,7 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle,
if (!object) return NULL;
ctk_object = CTK_DISPLAY_DEVICE(object);
- ctk_object->handle = handle;
+ ctk_object->ctrl_target = ctrl_target;
ctk_object->ctk_event = ctk_event;
ctk_object->ctk_event_gpu = ctk_event_gpu;
ctk_object->ctk_config = ctk_config;
@@ -351,7 +351,7 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle,
/* pack the EDID button */
- ctk_object->edid = ctk_edid_new(ctk_object->handle,
+ ctk_object->edid = ctk_edid_new(ctrl_target,
ctk_object->ctk_config,
ctk_object->ctk_event,
ctk_object->name);
@@ -385,7 +385,7 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle,
/* pack the color controls */
ctk_object->color_controls =
- ctk_color_controls_new(handle, ctk_config, ctk_event,
+ ctk_color_controls_new(ctrl_target, ctk_config, ctk_event,
ctk_object->reset_button, name);
if (ctk_object->color_controls) {
@@ -396,7 +396,7 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle,
/* pack the dithering controls */
ctk_object->dithering_controls =
- ctk_dithering_controls_new(handle, ctk_config, ctk_event,
+ ctk_dithering_controls_new(ctrl_target, ctk_config, ctk_event,
ctk_object->reset_button, name);
if (ctk_object->dithering_controls) {
@@ -407,7 +407,7 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle,
/* pack the image sliders */
ctk_object->image_sliders =
- ctk_image_sliders_new(handle, ctk_config, ctk_event,
+ ctk_image_sliders_new(ctrl_target, ctk_config, ctk_event,
ctk_object->reset_button, name);
if (ctk_object->image_sliders) {
gtk_box_pack_start(GTK_BOX(nbox), ctk_object->image_sliders,
@@ -553,18 +553,20 @@ GtkTextBuffer *ctk_display_device_create_help(GtkTextTagTable *table,
static gboolean update_guid_info(InfoEntry *entry)
{
CtkDisplayDevice *ctk_object = entry->ctk_object;
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
ReturnStatus ret;
char *str;
- ret = NvCtrlGetStringDisplayAttribute(ctk_object->handle, 0,
- NV_CTRL_STRING_DISPLAY_NAME_DP_GUID, &str);
+ ret = NvCtrlGetStringAttribute(ctrl_target,
+ NV_CTRL_STRING_DISPLAY_NAME_DP_GUID,
+ &str);
if (ret != NvCtrlSuccess) {
return FALSE;
}
gtk_label_set_text(GTK_LABEL(entry->txt), str);
- XFree(str);
+ free(str);
return TRUE;
}
@@ -574,18 +576,20 @@ static gboolean update_guid_info(InfoEntry *entry)
static gboolean update_tv_encoder_info(InfoEntry *entry)
{
CtkDisplayDevice *ctk_object = entry->ctk_object;
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
ReturnStatus ret;
char *str;
- ret = NvCtrlGetStringDisplayAttribute(ctk_object->handle, 0,
- NV_CTRL_STRING_TV_ENCODER_NAME, &str);
+ ret = NvCtrlGetStringAttribute(ctrl_target,
+ NV_CTRL_STRING_TV_ENCODER_NAME,
+ &str);
if (ret != NvCtrlSuccess) {
return FALSE;
}
gtk_label_set_text(GTK_LABEL(entry->txt), str);
- XFree(str);
+ free(str);
return TRUE;
}
@@ -595,11 +599,12 @@ static gboolean update_tv_encoder_info(InfoEntry *entry)
static gboolean update_chip_info(InfoEntry *entry)
{
CtkDisplayDevice *ctk_object = entry->ctk_object;
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
ReturnStatus ret;
gint val;
const gchar *str;
- ret = NvCtrlGetAttribute(ctk_object->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FLATPANEL_CHIP_LOCATION, &val);
if (ret != NvCtrlSuccess) {
return FALSE;
@@ -627,12 +632,12 @@ static gboolean update_chip_info(InfoEntry *entry)
static gboolean update_signal_info(InfoEntry *entry)
{
CtkDisplayDevice *ctk_object = entry->ctk_object;
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
ReturnStatus ret;
gint val;
const char *str;
- ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_FLATPANEL_SIGNAL,
- &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_FLATPANEL_SIGNAL, &val);
if (ret != NvCtrlSuccess) {
return FALSE;
}
@@ -666,12 +671,13 @@ static gboolean update_signal_info(InfoEntry *entry)
static gboolean update_link_info(InfoEntry *entry)
{
CtkDisplayDevice *ctk_object = entry->ctk_object;
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
ReturnStatus ret;
gint val;
const char *link;
char tmp[32];
- ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_FLATPANEL_LINK, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_FLATPANEL_LINK, &val);
if (ret != NvCtrlSuccess) {
return FALSE;
}
@@ -681,8 +687,8 @@ static gboolean update_link_info(InfoEntry *entry)
lanes = val + 1;
- ret = NvCtrlGetAttribute(ctk_object->handle,
- NV_CTRL_DISPLAYPORT_LINK_RATE, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_DISPLAYPORT_LINK_RATE,
+ &val);
if ((ret == NvCtrlSuccess) &&
(val == NV_CTRL_DISPLAYPORT_LINK_RATE_DISABLED)) {
link = "Disabled";
@@ -725,18 +731,19 @@ static gboolean update_link_info(InfoEntry *entry)
static gboolean update_refresh_rate(InfoEntry *entry)
{
CtkDisplayDevice *ctk_object = entry->ctk_object;
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
ReturnStatus ret;
gint val;
gboolean hdmi3D;
char *str;
float fvalue;
- ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_REFRESH_RATE, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_REFRESH_RATE, &val);
if (ret != NvCtrlSuccess) {
return FALSE;
}
- ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_DPY_HDMI_3D, &hdmi3D);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_DPY_HDMI_3D, &hdmi3D);
if (ret != NvCtrlSuccess) {
return FALSE;
}
@@ -802,13 +809,14 @@ static void update_device_info(CtkDisplayDevice *ctk_object)
*/
static void display_device_setup(CtkDisplayDevice *ctk_object)
{
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
+
/* Disable the reset button here and allow the controls below to (re)enable
* it if need be,.
*/
gtk_widget_set_sensitive(ctk_object->reset_button, FALSE);
- update_display_enabled_flag(ctk_object->handle,
- &ctk_object->display_enabled);
+ update_display_enabled_flag(ctrl_target, &ctk_object->display_enabled);
/* Update info */
@@ -892,7 +900,8 @@ static gboolean unregister_refresh_rate_events(InfoEntry *entry)
* this page should disable/enable access based on whether
* or not the display device is enabled.
*/
-static void enabled_displays_received(GObject *object, gpointer arg1,
+static void enabled_displays_received(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
CtkDisplayDevice *ctk_object = CTK_DISPLAY_DEVICE(user_data);
@@ -904,7 +913,8 @@ static void enabled_displays_received(GObject *object, gpointer arg1,
} /* enabled_displays_received() */
-static void callback_link_changed(GObject *object, gpointer arg1,
+static void callback_link_changed(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
InfoEntry *entry = (InfoEntry *)user_data;
@@ -913,7 +923,8 @@ static void callback_link_changed(GObject *object, gpointer arg1,
}
-static void callback_refresh_rate_changed(GObject *object, gpointer arg1,
+static void callback_refresh_rate_changed(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
InfoEntry *entry = (InfoEntry *)user_data;
@@ -928,12 +939,13 @@ static void add_color_correction_tab(CtkDisplayDevice *ctk_object,
GtkWidget *notebook,
ParsedAttribute *p)
{
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
ReturnStatus ret;
gint val;
GtkWidget *ctk_color_correction;
GtkWidget *box;
- ret = NvCtrlGetAttribute(ctk_object->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE, &val);
if (ret != NvCtrlSuccess) {
@@ -944,7 +956,7 @@ static void add_color_correction_tab(CtkDisplayDevice *ctk_object,
return;
}
- ctk_color_correction = ctk_color_correction_new(ctk_object->handle,
+ ctk_color_correction = ctk_color_correction_new(ctrl_target,
ctk_config,
p,
ctk_event);
diff --git a/src/gtk+-2.x/ctkdisplaydevice.h b/src/gtk+-2.x/ctkdisplaydevice.h
index 08d59d1..89fe1de 100644
--- a/src/gtk+-2.x/ctkdisplaydevice.h
+++ b/src/gtk+-2.x/ctkdisplaydevice.h
@@ -63,7 +63,7 @@ struct _CtkDisplayDevice
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
CtkEvent *ctk_event;
CtkEvent *ctk_event_gpu;
@@ -91,8 +91,7 @@ struct _CtkDisplayDeviceClass
};
GType ctk_display_device_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_display_device_new (NvCtrlAttributeHandle *,
- CtkConfig *, CtkEvent *,
+GtkWidget* ctk_display_device_new (CtrlTarget *, CtkConfig *, CtkEvent *,
CtkEvent *, char *, char *,
ParsedAttribute *);
diff --git a/src/gtk+-2.x/ctkdisplaylayout.c b/src/gtk+-2.x/ctkdisplaylayout.c
index 9161cdc..a5f78f9 100644
--- a/src/gtk+-2.x/ctkdisplaylayout.c
+++ b/src/gtk+-2.x/ctkdisplaylayout.c
@@ -2601,8 +2601,7 @@ GType ctk_display_layout_get_type(void)
* CTK Display Layout widget creation.
*
*/
-GtkWidget* ctk_display_layout_new(NvCtrlAttributeHandle *handle,
- CtkConfig *ctk_config,
+GtkWidget* ctk_display_layout_new(CtkConfig *ctk_config,
nvLayoutPtr layout,
int width,
int height)
@@ -2614,10 +2613,6 @@ GtkWidget* ctk_display_layout_new(NvCtrlAttributeHandle *handle,
int i, j;
- /* Make sure we have a handle */
- g_return_val_if_fail(handle != NULL, NULL);
-
-
/* Create the ctk object */
object = g_object_new(CTK_TYPE_DISPLAY_LAYOUT, NULL);
ctk_object = CTK_DISPLAY_LAYOUT(object);
@@ -2632,7 +2627,6 @@ GtkWidget* ctk_display_layout_new(NvCtrlAttributeHandle *handle,
/* Setup widget properties */
ctk_object->ctk_config = ctk_config;
- ctk_object->handle = handle;
ctk_object->layout = layout;
sync_layout(ctk_object);
@@ -3018,7 +3012,7 @@ static void draw_display(CtkDisplayLayout *ctk_object,
mode = display->cur_mode;
base_color_idx =
- NUM_COLORS_PER_PALETTE * NvCtrlGetTargetId(display->gpu->handle);
+ NUM_COLORS_PER_PALETTE * NvCtrlGetTargetId(display->gpu->ctrl_target);
/* Draw panning */
diff --git a/src/gtk+-2.x/ctkdisplaylayout.h b/src/gtk+-2.x/ctkdisplaylayout.h
index bcfd1b0..7b17328 100644
--- a/src/gtk+-2.x/ctkdisplaylayout.h
+++ b/src/gtk+-2.x/ctkdisplaylayout.h
@@ -226,7 +226,7 @@ typedef struct nvDisplayRec {
struct nvDisplayRec *next_in_screen;
XConfigMonitorPtr conf_monitor;
- NvCtrlAttributeHandle *handle; /* NV-CONTROL handle to device */
+ CtrlTarget *ctrl_target;
struct nvGpuRec *gpu; /* GPU the display belongs to */
struct nvScreenRec *screen; /* X screen the display is tied to */
@@ -295,7 +295,7 @@ typedef struct nvScreenRec {
*
*/
- NvCtrlAttributeHandle *handle; /* NV-CONTROL handle to X screen */
+ CtrlTarget *ctrl_target;
CtkEvent *ctk_event;
int scrnum;
@@ -356,7 +356,7 @@ typedef struct GvoModeDataRec {
typedef struct nvGpuRec {
struct nvGpuRec *next_in_layout; /* List of all GPUs */
- NvCtrlAttributeHandle *handle; /* NV-CONTROL handle to GPU */
+ CtrlTarget *ctrl_target;
CtkEvent *ctk_event;
struct nvLayoutRec *layout; /* Layout this GPU belongs to */
@@ -394,7 +394,9 @@ typedef struct nvLayoutRec {
XConfigLayoutPtr conf_layout;
char *filename;
- NvCtrlAttributeHandle *handle;
+ CtrlSystemList systems; /* Holds 1 system */
+ CtrlSystem *system;
+
nvGpuPtr gpus; /* Linked list of GPUs (next_in_layout) */
int num_gpus;
@@ -469,7 +471,6 @@ typedef struct _CtkDisplayLayout
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
CtkConfig *ctk_config;
GtkWidget *drawing_area; /* Drawing area */
@@ -544,8 +545,7 @@ typedef struct _CtkDisplayLayoutClass
GType ctk_display_layout_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_display_layout_new (NvCtrlAttributeHandle *,
- CtkConfig *,
+GtkWidget* ctk_display_layout_new (CtkConfig *,
nvLayoutPtr, /* Layout to display */
int, /* Width of image */
int /* Height of image */
diff --git a/src/gtk+-2.x/ctkditheringcontrols.c b/src/gtk+-2.x/ctkditheringcontrols.c
index dee39dd..3ddd6fb 100644
--- a/src/gtk+-2.x/ctkditheringcontrols.c
+++ b/src/gtk+-2.x/ctkditheringcontrols.c
@@ -65,7 +65,7 @@ static void dithering_mode_menu_changed(GtkWidget *dithering_mode_menu,
static void dithering_config_menu_changed(GtkWidget *dithering_config_menu,
gpointer user_data);
-static void dithering_update_received(GObject *object, gpointer arg1,
+static void dithering_update_received(GObject *object, CtrlEvent *event,
gpointer user_data);
static
@@ -151,7 +151,7 @@ static void ctk_dither_controls_finalize(GObject *object)
(gpointer) ctk_object);
}
-GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_dithering_controls_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
CtkEvent *ctk_event,
GtkWidget *reset_button,
@@ -166,7 +166,7 @@ GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle,
int tmp;
/* test that dithering is available before creating the widget */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_DITHERING, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_DITHERING, &tmp);
if (ret != NvCtrlSuccess) {
return NULL;
}
@@ -178,7 +178,7 @@ GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle,
}
ctk_dithering_controls = CTK_DITHERING_CONTROLS(object);
- ctk_dithering_controls->handle = handle;
+ ctk_dithering_controls->ctrl_target = ctrl_target;
ctk_dithering_controls->ctk_event = ctk_event;
ctk_dithering_controls->ctk_config = ctk_config;
ctk_dithering_controls->reset_button = reset_button;
@@ -455,6 +455,7 @@ static void setup_reset_button(CtkDitheringControls *ctk_dithering_controls)
static void
setup_dithering_depth_menu(CtkDitheringControls *ctk_dithering_controls)
{
+ CtrlTarget *ctrl_target = ctk_dithering_controls->ctrl_target;
CtkDropDownMenu *dithering_depth_menu;
gint val;
ReturnStatus ret;
@@ -462,8 +463,7 @@ setup_dithering_depth_menu(CtkDitheringControls *ctk_dithering_controls)
CTK_DROP_DOWN_MENU(ctk_dithering_controls->dithering_depth_menu);
/* dithering depth */
- ret = NvCtrlGetAttribute(ctk_dithering_controls->handle,
- NV_CTRL_DITHERING_DEPTH, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_DITHERING_DEPTH, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_DITHERING_DEPTH_AUTO;
}
@@ -486,6 +486,7 @@ setup_dithering_depth_menu(CtkDitheringControls *ctk_dithering_controls)
static void
setup_dithering_mode_menu(CtkDitheringControls *ctk_dithering_controls)
{
+ CtrlTarget *ctrl_target = ctk_dithering_controls->ctrl_target;
CtkDropDownMenu *dithering_mode_menu;
gint val, i;
ReturnStatus ret;
@@ -523,8 +524,7 @@ setup_dithering_mode_menu(CtkDitheringControls *ctk_dithering_controls)
}
/* dithering mode */
- ret = NvCtrlGetAttribute(ctk_dithering_controls->handle,
- NV_CTRL_DITHERING_MODE, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_DITHERING_MODE, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_DITHERING_MODE_AUTO;
}
@@ -545,6 +545,7 @@ setup_dithering_mode_menu(CtkDitheringControls *ctk_dithering_controls)
static void
setup_dithering_config_menu(CtkDitheringControls *ctk_dithering_controls)
{
+ CtrlTarget *ctrl_target = ctk_dithering_controls->ctrl_target;
CtkDropDownMenu *dithering_config_menu;
gint val;
dithering_config_menu =
@@ -552,7 +553,7 @@ setup_dithering_config_menu(CtkDitheringControls *ctk_dithering_controls)
/* dithering */
if (NvCtrlSuccess !=
- NvCtrlGetAttribute(ctk_dithering_controls->handle,
+ NvCtrlGetAttribute(ctrl_target,
NV_CTRL_DITHERING, &val)) {
val = NV_CTRL_DITHERING_AUTO;
return;
@@ -614,11 +615,11 @@ static Bool update_dithering_info(gpointer user_data)
{
CtkDitheringControls *ctk_dithering_controls =
CTK_DITHERING_CONTROLS(user_data);
+ CtrlTarget *ctrl_target = ctk_dithering_controls->ctrl_target;
ReturnStatus ret;
gint val;
- ret = NvCtrlGetAttribute(ctk_dithering_controls->handle,
- NV_CTRL_DITHERING, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_DITHERING, &val);
if (ret != NvCtrlSuccess) {
/* Dithering is not currently available */
return FALSE;
@@ -638,8 +639,7 @@ static Bool update_dithering_info(gpointer user_data)
}
/* current dithering */
- ret = NvCtrlGetAttribute(ctk_dithering_controls->handle,
- NV_CTRL_CURRENT_DITHERING, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_CURRENT_DITHERING, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_CURRENT_DITHERING_DISABLED;
}
@@ -653,8 +653,8 @@ static Bool update_dithering_info(gpointer user_data)
}
/* current dithering mode */
- ret = NvCtrlGetAttribute(ctk_dithering_controls->handle,
- NV_CTRL_CURRENT_DITHERING_MODE, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_CURRENT_DITHERING_MODE,
+ &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_CURRENT_DITHERING_MODE_NONE;
}
@@ -679,8 +679,8 @@ static Bool update_dithering_info(gpointer user_data)
break;
}
/* current dithering depth */
- ret = NvCtrlGetAttribute(ctk_dithering_controls->handle,
- NV_CTRL_CURRENT_DITHERING_DEPTH, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_CURRENT_DITHERING_DEPTH,
+ &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_CURRENT_DITHERING_DEPTH_NONE;
}
@@ -777,6 +777,7 @@ static void dithering_config_menu_changed(GtkWidget *dithering_config_menu,
{
CtkDitheringControls *ctk_dithering_controls =
CTK_DITHERING_CONTROLS(user_data);
+ CtrlTarget *ctrl_target = ctk_dithering_controls->ctrl_target;
CtkDropDownMenu *menu = CTK_DROP_DOWN_MENU(dithering_config_menu);
gint history, dithering_config = NV_CTRL_DITHERING_AUTO;
@@ -784,9 +785,7 @@ static void dithering_config_menu_changed(GtkWidget *dithering_config_menu,
dithering_config = map_dithering_config_menu_idx_to_nvctrl(history);
- NvCtrlSetAttribute(ctk_dithering_controls->handle,
- NV_CTRL_DITHERING,
- dithering_config);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_DITHERING, dithering_config);
/* reflecting the change in configuration to other widgets & reset button */
setup_dithering_info(ctk_dithering_controls);
@@ -800,6 +799,7 @@ static void dithering_mode_menu_changed(GtkWidget *dithering_mode_menu,
{
CtkDitheringControls *ctk_dithering_controls =
CTK_DITHERING_CONTROLS(user_data);
+ CtrlTarget *ctrl_target = ctk_dithering_controls->ctrl_target;
CtkDropDownMenu *menu = CTK_DROP_DOWN_MENU(dithering_mode_menu);
gint history, dithering_mode = NV_CTRL_DITHERING_MODE_AUTO;
@@ -807,9 +807,7 @@ static void dithering_mode_menu_changed(GtkWidget *dithering_mode_menu,
dithering_mode = ctk_dithering_controls->dithering_mode_table[history];
- NvCtrlSetAttribute(ctk_dithering_controls->handle,
- NV_CTRL_DITHERING_MODE,
- dithering_mode);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_DITHERING_MODE, dithering_mode);
dithering_mode = map_nvctrl_value_to_table(ctk_dithering_controls,
dithering_mode);
@@ -824,6 +822,7 @@ static void dithering_depth_menu_changed(GtkWidget *dithering_depth_menu,
{
CtkDitheringControls *ctk_dithering_controls =
CTK_DITHERING_CONTROLS(user_data);
+ CtrlTarget *ctrl_target = ctk_dithering_controls->ctrl_target;
CtkDropDownMenu *menu = CTK_DROP_DOWN_MENU(dithering_depth_menu);
gint history, dithering_depth = NV_CTRL_DITHERING_DEPTH_AUTO;
@@ -831,8 +830,7 @@ static void dithering_depth_menu_changed(GtkWidget *dithering_depth_menu,
dithering_depth = map_dithering_depth_menu_idx_to_nvctrl(history);
- NvCtrlSetAttribute(ctk_dithering_controls->handle,
- NV_CTRL_DITHERING_DEPTH,
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_DITHERING_DEPTH,
dithering_depth);
/* reflecting the change in configuration to other widgets & reset button */
@@ -848,19 +846,23 @@ static void dithering_depth_menu_changed(GtkWidget *dithering_depth_menu,
*/
void ctk_dithering_controls_reset(CtkDitheringControls *ctk_dithering_controls)
{
+ CtrlTarget *ctrl_target;
+
if (!ctk_dithering_controls) {
return;
}
- NvCtrlSetAttribute(ctk_dithering_controls->handle,
+ ctrl_target = ctk_dithering_controls->ctrl_target;
+
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_DITHERING,
NV_CTRL_DITHERING_AUTO);
- NvCtrlSetAttribute(ctk_dithering_controls->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_DITHERING_MODE,
NV_CTRL_DITHERING_MODE_AUTO);
- NvCtrlSetAttribute(ctk_dithering_controls->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_DITHERING_DEPTH,
NV_CTRL_DITHERING_DEPTH_AUTO);
@@ -897,22 +899,29 @@ void add_dithering_controls_help(CtkDitheringControls *ctk_dithering_controls,
* When dithering configuration is enabled/disabled,
* we should update the GUI to reflect the current state & mode.
*/
-static void dithering_update_received(GObject *object, gpointer arg1,
+static void dithering_update_received(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
CtkDitheringControls *ctk_object = CTK_DITHERING_CONTROLS(user_data);
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
+
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
ctk_dithering_controls_setup(ctk_object);
/* update status bar message */
- switch (event_struct->attribute) {
+ switch (event->int_attr.attribute) {
case NV_CTRL_DITHERING:
- post_dithering_config_update(ctk_object, event_struct->value); break;
+ post_dithering_config_update(ctk_object, event->int_attr.value);
+ break;
case NV_CTRL_DITHERING_MODE:
- post_dithering_mode_update(ctk_object, event_struct->value); break;
+ post_dithering_mode_update(ctk_object, event->int_attr.value);
+ break;
case NV_CTRL_DITHERING_DEPTH:
- post_dithering_depth_update(ctk_object, event_struct->value); break;
+ post_dithering_depth_update(ctk_object, event->int_attr.value);
+ break;
}
} /* dithering_update_received() */
@@ -923,6 +932,7 @@ static void dithering_update_received(GObject *object, gpointer arg1,
*/
static gboolean build_dithering_mode_table(CtkDitheringControls *ctk_dithering_controls)
{
+ CtrlTarget *ctrl_target = ctk_dithering_controls->ctrl_target;
ReturnStatus ret;
NVCTRLAttributeValidValuesRec valid;
gint i, n = 0, num_of_modes = 0, mask;
@@ -934,7 +944,7 @@ static gboolean build_dithering_mode_table(CtkDitheringControls *ctk_dithering_c
}
ret =
- NvCtrlGetValidAttributeValues(ctk_dithering_controls->handle,
+ NvCtrlGetValidAttributeValues(ctrl_target,
NV_CTRL_DITHERING_MODE,
&valid);
diff --git a/src/gtk+-2.x/ctkditheringcontrols.h b/src/gtk+-2.x/ctkditheringcontrols.h
index 4cb00b8..8415f3f 100644
--- a/src/gtk+-2.x/ctkditheringcontrols.h
+++ b/src/gtk+-2.x/ctkditheringcontrols.h
@@ -52,7 +52,7 @@ struct _CtkDitheringControls
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
char *name;
GtkWidget *reset_button;
@@ -81,7 +81,7 @@ struct _CtkDitheringControlsClass
};
GType ctk_dithering_controls_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_dithering_controls_new (NvCtrlAttributeHandle *,
+GtkWidget* ctk_dithering_controls_new (CtrlTarget *,
CtkConfig *, CtkEvent *,
GtkWidget *,
char *);
diff --git a/src/gtk+-2.x/ctkecc.c b/src/gtk+-2.x/ctkecc.c
index 21f9f00..d7208b1 100644
--- a/src/gtk+-2.x/ctkecc.c
+++ b/src/gtk+-2.x/ctkecc.c
@@ -67,7 +67,7 @@ static const char *__reset_default_config_button_help =
static void ecc_config_button_toggled(GtkWidget *, gpointer);
static void show_ecc_toggle_warning_dlg(CtkEcc *);
static void ecc_set_config_status(CtkEcc *);
-static void ecc_configuration_update_received(GObject *, gpointer, gpointer);
+static void ecc_configuration_update_received(GObject *, CtrlEvent *, gpointer);
static void post_ecc_configuration_update(CtkEcc *);
GType ctk_ecc_get_type(void)
@@ -154,17 +154,18 @@ static GtkWidget *add_table_int_row(CtkConfig *ctk_config, GtkWidget *table,
static gboolean update_ecc_info(gpointer user_data)
{
CtkEcc *ctk_ecc = CTK_ECC(user_data);
+ CtrlTarget *ctrl_target = ctk_ecc->ctrl_target;
int64_t val;
ReturnStatus ret;
if ( ctk_ecc->ecc_enabled == FALSE ) {
return FALSE;
}
-
+
/* Query ECC Errors */
if ( ctk_ecc->dbit_error ) {
- ret = NvCtrlGetAttribute64(ctk_ecc->handle,
+ ret = NvCtrlGetAttribute64(ctrl_target,
NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS,
&val);
if ( ret != NvCtrlSuccess ) {
@@ -174,7 +175,7 @@ static gboolean update_ecc_info(gpointer user_data)
}
if ( ctk_ecc->aggregate_dbit_error ) {
- ret = NvCtrlGetAttribute64(ctk_ecc->handle,
+ ret = NvCtrlGetAttribute64(ctrl_target,
NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS,
&val);
if ( ret != NvCtrlSuccess ) {
@@ -239,12 +240,16 @@ static void ecc_set_config_status(CtkEcc *ctk_ecc)
*/
static void ecc_configuration_update_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkEcc *ctk_ecc = CTK_ECC(user_data);
- ctk_ecc->ecc_configured = event_struct->value;
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ ctk_ecc->ecc_configured = event->int_attr.value;
/* set ECC configuration button status */
ecc_set_config_status(ctk_ecc);
@@ -266,9 +271,10 @@ static void reset_default_config_button_clicked(GtkWidget *widget,
gboolean status;
ReturnStatus ret;
CtkEcc *ctk_ecc = CTK_ECC(user_data);
-
+ CtrlTarget *ctrl_target = ctk_ecc->ctrl_target;
+
/* get default status and set it to ECC configuration */
- ret = NvCtrlGetAttribute(ctk_ecc->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION,
&status);
if (ret != NvCtrlSuccess) {
@@ -276,7 +282,7 @@ static void reset_default_config_button_clicked(GtkWidget *widget,
"Failed to get default configuration!");
return;
}
- ret = NvCtrlSetAttribute(ctk_ecc->handle,
+ ret = NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GPU_ECC_CONFIGURATION,
status);
if (ret != NvCtrlSuccess) {
@@ -310,11 +316,12 @@ static void clear_ecc_errors_button_clicked(GtkWidget *widget,
gpointer user_data)
{
CtkEcc *ctk_ecc = CTK_ECC(user_data);
-
- NvCtrlSetAttribute(ctk_ecc->handle,
+ CtrlTarget *ctrl_target = ctk_ecc->ctrl_target;
+
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GPU_ECC_RESET_ERROR_STATUS,
NV_CTRL_GPU_ECC_RESET_ERROR_STATUS_VOLATILE);
-
+
ctk_config_statusbar_message(ctk_ecc->ctk_config,
"ECC errors cleared.");
} /* clear_ecc_errors_button_clicked() */
@@ -330,11 +337,12 @@ static void clear_aggregate_ecc_errors_button_clicked(GtkWidget *widget,
gpointer user_data)
{
CtkEcc *ctk_ecc = CTK_ECC(user_data);
-
- NvCtrlSetAttribute(ctk_ecc->handle,
+ CtrlTarget *ctrl_target = ctk_ecc->ctrl_target;
+
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GPU_ECC_RESET_ERROR_STATUS,
NV_CTRL_GPU_ECC_RESET_ERROR_STATUS_AGGREGATE);
-
+
ctk_config_statusbar_message(ctk_ecc->ctk_config,
"ECC aggregate errors cleared.");
} /* clear_aggregate_ecc_errors_button_clicked() */
@@ -375,6 +383,7 @@ static void ecc_config_button_toggled(GtkWidget *widget,
{
gboolean enabled;
CtkEcc *ctk_ecc = CTK_ECC(user_data);
+ CtrlTarget *ctrl_target = ctk_ecc->ctrl_target;
ReturnStatus ret;
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
@@ -383,7 +392,7 @@ static void ecc_config_button_toggled(GtkWidget *widget,
show_ecc_toggle_warning_dlg(ctk_ecc);
/* set the newly specified ECC value */
- ret = NvCtrlSetAttribute(ctk_ecc->handle,
+ ret = NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GPU_ECC_CONFIGURATION,
enabled);
if (ret != NvCtrlSuccess) {
@@ -391,7 +400,7 @@ static void ecc_config_button_toggled(GtkWidget *widget,
"Failed to set ECC configuration!");
return;
}
-
+
ctk_ecc->ecc_configured = enabled;
gtk_widget_set_sensitive(ctk_ecc->reset_default_config_button, TRUE);
@@ -402,7 +411,7 @@ static void ecc_config_button_toggled(GtkWidget *widget,
-GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_ecc_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
CtkEvent *ctk_event)
{
@@ -424,13 +433,14 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle,
/* make sure we have a handle */
- g_return_val_if_fail(handle != NULL, NULL);
+ g_return_val_if_fail((ctrl_target != NULL) &&
+ (ctrl_target->h != NULL), NULL);
/*
* check if ECC support available.
*/
- ret = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GPU_ECC_SUPPORTED,
&val);
if (ret != NvCtrlSuccess || val != NV_CTRL_GPU_ECC_SUPPORTED_TRUE) {
@@ -442,7 +452,7 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle,
object = g_object_new(CTK_TYPE_ECC, NULL);
ctk_ecc = CTK_ECC(object);
- ctk_ecc->handle = handle;
+ ctk_ecc->ctrl_target = ctrl_target;
ctk_ecc->ctk_config = ctk_config;
ctk_ecc->ecc_toggle_warning_dlg_shown = FALSE;
@@ -454,7 +464,7 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle,
/* Query ECC Status */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_ECC_STATUS,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_ECC_STATUS,
&val);
if (ret != NvCtrlSuccess || val == NV_CTRL_GPU_ECC_STATUS_DISABLED) {
ecc_enabled = FALSE;
@@ -467,7 +477,8 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle,
/* Query ECC Configuration */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_ECC_CONFIGURATION, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_ECC_CONFIGURATION,
+ &val);
if (ret != NvCtrlSuccess ||
val == NV_CTRL_GPU_ECC_CONFIGURATION_DISABLED) {
ctk_ecc->ecc_configured = FALSE;
@@ -476,7 +487,7 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle,
}
/* get default status */
- ret = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION,
&val);
if (ret != NvCtrlSuccess ||
@@ -488,14 +499,15 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle,
/* Query ECC errors */
- ret = NvCtrlGetAttribute64(handle, NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS,
- &dbit_error);
+ ret = NvCtrlGetAttribute64(ctrl_target,
+ NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS,
+ &dbit_error);
if ( ret != NvCtrlSuccess ) {
dbit_error_available = FALSE;
}
- ret = NvCtrlGetAttribute64(handle,
- NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS,
- &aggregate_dbit_error);
+ ret = NvCtrlGetAttribute64(ctrl_target,
+ NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS,
+ &aggregate_dbit_error);
if ( ret != NvCtrlSuccess ) {
aggregate_dbit_error_available = FALSE;
}
@@ -503,7 +515,7 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle,
ctk_ecc->aggregate_dbit_error_available = aggregate_dbit_error_available;
/* Query ECC configuration supported */
- ret = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED,
&ecc_config_supported);
if ( ret != NvCtrlSuccess ) {
@@ -654,7 +666,7 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle,
/* Register a timer callback to update Ecc status info */
str = g_strdup_printf("ECC Settings (GPU %d)",
- NvCtrlGetTargetId(handle));
+ NvCtrlGetTargetId(ctrl_target));
ctk_config_add_timer(ctk_ecc->ctk_config,
DEFAULT_UPDATE_ECC_STATUS_INFO_TIME_INTERVAL,
diff --git a/src/gtk+-2.x/ctkecc.h b/src/gtk+-2.x/ctkecc.h
index 1f5c7a4..3251a75 100644
--- a/src/gtk+-2.x/ctkecc.h
+++ b/src/gtk+-2.x/ctkecc.h
@@ -20,7 +20,6 @@
#ifndef __CTK_ECC_H__
#define __CTK_ECC_H__
-#include "NvCtrlAttributes.h"
#include "ctkevent.h"
#include "ctkconfig.h"
@@ -51,7 +50,7 @@ struct _CtkEcc
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
GtkWidget* status;
@@ -77,7 +76,7 @@ struct _CtkEccClass
};
GType ctk_ecc_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_ecc_new (NvCtrlAttributeHandle *, CtkConfig *, CtkEvent *);
+GtkWidget* ctk_ecc_new (CtrlTarget *, CtkConfig *, CtkEvent *);
GtkTextBuffer* ctk_ecc_create_help (GtkTextTagTable *, CtkEcc *);
void ctk_ecc_start_timer (GtkWidget *);
diff --git a/src/gtk+-2.x/ctkedid.c b/src/gtk+-2.x/ctkedid.c
index edf9049..a957127 100644
--- a/src/gtk+-2.x/ctkedid.c
+++ b/src/gtk+-2.x/ctkedid.c
@@ -27,6 +27,7 @@
#include "ctkscale.h"
#include "ctkconfig.h"
#include "ctkhelp.h"
+#include "ctkutils.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -85,10 +86,11 @@ GType ctk_edid_get_type(void)
void ctk_edid_setup(CtkEdid *ctk_object)
{
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
ReturnStatus ret;
gint val;
- ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_EDID_AVAILABLE, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_EDID_AVAILABLE, &val);
if ((ret != NvCtrlSuccess) || (val != NV_CTRL_EDID_AVAILABLE_TRUE)) {
gtk_widget_set_sensitive(ctk_object->button, FALSE);
@@ -99,7 +101,7 @@ void ctk_edid_setup(CtkEdid *ctk_object)
}
-GtkWidget* ctk_edid_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_edid_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config, CtkEvent *ctk_event,
char *name)
{
@@ -114,20 +116,11 @@ GtkWidget* ctk_edid_new(NvCtrlAttributeHandle *handle,
ctk_edid = CTK_EDID(object);
- ctk_edid->handle = handle;
+ ctk_edid->ctrl_target = ctrl_target;
ctk_edid->ctk_config = ctk_config;
ctk_edid->name = name;
ctk_edid->filename = DEFAULT_EDID_FILENAME_BINARY;
ctk_edid->file_format = FILE_FORMAT_BINARY;
- ctk_edid->file_selector =
- gtk_file_chooser_dialog_new("Please select file where "
- "EDID data will be saved.",
- NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(ctk_edid->file_selector),
- ctk_edid->filename);
/* create the frame and vbox */
@@ -159,41 +152,6 @@ GtkWidget* ctk_edid_new(NvCtrlAttributeHandle *handle,
G_CALLBACK(button_clicked),
(gpointer) ctk_edid);
- /* adding file format selection option to file selector dialog */
-
- frame = gtk_frame_new(NULL);
-
- hbox = gtk_hbox_new(FALSE, 10);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), FRAME_PADDING);
- gtk_container_add(GTK_CONTAINER(frame), hbox);
-
- label = gtk_label_new("EDID File Format: ");
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
- ctk_edid->file_format_binary_radio_button =
- gtk_radio_button_new_with_label(NULL, "Binary");
- gtk_box_pack_start(GTK_BOX(hbox), ctk_edid->file_format_binary_radio_button,
- FALSE, FALSE, 0);
- g_signal_connect(G_OBJECT(ctk_edid->file_format_binary_radio_button),
- "toggled", G_CALLBACK(file_format_changed),
- (gpointer) ctk_edid);
-
- ctk_edid->file_format_ascii_radio_button =
- gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON(ctk_edid->file_format_binary_radio_button),
- "ASCII");
- gtk_box_pack_start(GTK_BOX(hbox), ctk_edid->file_format_ascii_radio_button,
- FALSE, FALSE, 0);
- g_signal_connect(G_OBJECT(ctk_edid->file_format_ascii_radio_button),
- "toggled", G_CALLBACK(file_format_changed),
- (gpointer) ctk_edid);
-
- gtk_toggle_button_set_active
- (GTK_TOGGLE_BUTTON(ctk_edid->file_format_binary_radio_button), TRUE);
- gtk_widget_show_all(frame);
- gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(ctk_edid->file_selector),
- frame);
-
gtk_widget_show_all(GTK_WIDGET(object));
ctk_edid_setup(ctk_edid);
@@ -210,7 +168,7 @@ static void normalize_filename(CtkEdid *ctk_edid)
int len = 0, n;
ctk_edid->filename =
- gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(ctk_edid->file_selector));
+ ctk_file_chooser_get_filename(ctk_edid->file_selector);
if (!ctk_edid->filename) {
goto done;
@@ -278,8 +236,7 @@ static void normalize_filename(CtkEdid *ctk_edid)
}
/* modify the file name as per the format selected */
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(ctk_edid->file_selector),
- slash);
+ ctk_file_chooser_set_filename(ctk_edid->file_selector, slash);
done:
free(filename);
free(buffer);
@@ -295,14 +252,16 @@ static void button_clicked(GtkButton *button, gpointer user_data)
{
ReturnStatus ret;
CtkEdid *ctk_edid = CTK_EDID(user_data);
+ CtrlTarget *ctrl_target = ctk_edid->ctrl_target;
unsigned char *data = NULL;
int len = 0;
gint result;
-
+ GtkWidget *file_format_frame, *label, *hbox;
+
/* Grab EDID information */
-
- ret = NvCtrlGetBinaryAttribute(ctk_edid->handle, 0,
+
+ ret = NvCtrlGetBinaryAttribute(ctrl_target, 0,
NV_CTRL_BINARY_DATA_EDID,
&data, &len);
if (ret != NvCtrlSuccess) {
@@ -311,36 +270,83 @@ static void button_clicked(GtkButton *button, gpointer user_data)
ctk_edid->name);
} else {
- /* Ask user for filename */
+ /* Create a dialog and ask user for filename */
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(ctk_edid->file_selector),
+ ctk_edid->file_selector =
+ ctk_file_chooser_dialog_new("Please select file where "
+ "EDID data will be saved.",
+ NULL, GTK_FILE_CHOOSER_ACTION_SAVE);
+
+ ctk_file_chooser_set_filename(ctk_edid->file_selector,
ctk_edid->filename);
+ /* adding file format selection option to file selector dialog */
+
+ file_format_frame = gtk_frame_new(NULL);
+
+ hbox = gtk_hbox_new(FALSE, 10);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), FRAME_PADDING);
+ gtk_container_add(GTK_CONTAINER(file_format_frame), hbox);
+
+ label = gtk_label_new("EDID File Format: ");
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+ ctk_edid->file_format_binary_radio_button =
+ gtk_radio_button_new_with_label(NULL, "Binary");
+ gtk_box_pack_start(GTK_BOX(hbox),
+ ctk_edid->file_format_binary_radio_button,
+ FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(ctk_edid->file_format_binary_radio_button),
+ "toggled", G_CALLBACK(file_format_changed),
+ (gpointer) ctk_edid);
+
+ ctk_edid->file_format_ascii_radio_button =
+ gtk_radio_button_new_with_label_from_widget
+ (GTK_RADIO_BUTTON(ctk_edid->file_format_binary_radio_button),
+ "ASCII");
+ gtk_box_pack_start(GTK_BOX(hbox),
+ ctk_edid->file_format_ascii_radio_button,
+ FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(ctk_edid->file_format_ascii_radio_button),
+ "toggled", G_CALLBACK(file_format_changed),
+ (gpointer) ctk_edid);
+
+ if (ctk_edid->file_format == FILE_FORMAT_BINARY) {
+ gtk_toggle_button_set_active
+ (GTK_TOGGLE_BUTTON(ctk_edid->file_format_binary_radio_button),
+ TRUE);
+ } else {
+ gtk_toggle_button_set_active
+ (GTK_TOGGLE_BUTTON(ctk_edid->file_format_ascii_radio_button),
+ TRUE);
+ }
+
+ gtk_widget_show_all(file_format_frame);
+
+ ctk_file_chooser_set_extra_widget(ctk_edid->file_selector,
+ file_format_frame);
+
+ /* Run dialog */
+
result = gtk_dialog_run(GTK_DIALOG(ctk_edid->file_selector));
- gtk_widget_hide(ctk_edid->file_selector);
-
- switch ( result ) {
- case GTK_RESPONSE_ACCEPT:
- case GTK_RESPONSE_OK:
-
- normalize_filename(ctk_edid);
- ctk_edid->filename =
- gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(ctk_edid->file_selector));
-
- write_edid_to_file(ctk_edid->ctk_config, ctk_edid->filename,
- ctk_edid->file_format, data, len);
-
- break;
- default:
- return;
+
+ if (result == GTK_RESPONSE_ACCEPT || result == GTK_RESPONSE_OK) {
+ normalize_filename(ctk_edid);
+
+ write_edid_to_file(ctk_edid->ctk_config, ctk_edid->filename,
+ ctk_edid->file_format, data, len);
}
-
+
+ gtk_widget_destroy(ctk_edid->file_selector);
+
+ ctk_edid->file_selector = NULL;
+ ctk_edid->file_format_ascii_radio_button = NULL;
+ ctk_edid->file_format_binary_radio_button = NULL;
+
} /* EDID available */
- if (data) {
- XFree(data);
- }
-
+ free(data);
+
} /* button_clicked() */
diff --git a/src/gtk+-2.x/ctkedid.h b/src/gtk+-2.x/ctkedid.h
index d29738d..47a5369 100644
--- a/src/gtk+-2.x/ctkedid.h
+++ b/src/gtk+-2.x/ctkedid.h
@@ -52,7 +52,7 @@ struct _CtkEdid
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
GtkWidget *button;
GtkWidget *file_selector;
@@ -71,7 +71,7 @@ struct _CtkEdidClass
};
GType ctk_edid_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_edid_new (NvCtrlAttributeHandle *,
+GtkWidget* ctk_edid_new (CtrlTarget *,
CtkConfig *, CtkEvent *,
char *name);
diff --git a/src/gtk+-2.x/ctkevent.c b/src/gtk+-2.x/ctkevent.c
index 2465b2b..76b0e97 100644
--- a/src/gtk+-2.x/ctkevent.c
+++ b/src/gtk+-2.x/ctkevent.c
@@ -57,10 +57,8 @@ typedef struct __CtkEventNodeRec {
/* dpys should have a single event source object */
typedef struct __CtkEventSourceRec {
GSource source;
- Display *dpy;
+ NvCtrlEventHandle *event_handle;
GPollFD event_poll_fd;
- int event_base;
- int randr_event_base;
CtkEventNode *ctk_events;
struct __CtkEventSourceRec *next;
@@ -190,11 +188,6 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class)
MAKE_SIGNAL(NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH);
MAKE_SIGNAL(NV_CTRL_GVIO_VIDEO_FORMAT_HEIGHT);
MAKE_SIGNAL(NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE);
- MAKE_SIGNAL(NV_CTRL_GPU_OVERCLOCKING_STATE);
- MAKE_SIGNAL(NV_CTRL_GPU_2D_CLOCK_FREQS);
- MAKE_SIGNAL(NV_CTRL_GPU_3D_CLOCK_FREQS);
- MAKE_SIGNAL(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS);
- MAKE_SIGNAL(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE);
MAKE_SIGNAL(NV_CTRL_FLATPANEL_LINK);
MAKE_SIGNAL(NV_CTRL_USE_HOUSE_SYNC);
MAKE_SIGNAL(NV_CTRL_IMAGE_SETTINGS);
@@ -338,6 +331,8 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class)
MAKE_SIGNAL(NV_CTRL_GPU_NVCLOCK_OFFSET);
MAKE_SIGNAL(NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET);
MAKE_SIGNAL(NV_CTRL_VIDEO_DECODER_UTILIZATION);
+ MAKE_SIGNAL(NV_CTRL_GPU_OVER_VOLTAGE_OFFSET);
+ MAKE_SIGNAL(NV_CTRL_GPU_CURRENT_CORE_VOLTAGE);
#undef MAKE_SIGNAL
/*
@@ -347,7 +342,7 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class)
* knows about.
*/
-#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_VIDEO_DECODER_UTILIZATION
+#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_GPU_CURRENT_CORE_VOLTAGE
#warning "There are attributes that do not emit signals!"
#endif
@@ -455,40 +450,50 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class)
+static CtkEventSource* find_event_source(NvCtrlEventHandle *event_handle)
+{
+ CtkEventSource *event_source = event_sources;
+ while (event_source) {
+ if (event_source->event_handle == event_handle) {
+ break;
+ }
+ event_source = event_source->next;
+ }
+ return event_source;
+}
+
+
+
/* - ctk_event_register_source()
*
* Keep track of event sources globally to support
- * dispatching events on a dpy to multiple CtkEvent
+ * dispatching events on an event handle to multiple CtkEvent
* objects. Since the driver only sends out one event
- * notification per dpy (client), there should only be one
- * event source attached per unique dpy. When an event
+ * notification per event handle (client), there should only be one
+ * event source attached per unique event handle. When an event
* is received, the dispatching function should then
* emit a signal to every CtkEvent object that
- * requests event notification from the dpy for the
+ * requests event notification from the event handle for the
* given target type/id (X screen, GPU etc).
*/
static void ctk_event_register_source(CtkEvent *ctk_event)
{
- Display *dpy = NvCtrlGetDisplayPtr(ctk_event->handle);
+ CtrlTarget *ctrl_target = ctk_event->ctrl_target;
+ NvCtrlEventHandle *event_handle = NvCtrlGetEventHandle(ctrl_target);
CtkEventSource *event_source;
CtkEventNode *event_node;
- if (!dpy) {
+ if (!event_handle) {
return;
}
- /* Do we already have an event source for this dpy? */
- event_source = event_sources;
- while (event_source) {
- if (event_source->dpy == dpy) {
- break;
- }
- event_source = event_source->next;
- }
+ /* Do we already have an event source for this event handle? */
+ event_source = find_event_source(event_handle);
/* create a new input source */
if (!event_source) {
GSource *source;
+ int event_fd;
static GSourceFuncs ctk_source_funcs = {
ctk_event_prepare,
@@ -505,12 +510,10 @@ static void ctk_event_register_source(CtkEvent *ctk_event)
return;
}
- event_source->dpy = dpy;
- event_source->event_poll_fd.fd = ConnectionNumber(dpy);
+ NvCtrlEventHandleGetFD(event_handle, &event_fd);
+ event_source->event_handle = event_handle;
+ event_source->event_poll_fd.fd = event_fd;
event_source->event_poll_fd.events = G_IO_IN;
- event_source->event_base = NvCtrlGetEventBase(ctk_event->handle);
- event_source->randr_event_base =
- NvCtrlGetXrandrEventBase(ctk_event->handle);
/* add the input source to the glib main loop */
@@ -531,29 +534,93 @@ static void ctk_event_register_source(CtkEvent *ctk_event)
return;
}
event_node->ctk_event = ctk_event;
- event_node->target_type = NvCtrlGetTargetType(ctk_event->handle);
- event_node->target_id = NvCtrlGetTargetId(ctk_event->handle);
+ event_node->target_type = NvCtrlGetTargetType(ctrl_target);
+ event_node->target_id = NvCtrlGetTargetId(ctrl_target);
event_node->next = event_source->ctk_events;
event_source->ctk_events = event_node;
- /*
- * This next bit of code is to make sure that the randr_event_base
- * for this event source is valid in the case where a NON X Screen
- * target type handle is used to create the initial event source
- * (Resulting in randr_event_base being == -1), followed by an
- * X Screen target type handle registering itself to receive
- * XRandR events on the existing dpy/event source.
- */
- if (event_source->randr_event_base == -1 &&
- event_node->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) {
- event_source->randr_event_base =
- NvCtrlGetXrandrEventBase(ctk_event->handle);
- }
} /* ctk_event_register_source() */
-GObject *ctk_event_new(NvCtrlAttributeHandle *handle)
+/*
+ * Unregister a previously registered CtkEvent from its corresponding event
+ * source. If the event source becomes empty (no CtkEvents attached to it), this
+ * function also destroys the event source and its corresponding event handle.
+ */
+static void ctk_event_unregister_source(CtkEvent *ctk_event)
+{
+ CtrlTarget *ctrl_target = ctk_event->ctrl_target;
+ NvCtrlEventHandle *event_handle = NvCtrlGetEventHandle(ctrl_target);
+ CtkEventSource *event_source;
+ CtkEventNode *event_node;
+
+ if (!event_handle) {
+ return;
+ }
+
+ /* Do we have an event source for this event handle? */
+ event_source = find_event_source(event_handle);
+
+ if (!event_source) {
+ return;
+ }
+
+
+ /* Remove the ctk_event object from the source's list of event objects */
+
+ event_node = event_source->ctk_events;
+ if (event_node->ctk_event == ctk_event) {
+ event_source->ctk_events = event_node->next;
+ }
+ else {
+ CtkEventNode *prev = event_node;
+ event_node = event_node->next;
+ while (event_node) {
+ if (event_node->ctk_event == ctk_event) {
+ prev->next = event_node->next;
+ break;
+ }
+ prev = event_node;
+ event_node = event_node->next;
+ }
+ }
+
+ if (!event_node) {
+ return;
+ }
+
+ g_free(event_node);
+
+
+ /* destroy the event source if empty */
+
+ if (event_source->ctk_events == NULL) {
+ GSource *source = (GSource *)event_source;
+
+ if (event_sources == event_source) {
+ event_sources = event_source->next;
+ }
+ else {
+ CtkEventSource *cur;
+ for (cur = event_sources; cur; cur = cur->next) {
+ if (cur->next == event_source) {
+ cur->next = event_source->next;
+ break;
+ }
+ }
+ }
+
+ NvCtrlCloseEventHandle(event_source->event_handle);
+ g_source_remove_poll(source, &(event_source->event_poll_fd));
+ g_source_destroy(source);
+ g_source_unref(source);
+ }
+}
+
+
+
+GObject *ctk_event_new(CtrlTarget *ctrl_target)
{
GObject *object;
CtkEvent *ctk_event;
@@ -563,7 +630,7 @@ GObject *ctk_event_new(NvCtrlAttributeHandle *handle)
object = g_object_new(CTK_TYPE_EVENT, NULL);
ctk_event = CTK_EVENT(object);
- ctk_event->handle = handle;
+ ctk_event->ctrl_target = ctrl_target;
/* Register to receive (dpy) events */
@@ -575,22 +642,51 @@ GObject *ctk_event_new(NvCtrlAttributeHandle *handle)
+void ctk_event_destroy(GObject *object)
+{
+ CtkEvent *ctk_event;
+
+ if (object == NULL || !CTK_IS_EVENT(object)) {
+ return;
+ }
+
+ ctk_event = CTK_EVENT(object);
+
+ /* Unregister to stop receiving (dpy) events */
+
+ ctk_event_unregister_source(ctk_event);
+
+ /* Unref the CtkEvent object */
+
+ g_object_unref(object);
+}
+
+
+
static gboolean ctk_event_prepare(GSource *source, gint *timeout)
{
+ ReturnStatus status;
+ Bool pending;
CtkEventSource *event_source = (CtkEventSource *) source;
*timeout = -1;
/*
- * Check if any events are pending on the Display connection
+ * Check if any events are pending on the event handle
*/
+ status = NvCtrlEventHandlePending(event_source->event_handle, &pending);
+ if (status == NvCtrlSuccess) {
+ return pending;
+ }
- return XPending(event_source->dpy);
+ return FALSE;
}
static gboolean ctk_event_check(GSource *source)
{
+ ReturnStatus status;
+ Bool pending;
CtkEventSource *event_source = (CtkEventSource *) source;
/*
@@ -598,244 +694,118 @@ static gboolean ctk_event_check(GSource *source)
* but doing so caused some events to be missed as they came in with only
* the G_IO_OUT flag set which is odd.
*/
- return XPending(event_source->dpy);
-}
-
-
-
-static int get_screen_of_root(Display *dpy, Window root)
-{
- int screen = -1;
-
- /* Find the screen the window belongs to */
- screen = XScreenCount(dpy);
-
- while (screen > 0) {
- screen--;
- if (root == RootWindow(dpy, screen)) {
- break;
- }
+ status = NvCtrlEventHandlePending(event_source->event_handle, &pending);
+ if (status == NvCtrlSuccess) {
+ return pending;
}
-
- return screen;
+
+ return FALSE;
}
-#define CTK_EVENT_BROADCAST(ES, SIG, PTR, TYPE, ID) \
-do { \
- CtkEventNode *e = (ES)->ctk_events; \
- while (e) { \
- if (e->target_type == (TYPE) && \
- e->target_id == (ID)) { \
- g_signal_emit(e->ctk_event, SIG, 0, PTR); \
- } \
- e = e->next; \
- } \
+#define CTK_EVENT_BROADCAST(ES, SIG, CEVT) \
+do { \
+ CtkEventNode *e = (ES)->ctk_events; \
+ while (e) { \
+ if (e->target_type == (CEVT)->target_type && \
+ e->target_id == (CEVT)->target_id) { \
+ g_signal_emit(e->ctk_event, SIG, 0, CEVT); \
+ } \
+ e = e->next; \
+ } \
} while (0)
static gboolean ctk_event_dispatch(GSource *source,
- GSourceFunc callback, gpointer user_data)
+ GSourceFunc callback,
+ gpointer user_data)
{
- XEvent event;
+ ReturnStatus status;
+ CtrlEvent event;
CtkEventSource *event_source = (CtkEventSource *) source;
- CtkEventStruct event_struct;
-
- memset(&event_struct, 0, sizeof(event_struct));
/*
* if ctk_event_dispatch() is called, then either
* ctk_event_prepare() or ctk_event_check() returned TRUE, so we
* know there is an event pending
*/
-
- XNextEvent(event_source->dpy, &event);
-
- /*
- * Handle the ATTRIBUTE_CHANGED_EVENT NV-CONTROL event
- */
-
- if (event_source->event_base != -1 &&
- (event.type == (event_source->event_base + ATTRIBUTE_CHANGED_EVENT))) {
-
- XNVCtrlAttributeChangedEvent *nvctrlevent =
- (XNVCtrlAttributeChangedEvent *) &event;
-
- /* make sure the attribute is in our signal array */
-
- if ((nvctrlevent->attribute <= NV_CTRL_LAST_ATTRIBUTE) &&
- (signals[nvctrlevent->attribute] != 0)) {
-
- event_struct.attribute = nvctrlevent->attribute;
- event_struct.value = nvctrlevent->value;
- event_struct.display_mask = nvctrlevent->display_mask;
+ status = NvCtrlEventHandleNextEvent(event_source->event_handle, &event);
+ if (status != NvCtrlSuccess) {
+ return FALSE;
+ }
- /*
- * XXX Is emitting a signal with g_signal_emit() really
- * the "correct" way of dispatching the event?
- */
+ if (event.type != CTRL_EVENT_TYPE_UNKNOWN) {
- CTK_EVENT_BROADCAST(event_source,
- signals[nvctrlevent->attribute],
- &event_struct,
- NV_CTRL_TARGET_TYPE_X_SCREEN,
- nvctrlevent->screen);
+ /*
+ * Handle the CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE event
+ */
+ if (event.type == CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+
+ /* make sure the attribute is in our signal array */
+ if ((event.int_attr.attribute <= NV_CTRL_LAST_ATTRIBUTE) &&
+ (signals[event.int_attr.attribute] != 0)) {
+
+ /*
+ * XXX Is emitting a signal with g_signal_emit() really
+ * the "correct" way of dispatching the event?
+ */
+ CTK_EVENT_BROADCAST(event_source,
+ signals[event.int_attr.attribute],
+ &event);
+ }
}
+
+ /*
+ * Handle the CTRL_EVENT_TYPE_STRING_ATTRIBUTE event
+ */
+ else if (event.type == CTRL_EVENT_TYPE_STRING_ATTRIBUTE) {
- /*
- * Handle the TARGET_ATTRIBUTE_CHANGED_EVENT NV-CONTROL event
- */
-
- } else if (event_source->event_base != -1 &&
- (event.type == (event_source->event_base
- +TARGET_ATTRIBUTE_CHANGED_EVENT))) {
-
- XNVCtrlAttributeChangedEventTarget *nvctrlevent =
- (XNVCtrlAttributeChangedEventTarget *) &event;
-
- /* make sure the attribute is in our signal array */
-
- if ((nvctrlevent->attribute <= NV_CTRL_LAST_ATTRIBUTE) &&
- (signals[nvctrlevent->attribute] != 0)) {
-
- event_struct.attribute = nvctrlevent->attribute;
- event_struct.value = nvctrlevent->value;
- event_struct.display_mask = nvctrlevent->display_mask;
+ /* make sure the attribute is in our string signal array */
- /*
- * XXX Is emitting a signal with g_signal_emit() really
- * the "correct" way of dispatching the event?
- */
+ if ((event.str_attr.attribute <= NV_CTRL_STRING_LAST_ATTRIBUTE) &&
+ (string_signals[event.str_attr.attribute] != 0)) {
- CTK_EVENT_BROADCAST(event_source,
- signals[nvctrlevent->attribute],
- &event_struct,
- nvctrlevent->target_type,
- nvctrlevent->target_id);
+ /*
+ * XXX Is emitting a signal with g_signal_emit() really
+ * the "correct" way of dispatching the event
+ */
+ CTK_EVENT_BROADCAST(event_source,
+ string_signals[event.str_attr.attribute],
+ &event);
+ }
}
/*
- * Handle the TARGET_ATTRIBUTE_AVAILABILITY_CHANGED_EVENT
- * NV-CONTROL event.
+ * Handle the CTRL_EVENT_TYPE_BINARY_ATTRIBUTE event
*/
-
- } else if (event_source->event_base != -1 &&
- (event.type == (event_source->event_base
- + TARGET_ATTRIBUTE_AVAILABILITY_CHANGED_EVENT))) {
-
- XNVCtrlAttributeChangedEventTargetAvailability *nvctrlevent =
- (XNVCtrlAttributeChangedEventTargetAvailability *) &event;
-
- /* make sure the attribute is in our signal array */
-
- if ((nvctrlevent->attribute <= NV_CTRL_LAST_ATTRIBUTE) &&
- (signals[nvctrlevent->attribute] != 0)) {
-
- event_struct.attribute = nvctrlevent->attribute;
- event_struct.value = nvctrlevent->value;
- event_struct.display_mask = nvctrlevent->display_mask;
- event_struct.is_availability_changed = TRUE;
- event_struct.availability = nvctrlevent->availability;
-
- /*
- * XXX Is emitting a signal with g_signal_emit() really
- * the "correct" way of dispatching the event?
- */
-
- CTK_EVENT_BROADCAST(event_source,
- signals[nvctrlevent->attribute],
- &event_struct,
- nvctrlevent->target_type,
- nvctrlevent->target_id);
+ else if (event.type == CTRL_EVENT_TYPE_BINARY_ATTRIBUTE) {
+
+ /* make sure the attribute is in our binary signal array */
+ if ((event.bin_attr.attribute <= NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE) &&
+ (binary_signals[event.bin_attr.attribute] != 0)) {
+
+ /*
+ * XXX Is emitting a signal with g_signal_emit() really
+ * the "correct" way of dispatching the event
+ */
+ CTK_EVENT_BROADCAST(event_source,
+ binary_signals[event.bin_attr.attribute],
+ &event);
+ }
}
- /*
- * Handle the TARGET_STRING_ATTRIBUTE_CHANGED_EVENT
- * NV-CONTROL event.
- */
- } else if (event_source->event_base != -1 &&
- (event.type == (event_source->event_base
- + TARGET_STRING_ATTRIBUTE_CHANGED_EVENT))) {
- XNVCtrlStringAttributeChangedEventTarget *nvctrlevent =
- (XNVCtrlStringAttributeChangedEventTarget *) &event;
-
- /* make sure the attribute is in our signal array */
-
- if ((nvctrlevent->attribute <= NV_CTRL_STRING_LAST_ATTRIBUTE) &&
- (string_signals[nvctrlevent->attribute] != 0)) {
-
- event_struct.attribute = nvctrlevent->attribute;
- event_struct.value = 0;
- event_struct.display_mask = nvctrlevent->display_mask;
- /*
- * XXX Is emitting a signal with g_signal_emit() really
- * the "correct" way of dispatching the event
- */
-
- CTK_EVENT_BROADCAST(event_source,
- string_signals[nvctrlevent->attribute],
- &event_struct,
- nvctrlevent->target_type,
- nvctrlevent->target_id);
- }
- /*
- * Handle the TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT
- * NV-CONTROL event.
- */
- } else if (event_source->event_base != -1 &&
- (event.type == (event_source->event_base
- + TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT))) {
- XNVCtrlBinaryAttributeChangedEventTarget *nvctrlevent =
- (XNVCtrlBinaryAttributeChangedEventTarget *) &event;
-
- /* make sure the attribute is in our signal array */
- if ((nvctrlevent->attribute <= NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE) &&
- (binary_signals[nvctrlevent->attribute] != 0)) {
-
- event_struct.attribute = nvctrlevent->attribute;
- event_struct.value = 0;
- event_struct.display_mask = nvctrlevent->display_mask;
- /*
- * XXX Is emitting a signal with g_signal_emit() really
- * the "correct" way of dispatching the event
- */
-
- CTK_EVENT_BROADCAST(event_source,
- binary_signals[nvctrlevent->attribute],
- &event_struct,
- nvctrlevent->target_type,
- nvctrlevent->target_id);
- }
-
/*
- * Also handle XRandR events.
+ * Handle the CTRL_EVENT_TYPE_SCREEN_CHANGE event
*/
-
- } else if (event_source->randr_event_base != -1 &&
- (event.type ==
- (event_source->randr_event_base + RRScreenChangeNotify))) {
-
- XRRScreenChangeNotifyEvent *xrandrevent =
- (XRRScreenChangeNotifyEvent *)&event;
- int screen;
-
- /* Find the screen the window belongs to */
- screen = get_screen_of_root(xrandrevent->display, xrandrevent->root);
- if (screen >= 0) {
- CTK_EVENT_BROADCAST(event_source,
- signal_RRScreenChangeNotify,
- &event,
- NV_CTRL_TARGET_TYPE_X_SCREEN,
- screen);
+ else if (event.type == CTRL_EVENT_TYPE_SCREEN_CHANGE) {
+
+ /* make sure the target_id is valid */
+ if (event.target_id >= 0) {
+ CTK_EVENT_BROADCAST(event_source,
+ signal_RRScreenChangeNotify,
+ &event);
+ }
}
-
- /*
- * Trap events that get registered but are not handled
- * properly.
- */
-
- } else {
- nv_warning_msg("Unknown event type %d.", event.type);
}
return TRUE;
@@ -849,11 +819,14 @@ static gboolean ctk_event_dispatch(GSource *source,
* that various parts of nvidia-settings can communicate (internally)
*/
void ctk_event_emit(CtkEvent *ctk_event,
- unsigned int mask, int attrib, int value)
+ unsigned int mask,
+ int attrib,
+ int value)
{
- CtkEventStruct event;
+ CtrlEvent event;
CtkEventSource *source;
- Display *dpy = NvCtrlGetDisplayPtr(ctk_event->handle);
+ CtrlTarget *ctrl_target = ctk_event->ctrl_target;
+ NvCtrlEventHandle *event_handle = NvCtrlGetEventHandle(ctrl_target);
if (attrib > NV_CTRL_LAST_ATTRIBUTE) return;
@@ -862,7 +835,7 @@ void ctk_event_emit(CtkEvent *ctk_event,
/* Find the event source */
source = event_sources;
while (source) {
- if (source->dpy == dpy) {
+ if (source->event_handle == event_handle) {
break;
}
source = source->next;
@@ -871,15 +844,16 @@ void ctk_event_emit(CtkEvent *ctk_event,
/* Broadcast event to all relevant ctk_event objects */
- event.attribute = attrib;
- event.value = value;
- event.display_mask = mask;
+ memset(&event, 0, sizeof(CtrlEvent));
- CTK_EVENT_BROADCAST(source,
- signals[attrib],
- &event,
- NvCtrlGetTargetType(ctk_event->handle),
- NvCtrlGetTargetId(ctk_event->handle));
+ event.type = CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE;
+ event.target_type = NvCtrlGetTargetType(ctrl_target);
+ event.target_id = NvCtrlGetTargetId(ctrl_target);
+
+ event.int_attr.attribute = attrib;
+ event.int_attr.value = value;
+
+ CTK_EVENT_BROADCAST(source, signals[attrib], &event);
} /* ctk_event_emit() */
@@ -890,11 +864,13 @@ void ctk_event_emit(CtkEvent *ctk_event,
* that various parts of nvidia-settings can communicate (internally)
*/
void ctk_event_emit_string(CtkEvent *ctk_event,
- unsigned int mask, int attrib)
+ unsigned int mask,
+ int attrib)
{
- CtkEventStruct event;
+ CtrlEvent event;
CtkEventSource *source;
- Display *dpy = NvCtrlGetDisplayPtr(ctk_event->handle);
+ CtrlTarget *ctrl_target = ctk_event->ctrl_target;
+ NvCtrlEventHandle *event_handle = NvCtrlGetEventHandle(ctrl_target);
if (attrib > NV_CTRL_STRING_LAST_ATTRIBUTE) return;
@@ -903,7 +879,7 @@ void ctk_event_emit_string(CtkEvent *ctk_event,
/* Find the event source */
source = event_sources;
while (source) {
- if (source->dpy == dpy) {
+ if (source->event_handle == event_handle) {
break;
}
source = source->next;
@@ -912,16 +888,15 @@ void ctk_event_emit_string(CtkEvent *ctk_event,
/* Broadcast event to all relevant ctk_event objects */
+ memset(&event, 0, sizeof(CtrlEvent));
+
+ event.type = CTRL_EVENT_TYPE_STRING_ATTRIBUTE;
+ event.target_type = NvCtrlGetTargetType(ctrl_target);
+ event.target_id = NvCtrlGetTargetId(ctrl_target);
- event.attribute = attrib;
- event.value = 0;
- event.display_mask = mask;
+ event.str_attr.attribute = attrib;
- CTK_EVENT_BROADCAST(source,
- string_signals[attrib],
- &event,
- NvCtrlGetTargetType(ctk_event->handle),
- NvCtrlGetTargetId(ctk_event->handle));
+ CTK_EVENT_BROADCAST(source, signals[attrib], &event);
} /* ctk_event_emit_string() */
diff --git a/src/gtk+-2.x/ctkevent.h b/src/gtk+-2.x/ctkevent.h
index 6090fba..f413659 100644
--- a/src/gtk+-2.x/ctkevent.h
+++ b/src/gtk+-2.x/ctkevent.h
@@ -22,7 +22,7 @@
#include <gtk/gtk.h>
-#include "NvCtrlAttributes.h"
+#include "query-assign.h"
G_BEGIN_DECLS
@@ -46,12 +46,11 @@ G_BEGIN_DECLS
typedef struct _CtkEvent CtkEvent;
typedef struct _CtkEventClass CtkEventClass;
-typedef struct _CtkEventStruct CtkEventStruct;
struct _CtkEvent
{
- GObject parent;
- NvCtrlAttributeHandle *handle;
+ GObject parent;
+ CtrlTarget *ctrl_target;
};
struct _CtkEventClass
@@ -59,17 +58,9 @@ struct _CtkEventClass
GtkWidgetClass parent_class;
};
-struct _CtkEventStruct
-{
- gint attribute;
- gint value;
- guint display_mask;
- gboolean is_availability_changed;
- gboolean availability;
-};
-
GType ctk_event_get_type (void) G_GNUC_CONST;
-GObject* ctk_event_new (NvCtrlAttributeHandle*);
+GObject* ctk_event_new (CtrlTarget*);
+void ctk_event_destroy (GObject*);
void ctk_event_emit(CtkEvent *ctk_event,
unsigned int mask, int attrib, int value);
diff --git a/src/gtk+-2.x/ctkframelock.c b/src/gtk+-2.x/ctkframelock.c
index d9a282e..63acf72 100644
--- a/src/gtk+-2.x/ctkframelock.c
+++ b/src/gtk+-2.x/ctkframelock.c
@@ -172,7 +172,7 @@ struct _nvListTreeRec {
struct _nvDisplayDataRec {
- gpointer handle; /* NV-CONTROL Display Target */
+ CtrlTarget *ctrl_target; /* Display Target */
gboolean serverable;
gboolean clientable;
@@ -202,7 +202,7 @@ struct _nvDisplayDataRec {
struct _nvGPUDataRec {
- gpointer handle; /* NV-CONTROL GPU Target */
+ CtrlTarget *ctrl_target; /* GPU Target */
gboolean enabled; /* Sync enabled */
@@ -214,7 +214,7 @@ struct _nvGPUDataRec {
struct _nvFrameLockDataRec {
- gpointer handle; /* NV-CONTROL Frame Lock Target */
+ CtrlTarget *ctrl_target; /* Frame Lock Target */
int server_id;
int sync_delay_resolution;
@@ -336,7 +336,7 @@ static const char * __client_checkbox_help =
-static void add_framelock_devices(CtkFramelock *, gpointer, int);
+static void add_framelock_devices(CtkFramelock *, CtrlSystem *, int);
static void add_gpu_devices(CtkFramelock *, nvListEntryPtr);
static void add_display_devices(CtkFramelock *, nvListEntryPtr);
static void add_devices(CtkFramelock *, const gchar *, gboolean);
@@ -372,10 +372,12 @@ static void update_expand_all_button_status(CtkFramelock *);
static void apply_parsed_attribute_list(CtkFramelock *ctk_framelock,
ParsedAttribute *list);
-static void gpu_state_received(GObject *object,
- gpointer arg1, gpointer user_data);
-static void framelock_state_received(GObject *object,
- gpointer arg1, gpointer user_data);
+static void display_state_received(GObject *object, CtrlEvent *event,
+ gpointer user_data);
+static void gpu_state_received(GObject *object, CtrlEvent *event,
+ gpointer user_data);
+static void framelock_state_received(GObject *object, CtrlEvent *event,
+ gpointer user_data);
/** select_widget() *********************************************
@@ -556,6 +558,7 @@ static GtkWidget *create_sync_state_button(CtkFramelock *ctk_framelock)
*/
static GtkWidget *create_add_devices_dialog(CtkFramelock *ctk_framelock)
{
+ CtrlTarget *ctrl_target = ctk_framelock->ctrl_target;
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *hbox;
@@ -563,7 +566,7 @@ static GtkWidget *create_add_devices_dialog(CtkFramelock *ctk_framelock)
GtkWidget *image;
GdkPixbuf *pixbuf;
GtkWidget *alignment;
-
+
dialog = gtk_dialog_new_with_buttons("Add X Screen",
ctk_framelock->parent_window,
GTK_DIALOG_MODAL |
@@ -607,9 +610,8 @@ static GtkWidget *create_add_devices_dialog(CtkFramelock *ctk_framelock)
(gpointer) ctk_framelock);
gtk_entry_set_text(GTK_ENTRY(ctk_framelock->add_devices_entry),
- NvCtrlGetDisplayName
- (ctk_framelock->attribute_handle));
-
+ NvCtrlGetDisplayName(ctrl_target));
+
gtk_entry_set_width_chars
(GTK_ENTRY(ctk_framelock->add_devices_entry), 16);
@@ -840,8 +842,9 @@ static gchar *get_display_name(nvDisplayDataPtr data, gboolean simple)
char *display_name;
char *display_type = NULL;
char *name;
+ CtrlTarget *ctrl_target = data->ctrl_target;
- ret = NvCtrlGetStringAttribute(data->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_DISPLAY_DEVICE_NAME,
&display_name);
if (ret != NvCtrlSuccess) {
@@ -850,7 +853,7 @@ static gchar *get_display_name(nvDisplayDataPtr data, gboolean simple)
if (!simple) {
ret =
- NvCtrlGetStringAttribute(data->handle,
+ NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_DISPLAY_NAME_RANDR,
&display_type);
if (ret != NvCtrlSuccess) {
@@ -861,15 +864,13 @@ static gchar *get_display_name(nvDisplayDataPtr data, gboolean simple)
if (display_type) {
name = g_strconcat((display_name ? display_name : "Unknown Display"),
" (", display_type, ")", NULL);
- XFree(display_type);
+ free(display_type);
} else {
name = g_strconcat((display_name ? display_name : "Unknown Display"),
NULL);
}
- if (display_name) {
- XFree(display_name);
- }
+ free(display_name);
return name;
}
@@ -890,15 +891,16 @@ static gchar *get_gpu_name(nvGPUDataPtr data, gboolean simple)
char *product_name;
char tmp[32];
char *name;
+ CtrlTarget *ctrl_target = data->ctrl_target;
- ret = NvCtrlGetStringAttribute(data->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_PRODUCT_NAME,
&product_name);
if (ret != NvCtrlSuccess) {
product_name = NULL;
}
- snprintf(tmp, 32, " (GPU %d)", NvCtrlGetTargetId(data->handle));
+ snprintf(tmp, 32, " (GPU %d)", NvCtrlGetTargetId(ctrl_target));
if (simple) {
name = g_strconcat(product_name?product_name:"Unknown GPU",
@@ -908,9 +910,7 @@ static gchar *get_gpu_name(nvGPUDataPtr data, gboolean simple)
tmp, NULL);
}
- if (product_name) {
- free(product_name);
- }
+ free(product_name);
return name;
}
@@ -924,17 +924,18 @@ static gchar *get_gpu_name(nvGPUDataPtr data, gboolean simple)
*/
static char *get_framelock_name(nvFrameLockDataPtr data, gboolean simple)
{
- char *server_name;
- char tmp[32];
- char *name;
+ char *server_name;
+ char tmp[32];
+ char *name;
+ CtrlTarget *ctrl_target = data->ctrl_target;
/* NOTE: The display name of a non-X Screen target will
* return the server name and server # only.
* (i.e., it does not return a screen #)
*/
- server_name = NvCtrlGetDisplayName(data->handle);
+ server_name = NvCtrlGetDisplayName(ctrl_target);
- snprintf(tmp, 32, " (Quadro Sync %d)", NvCtrlGetTargetId(data->handle));
+ snprintf(tmp, 32, " (Quadro Sync %d)", NvCtrlGetTargetId(ctrl_target));
name = g_strconcat(server_name?server_name:"Unknown X Server", tmp, NULL);
@@ -1819,41 +1820,6 @@ static nvListEntryPtr list_entry_new(nvListTreePtr tree)
-static void framelock_data_free(nvFrameLockDataPtr data)
-{
- if (!data) return;
-
- if (data->handle) {
- NvCtrlAttributeClose(data->handle);
- }
-
- free(data);
-}
-
-
-
-static void gpu_data_free(nvGPUDataPtr data)
-{
- if (!data) return;
-
- if (data->handle) {
- NvCtrlAttributeClose(data->handle);
- }
-
- free(data);
-}
-
-
-
-static void display_data_free(nvDisplayDataPtr data)
-{
- if (!data) return;
-
- free(data);
-}
-
-
-
/** list_entry_free() ************************************************
*
* - Frees an existing list entry.
@@ -1872,25 +1838,12 @@ static void list_entry_free(nvListEntryPtr entry)
G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, (gpointer) entry);
- // XXX Free ctk_event object when we add that functionality.
+ ctk_event_destroy(G_OBJECT(entry->ctk_event));
}
/* Free any data associated with the entry */
- if (entry->data) {
- switch (entry->data_type) {
- case ENTRY_DATA_FRAMELOCK:
- framelock_data_free((nvFrameLockDataPtr)entry->data);
- break;
- case ENTRY_DATA_GPU:
- gpu_data_free((nvGPUDataPtr)entry->data);
- break;
- case ENTRY_DATA_DISPLAY:
- display_data_free((nvDisplayDataPtr)entry->data);
- break;
- }
- }
-
+ free(entry->data);
free(entry);
}
@@ -2104,7 +2057,7 @@ static nvListEntryPtr list_entry_new_with_framelock(nvFrameLockDataPtr data,
}
entry->data = (gpointer)(data);
entry->data_type = ENTRY_DATA_FRAMELOCK;
- entry->ctk_event = CTK_EVENT(ctk_event_new(data->handle));
+ entry->ctk_event = CTK_EVENT(ctk_event_new(data->ctrl_target));
/* Pack the data's widgets into the list entry data hbox */
@@ -2207,7 +2160,7 @@ static nvListEntryPtr list_entry_new_with_gpu(nvGPUDataPtr data,
}
entry->data = (gpointer)(data);
entry->data_type = ENTRY_DATA_GPU;
- entry->ctk_event = CTK_EVENT(ctk_event_new(data->handle));
+ entry->ctk_event = CTK_EVENT(ctk_event_new(data->ctrl_target));
/* Pack the data's widgets into the list entry data hbox */
@@ -2255,7 +2208,7 @@ static nvListEntryPtr list_entry_new_with_display(nvDisplayDataPtr data,
}
entry->data = (gpointer)(data);
entry->data_type = ENTRY_DATA_DISPLAY;
- entry->ctk_event = CTK_EVENT(ctk_event_new(data->handle));
+ entry->ctk_event = CTK_EVENT(ctk_event_new(data->ctrl_target));
/* Pack the data's widgets into the list entry data hbox */
@@ -2501,9 +2454,9 @@ static void list_tree_align_titles(nvListTreePtr tree)
/** find_server_by_name() ********************************************
*
- * - Looks in the list tree for a list entry with a handle to a
+ * - Looks in the list tree for a list entry with a target to a
* server with the name 'server_name'. The first list entry found
- * with a handle to the named server is returned.
+ * with a target to the named server is returned.
*
*/
static nvListEntryPtr find_server_by_name(nvListTreePtr tree,
@@ -2518,15 +2471,15 @@ static nvListEntryPtr find_server_by_name(nvListTreePtr tree,
switch (entry->data_type) {
case ENTRY_DATA_FRAMELOCK:
name = NvCtrlGetDisplayName
- (((nvFrameLockDataPtr)(entry->data))->handle);
+ (((nvFrameLockDataPtr)(entry->data))->ctrl_target);
break;
case ENTRY_DATA_GPU:
name = NvCtrlGetDisplayName
- (((nvGPUDataPtr)(entry->data))->handle);
+ (((nvGPUDataPtr)(entry->data))->ctrl_target);
break;
case ENTRY_DATA_DISPLAY:
name = NvCtrlGetDisplayName
- (((nvDisplayDataPtr)(entry->data))->handle);
+ (((nvDisplayDataPtr)(entry->data))->ctrl_target);
break;
default:
name = NULL;
@@ -2579,12 +2532,12 @@ static nvListEntryPtr find_server_by_id(nvListTreePtr tree,
*
* - Gets the X_SERVER_UNIQUE_ID nv-control attribute
*/
-static gboolean get_server_id(NvCtrlAttributeHandle *handle,
+static gboolean get_server_id(CtrlTarget *ctrl_target,
int *server_id)
{
ReturnStatus ret;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_X_SERVER_UNIQUE_ID, server_id);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_X_SERVER_UNIQUE_ID, server_id);
if (ret != NvCtrlSuccess) {
return FALSE;
@@ -2614,19 +2567,21 @@ static void toggle_use_house_sync(GtkWidget *widget, gpointer user_data)
nvListEntryPtr entry;
gboolean enabled;
nvFrameLockDataPtr data;
+ CtrlTarget *ctrl_target;
entry = get_framelock_server_entry((nvListTreePtr)(ctk_framelock->tree));
if (!entry) return;
data = (nvFrameLockDataPtr)(entry->data);
+ ctrl_target = data->ctrl_target;
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- NvCtrlSetAttribute(data->handle, NV_CTRL_USE_HOUSE_SYNC, enabled);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_USE_HOUSE_SYNC, enabled);
update_house_sync_controls(ctk_framelock);
- NvCtrlGetAttribute(data->handle, NV_CTRL_USE_HOUSE_SYNC, &enabled);
+ NvCtrlGetAttribute(ctrl_target, NV_CTRL_USE_HOUSE_SYNC, &enabled);
ctk_config_statusbar_message(ctk_framelock->ctk_config,
"%s use of house sync signal.",
@@ -2814,7 +2769,7 @@ static void toggle_server(GtkWidget *widget, gpointer data)
ctk_framelock = tree->ctk_framelock;
/* Make sure FrameLock is disabled on the GPU */
- NvCtrlSetAttribute(gpu_data->handle, NV_CTRL_FRAMELOCK_SYNC,
+ NvCtrlSetAttribute(gpu_data->ctrl_target, NV_CTRL_FRAMELOCK_SYNC,
NV_CTRL_FRAMELOCK_SYNC_DISABLE);
gpu_data->enabled = FALSE;
ctk_framelock->framelock_enabled = any_gpu_enabled(tree->entries);
@@ -2840,7 +2795,7 @@ static void toggle_server(GtkWidget *widget, gpointer data)
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON(display_data->client_checkbox), FALSE);
- NvCtrlSetAttribute(display_data->handle,
+ NvCtrlSetAttribute(display_data->ctrl_target,
NV_CTRL_FRAMELOCK_DISPLAY_CONFIG,
NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_SERVER);
} else {
@@ -2848,7 +2803,7 @@ static void toggle_server(GtkWidget *widget, gpointer data)
tree->server_entry = NULL;
}
- NvCtrlSetAttribute(display_data->handle,
+ NvCtrlSetAttribute(display_data->ctrl_target,
NV_CTRL_FRAMELOCK_DISPLAY_CONFIG,
NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_DISABLED);
}
@@ -2888,7 +2843,7 @@ static void toggle_client(GtkWidget *widget, gpointer data)
ctk_framelock = tree->ctk_framelock;
/* Make sure FrameLock is disabled on the GPU */
- NvCtrlSetAttribute(gpu_data->handle, NV_CTRL_FRAMELOCK_SYNC,
+ NvCtrlSetAttribute(gpu_data->ctrl_target, NV_CTRL_FRAMELOCK_SYNC,
NV_CTRL_FRAMELOCK_SYNC_DISABLE);
gpu_data->enabled = FALSE;
ctk_framelock->framelock_enabled = any_gpu_enabled(tree->entries);
@@ -2905,11 +2860,11 @@ static void toggle_client(GtkWidget *widget, gpointer data)
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON(display_data->server_checkbox), FALSE);
- NvCtrlSetAttribute(display_data->handle,
+ NvCtrlSetAttribute(display_data->ctrl_target,
NV_CTRL_FRAMELOCK_DISPLAY_CONFIG,
NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_CLIENT);
} else {
- NvCtrlSetAttribute(display_data->handle,
+ NvCtrlSetAttribute(display_data->ctrl_target,
NV_CTRL_FRAMELOCK_DISPLAY_CONFIG,
NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_DISABLED);
}
@@ -2936,16 +2891,18 @@ static gboolean set_enable_sync_server(nvListTreePtr tree, gboolean enable)
{
nvListEntryPtr entry = get_gpu_server_entry(tree);
nvGPUDataPtr data;
+ CtrlTarget *ctrl_target;
ReturnStatus ret;
if (!entry) return FALSE;
data = (nvGPUDataPtr)(entry->data);
+ ctrl_target = data->ctrl_target;
- ret = NvCtrlSetAttribute(data->handle, NV_CTRL_FRAMELOCK_SYNC, enable);
+ ret = NvCtrlSetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_SYNC, enable);
if (ret != NvCtrlSuccess) return FALSE;
- ret = NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_SYNC, &enable);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_SYNC, &enable);
if (ret != NvCtrlSuccess) return FALSE;
data->enabled = enable;
@@ -2985,6 +2942,7 @@ static gboolean set_enable_sync_clients(nvListEntryPtr entry_list,
for (entry = entry_list; entry; entry = entry->next_sibling) {
nvGPUDataPtr data;
+ CtrlTarget *ctrl_target;
if (entry->children) {
something_enabled = set_enable_sync_clients(entry->children,
@@ -2997,15 +2955,16 @@ static gboolean set_enable_sync_clients(nvListEntryPtr entry_list,
}
data = (nvGPUDataPtr)(entry->data);
+ ctrl_target = data->ctrl_target;
/* Only send protocol if there is something to enable */
if (!has_client_selected(entry)) continue;
- ret = NvCtrlSetAttribute(data->handle, NV_CTRL_FRAMELOCK_SYNC, enable);
+ ret = NvCtrlSetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_SYNC, enable);
if (ret != NvCtrlSuccess) continue;
/* Verify state w/ the server */
- ret = NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_SYNC,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_SYNC,
&(something_enabled));
if (ret != NvCtrlSuccess) continue;
@@ -3148,10 +3107,11 @@ static void toggle_sync_enable(GtkWidget *button, gpointer data)
entry = get_gpu_server_entry(tree);
if (enabled && entry && framelock_enabled) {
nvGPUDataPtr data = (nvGPUDataPtr)(entry->data);
- NvCtrlSetAttribute(data->handle,
+ CtrlTarget *ctrl_target = data->ctrl_target;
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_FRAMELOCK_TEST_SIGNAL,
NV_CTRL_FRAMELOCK_TEST_SIGNAL_ENABLE);
- NvCtrlSetAttribute(data->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_FRAMELOCK_TEST_SIGNAL,
NV_CTRL_FRAMELOCK_TEST_SIGNAL_DISABLE);
}
@@ -3214,7 +3174,7 @@ static gint test_link_done(gpointer data)
ctk_framelock->test_link_enabled = FALSE;
- NvCtrlSetAttribute(((nvGPUDataPtr)(entry->data))->handle,
+ NvCtrlSetAttribute(((nvGPUDataPtr)(entry->data))->ctrl_target,
NV_CTRL_FRAMELOCK_TEST_SIGNAL,
NV_CTRL_FRAMELOCK_TEST_SIGNAL_DISABLE);
@@ -3292,7 +3252,7 @@ static void toggle_test_link(GtkWidget *button, gpointer data)
gtk_grab_add(button);
- NvCtrlSetAttribute(((nvGPUDataPtr)(entry->data))->handle,
+ NvCtrlSetAttribute(((nvGPUDataPtr)(entry->data))->ctrl_target,
NV_CTRL_FRAMELOCK_TEST_SIGNAL,
NV_CTRL_FRAMELOCK_TEST_SIGNAL_ENABLE);
@@ -3344,7 +3304,7 @@ static void sync_interval_changed(GtkRange *range, gpointer user_data)
data = (nvFrameLockDataPtr)(entry->data);
- NvCtrlSetAttribute(data->handle, NV_CTRL_FRAMELOCK_SYNC_INTERVAL,
+ NvCtrlSetAttribute(data->ctrl_target, NV_CTRL_FRAMELOCK_SYNC_INTERVAL,
interval);
}
@@ -3386,7 +3346,7 @@ static void changed_sync_edge(GtkComboBox *combo_box, gpointer user_data)
data = (nvFrameLockDataPtr) entry->data;
- NvCtrlSetAttribute(data->handle, NV_CTRL_FRAMELOCK_POLARITY, edge);
+ NvCtrlSetAttribute(data->ctrl_target, NV_CTRL_FRAMELOCK_POLARITY, edge);
}
@@ -3411,7 +3371,7 @@ static void changed_video_mode(GtkComboBox *combo_box, gpointer user_data)
data = (nvFrameLockDataPtr) entry->data;
- NvCtrlSetAttribute(data->handle, NV_CTRL_FRAMELOCK_VIDEO_MODE, mode);
+ NvCtrlSetAttribute(data->ctrl_target, NV_CTRL_FRAMELOCK_VIDEO_MODE, mode);
}
@@ -3441,7 +3401,7 @@ static gboolean detect_video_mode_timer(gpointer user_data)
data = (nvFrameLockDataPtr)(entry->data);
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_HOUSE_STATUS, &house);
+ NvCtrlGetAttribute(data->ctrl_target, NV_CTRL_FRAMELOCK_HOUSE_STATUS, &house);
if (house) {
@@ -3493,7 +3453,7 @@ static gboolean detect_video_mode_timer(gpointer user_data)
* Set the new video format
*/
- NvCtrlSetAttribute(data->handle, NV_CTRL_FRAMELOCK_VIDEO_MODE,
+ NvCtrlSetAttribute(data->ctrl_target, NV_CTRL_FRAMELOCK_VIDEO_MODE,
ctk_framelock->current_detect_format);
return TRUE;
@@ -3562,7 +3522,7 @@ static void toggle_detect_video_mode(GtkToggleButton *button,
ctk_framelock->current_detect_format =
NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_AUTO;
- NvCtrlSetAttribute(data->handle, NV_CTRL_FRAMELOCK_VIDEO_MODE,
+ NvCtrlSetAttribute(data->ctrl_target, NV_CTRL_FRAMELOCK_VIDEO_MODE,
ctk_framelock->current_detect_format);
ctk_framelock->video_mode_detect_timer =
@@ -3584,6 +3544,7 @@ static void list_entry_update_framelock_status(CtkFramelock *ctk_framelock,
nvListEntryPtr entry)
{
nvFrameLockDataPtr data = (nvFrameLockDataPtr)(entry->data);
+ CtrlTarget *ctrl_target = data->ctrl_target;
gint rate, delay, house, port0, port1;
gchar str[32];
gfloat fvalue;
@@ -3595,10 +3556,10 @@ static void list_entry_update_framelock_status(CtkFramelock *ctk_framelock,
ReturnStatus ret;
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_SYNC_DELAY, &delay);
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_HOUSE_STATUS, &house);
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_PORT0_STATUS, &port0);
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_PORT1_STATUS, &port1);
+ NvCtrlGetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_SYNC_DELAY, &delay);
+ NvCtrlGetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_HOUSE_STATUS, &house);
+ NvCtrlGetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_PORT0_STATUS, &port0);
+ NvCtrlGetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_PORT1_STATUS, &port1);
use_house_sync = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON(ctk_framelock->use_house_sync));
@@ -3613,7 +3574,7 @@ static void list_entry_update_framelock_status(CtkFramelock *ctk_framelock,
update_image(data->receiving_hbox, ctk_framelock->led_grey_pixbuf);
} else {
gint receiving;
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_SYNC_READY,
+ NvCtrlGetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_SYNC_READY,
&receiving);
gtk_widget_set_sensitive(data->receiving_label, TRUE);
update_image(data->receiving_hbox,
@@ -3626,11 +3587,11 @@ static void list_entry_update_framelock_status(CtkFramelock *ctk_framelock,
gtk_widget_set_sensitive(data->rate_text, framelock_enabled);
ret =
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_SYNC_RATE_4, &rate);
+ NvCtrlGetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_SYNC_RATE_4, &rate);
if (ret == NvCtrlSuccess) {
snprintf(str, 32, "%d.%.4d Hz", (rate / 10000), (rate % 10000));
} else {
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_SYNC_RATE, &rate);
+ NvCtrlGetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_SYNC_RATE, &rate);
snprintf(str, 32, "%d.%.3d Hz", (rate / 1000), (rate % 1000));
}
gtk_label_set_text(GTK_LABEL(data->rate_text), str);
@@ -3647,10 +3608,9 @@ static void list_entry_update_framelock_status(CtkFramelock *ctk_framelock,
gtk_widget_set_sensitive(data->house_sync_rate_label, framelock_enabled);
gtk_widget_set_sensitive(data->house_sync_rate_text, framelock_enabled);
- ret =
- NvCtrlGetAttribute(data->handle,
- NV_CTRL_FRAMELOCK_INCOMING_HOUSE_SYNC_RATE,
- &rate);
+ ret = NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_FRAMELOCK_INCOMING_HOUSE_SYNC_RATE,
+ &rate);
if (ret == NvCtrlSuccess) {
snprintf(str, 32, "%d.%.4d Hz", (rate / 10000), (rate % 10000));
} else {
@@ -3707,7 +3667,7 @@ static void list_entry_update_gpu_status(CtkFramelock *ctk_framelock,
nvFrameLockDataPtr framelock_data =
(nvFrameLockDataPtr)(entry->parent->data);
- NvCtrlGetAttribute(framelock_data->handle,
+ NvCtrlGetAttribute(framelock_data->ctrl_target,
NV_CTRL_FRAMELOCK_HOUSE_STATUS,
&house);
}
@@ -3736,7 +3696,7 @@ static void list_entry_update_gpu_status(CtkFramelock *ctk_framelock,
update_image(data->timing_hbox, ctk_framelock->led_grey_pixbuf);
} else {
gint timing;
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_TIMING, &timing);
+ NvCtrlGetAttribute(data->ctrl_target, NV_CTRL_FRAMELOCK_TIMING, &timing);
gtk_widget_set_sensitive(data->timing_label, TRUE);
update_image(data->timing_hbox,
(timing ? ctk_framelock->led_green_pixbuf :
@@ -3755,6 +3715,7 @@ static void list_entry_update_gpu_status(CtkFramelock *ctk_framelock,
static void list_entry_update_display_status(CtkFramelock *ctk_framelock,
nvListEntryPtr entry)
{
+ CtrlTarget *ctrl_target = ctk_framelock->ctrl_target;
nvDisplayDataPtr data = (nvDisplayDataPtr)(entry->data);
gboolean framelock_enabled;
gboolean stereo_enabled = FALSE;
@@ -3780,8 +3741,7 @@ static void list_entry_update_display_status(CtkFramelock *ctk_framelock,
gpu_is_server = (gpu_server_entry && (gpu_server_entry == entry->parent));
- ret = NvCtrlGetAttribute(ctk_framelock->attribute_handle, NV_CTRL_STEREO,
- &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_STEREO, &val);
if ((ret == NvCtrlSuccess) &&
(val != NV_CTRL_STEREO_OFF)) {
stereo_enabled = TRUE;
@@ -3805,12 +3765,13 @@ static void list_entry_update_display_status(CtkFramelock *ctk_framelock,
if (entry->parent) {
GdkPixbuf *pixbuf = ctk_framelock->led_grey_pixbuf;
nvGPUDataPtr gpu_data = (nvGPUDataPtr)(entry->parent->data);
+ CtrlTarget *ctrl_target = gpu_data->ctrl_target;
- ret = NvCtrlGetAttribute(gpu_data->handle, NV_CTRL_FRAMELOCK_TIMING,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_FRAMELOCK_TIMING,
&val);
if ((ret == NvCtrlSuccess) &&
(val == NV_CTRL_FRAMELOCK_TIMING_TRUE)) {
- ret = NvCtrlGetAttribute(gpu_data->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FRAMELOCK_STEREO_SYNC, &val);
if (ret == NvCtrlSuccess) {
pixbuf = (val == NV_CTRL_FRAMELOCK_STEREO_SYNC_TRUE) ?
@@ -3899,7 +3860,7 @@ static gboolean check_for_ethernet(gpointer user_data)
nvFrameLockDataPtr data = (nvFrameLockDataPtr)(entry->data);
gint val;
- NvCtrlGetAttribute(data->handle,
+ NvCtrlGetAttribute(data->ctrl_target,
NV_CTRL_FRAMELOCK_ETHERNET_DETECTED,
&val);
@@ -3929,8 +3890,7 @@ static gboolean check_for_ethernet(gpointer user_data)
"PC is not turned on. Either disconnect the LAN "
"cable or turn on the linked PC for proper "
"operation.",
- NvCtrlGetDisplayName(error_data->handle)
- );
+ NvCtrlGetDisplayName(error_data->ctrl_target));
}
first_error = FALSE;
} else {
@@ -3955,7 +3915,7 @@ static void update_house_sync_controls(CtkFramelock *ctk_framelock)
gboolean use_house;
ReturnStatus ret;
nvFrameLockDataPtr data;
-
+ CtrlTarget *ctrl_target;
entry = get_framelock_server_entry((nvListTreePtr)(ctk_framelock->tree));
@@ -3968,9 +3928,10 @@ static void update_house_sync_controls(CtkFramelock *ctk_framelock)
/* Get the current use house sync state from the X Server */
- data = (nvFrameLockDataPtr)(entry->data);
+ data = (nvFrameLockDataPtr)(entry->data);
+ ctrl_target = data->ctrl_target;
- ret = NvCtrlGetAttribute(data->handle, NV_CTRL_USE_HOUSE_SYNC, &use_house);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_USE_HOUSE_SYNC, &use_house);
if (ret != NvCtrlSuccess) {
use_house = TRUE; /* Can't toggle, attribute always on. */
}
@@ -4002,21 +3963,24 @@ static void update_house_sync_controls(CtkFramelock *ctk_framelock)
gint sync_edge;
gint house_format;
- nvFrameLockDataPtr data;
+ nvFrameLockDataPtr master_data;
gtk_widget_set_sensitive(ctk_framelock->house_sync_vbox, TRUE);
- data = (nvFrameLockDataPtr)(entry->data);
+ master_data = (nvFrameLockDataPtr)(entry->data);
/* Query current house sync settings from master frame lock device */
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_SYNC_INTERVAL,
+ NvCtrlGetAttribute(master_data->ctrl_target,
+ NV_CTRL_FRAMELOCK_SYNC_INTERVAL,
&sync_interval);
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_POLARITY,
+ NvCtrlGetAttribute(master_data->ctrl_target,
+ NV_CTRL_FRAMELOCK_POLARITY,
&sync_edge);
- NvCtrlGetAttribute(data->handle, NV_CTRL_FRAMELOCK_VIDEO_MODE,
+ NvCtrlGetAttribute(master_data->ctrl_target,
+ NV_CTRL_FRAMELOCK_VIDEO_MODE,
&house_format);
/* Update GUI to reflect server settings */
@@ -4150,7 +4114,7 @@ static void update_display_config(nvListEntryPtr display_entry, int config)
/* Get what is possible */
- ret = NvCtrlGetValidAttributeValues(display_data->handle,
+ ret = NvCtrlGetValidAttributeValues(display_data->ctrl_target,
NV_CTRL_FRAMELOCK_DISPLAY_CONFIG,
&valid_config);
@@ -4265,9 +4229,9 @@ static void update_display_config(nvListEntryPtr display_entry, int config)
*
*/
static void display_state_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
- CtkEventStruct *event = (CtkEventStruct *) arg1;
nvListEntryPtr display_entry = (nvListEntryPtr) user_data;
nvDisplayDataPtr display_data;
nvListTreePtr tree;
@@ -4275,6 +4239,7 @@ static void display_state_received(GObject *object,
int rateMultiplier = 1;
int precision = 3;
+ gint value;
if (!display_entry ||
!display_entry->data ||
@@ -4282,11 +4247,16 @@ static void display_state_received(GObject *object,
return;
}
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ value = event->int_attr.value;
display_data = (nvDisplayDataPtr) display_entry->data;
tree = display_entry->tree;
ctk_framelock = tree->ctk_framelock;
- switch (event->attribute) {
+ switch (event->int_attr.attribute) {
case NV_CTRL_REFRESH_RATE:
rateMultiplier = 10;
@@ -4294,7 +4264,7 @@ static void display_state_received(GObject *object,
/* fallthrough */
case NV_CTRL_REFRESH_RATE_3:
update_display_rate_txt(display_data,
- event->value * rateMultiplier, /* rate_mHz */
+ value * rateMultiplier, /* rate_mHz */
precision);
/* Update the UI */
@@ -4302,7 +4272,7 @@ static void display_state_received(GObject *object,
break;
case NV_CTRL_FRAMELOCK_DISPLAY_CONFIG:
- update_display_config(display_entry, event->value);
+ update_display_config(display_entry, value);
/* Update the UI */
update_framelock_controls(ctk_framelock);
@@ -4318,9 +4288,9 @@ static void display_state_received(GObject *object,
*
*/
static void gpu_state_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
- CtkEventStruct *event = (CtkEventStruct *) arg1;
nvListEntryPtr gpu_entry = (nvListEntryPtr) user_data;
nvGPUDataPtr gpu_data;
nvListTreePtr tree;
@@ -4332,15 +4302,19 @@ static void gpu_state_received(GObject *object,
return;
}
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
gpu_data = (nvGPUDataPtr) gpu_entry->data;
tree = gpu_entry->tree;
ctk_framelock = tree->ctk_framelock;
- switch (event->attribute) {
+ switch (event->int_attr.attribute) {
case NV_CTRL_FRAMELOCK_SYNC:
/* Cache the enable/disable state of the gpu sync */
- gpu_data->enabled = event->value;
+ gpu_data->enabled = event->int_attr.value;
/* Look to see if any gpu is enabled/disabled */
ctk_framelock->framelock_enabled =
@@ -4364,7 +4338,7 @@ static void gpu_state_received(GObject *object,
break;
case NV_CTRL_FRAMELOCK_TEST_SIGNAL:
- switch (event->value) {
+ switch (event->int_attr.value) {
case NV_CTRL_FRAMELOCK_TEST_SIGNAL_ENABLE:
ctk_framelock->test_link_enabled = TRUE;
gdk_window_set_cursor
@@ -4419,9 +4393,9 @@ static void gpu_state_received(GObject *object,
*
*/
static void framelock_state_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
- CtkEventStruct *event = (CtkEventStruct *) arg1;
nvListEntryPtr entry = (nvListEntryPtr) user_data;
CtkFramelock *ctk_framelock = entry->tree->ctk_framelock;
@@ -4436,9 +4410,13 @@ static void framelock_state_received(GObject *object,
return;
}
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
/* Process the new frame lock device setting */
- switch (event->attribute) {
+ switch (event->int_attr.attribute) {
case NV_CTRL_USE_HOUSE_SYNC:
g_signal_handlers_block_by_func
(G_OBJECT(ctk_framelock->use_house_sync),
@@ -4447,7 +4425,7 @@ static void framelock_state_received(GObject *object,
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON(ctk_framelock->use_house_sync),
- event->value);
+ event->int_attr.value);
g_signal_handlers_unblock_by_func
(G_OBJECT(ctk_framelock->use_house_sync),
@@ -4462,7 +4440,7 @@ static void framelock_state_received(GObject *object,
(gpointer) ctk_framelock);
gtk_range_set_value(GTK_RANGE(ctk_framelock->sync_interval_scale),
- event->value);
+ event->int_attr.value);
g_signal_handlers_unblock_by_func
(G_OBJECT(ctk_framelock->sync_interval_scale),
@@ -4471,7 +4449,7 @@ static void framelock_state_received(GObject *object,
break;
case NV_CTRL_FRAMELOCK_POLARITY:
- sync_edge = event->value;
+ sync_edge = event->int_attr.value;
if (sync_edge < NV_CTRL_FRAMELOCK_POLARITY_RISING_EDGE)
sync_edge = NV_CTRL_FRAMELOCK_POLARITY_RISING_EDGE;
if (sync_edge > NV_CTRL_FRAMELOCK_POLARITY_BOTH_EDGES)
@@ -4494,7 +4472,7 @@ static void framelock_state_received(GObject *object,
break;
case NV_CTRL_FRAMELOCK_VIDEO_MODE:
- house_format = event->value;
+ house_format = event->int_attr.value;
if (house_format < NV_CTRL_FRAMELOCK_VIDEO_MODE_NONE)
house_format = NV_CTRL_FRAMELOCK_VIDEO_MODE_NONE;
if (house_format > NV_CTRL_FRAMELOCK_VIDEO_MODE_HDTV)
@@ -4596,8 +4574,9 @@ GType ctk_framelock_get_type(
* returns a new instance of the frame lock class.
*
*/
-GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle,
- GtkWidget *parent_window, CtkConfig *ctk_config,
+GtkWidget* ctk_framelock_new(CtrlTarget *ctrl_target,
+ GtkWidget *parent_window,
+ CtkConfig *ctk_config,
ParsedAttribute *p)
{
GObject *object;
@@ -4624,16 +4603,16 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle,
GtkWidget *image;
NVCTRLAttributeValidValuesRec valid;
-
- /* make sure we have a handle */
+ /* make sure we have a valid target */
- g_return_val_if_fail(handle != NULL, NULL);
+ g_return_val_if_fail((ctrl_target != NULL) &&
+ (ctrl_target->h != NULL), NULL);
/* Only expose frame lock if there are frame lock boards in
* the system. This isn't absolutely necessary, because the
* frame lock control page does not have to include the current
- * NV-CONTROL handle in the frame lock group. However, we don't
+ * control target in the frame lock group. However, we don't
* want to expose the frame lock page unconditionally (it would
* only confuse most users), so this is as good a condition as
* anything else.
@@ -4642,8 +4621,8 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle,
* Options page.
*/
- ret = NvCtrlQueryTargetCount(handle,
- NV_CTRL_TARGET_TYPE_FRAMELOCK,
+ ret = NvCtrlQueryTargetCount(ctrl_target,
+ FRAMELOCK_TARGET,
(int *)&num_framelocks);
if (ret != NvCtrlSuccess) return NULL;
if (!num_framelocks) return NULL;
@@ -4651,11 +4630,11 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle,
/* 1. - Create the frame lock widgets */
/* create the frame lock page object */
-
+
object = g_object_new(CTK_TYPE_FRAMELOCK, NULL);
-
+
ctk_framelock = CTK_FRAMELOCK(object);
- ctk_framelock->attribute_handle = handle;
+ ctk_framelock->ctrl_target = ctrl_target;
ctk_framelock->ctk_config = ctk_config;
ctk_framelock->parent_window = GTK_WINDOW(parent_window);
ctk_framelock->video_mode_read_only = TRUE;
@@ -4760,7 +4739,7 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle,
/* Select video mode widget dropdown/label depending on
* video mode is read-only.
*/
- ret = NvCtrlGetValidAttributeValues(ctk_framelock->attribute_handle,
+ ret = NvCtrlGetValidAttributeValues(ctrl_target,
NV_CTRL_FRAMELOCK_VIDEO_MODE,
&valid);
if ((ret == NvCtrlSuccess) && (valid.permissions & ATTRIBUTE_TYPE_WRITE)) {
@@ -4928,7 +4907,7 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle,
{
GtkWidget *frame2 = gtk_frame_new(NULL);
- ret = NvCtrlGetValidAttributeValues(ctk_framelock->attribute_handle,
+ ret = NvCtrlGetValidAttributeValues(ctrl_target,
NV_CTRL_FRAMELOCK_SYNC_INTERVAL,
&valid);
/*
@@ -4943,7 +4922,7 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle,
}
if (NvCtrlSuccess !=
- NvCtrlGetAttribute(ctk_framelock->attribute_handle,
+ NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FRAMELOCK_SYNC_INTERVAL,
&val)) {
return NULL;
@@ -5038,7 +5017,7 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle,
/* register a timer callback to update the status of the page */
string = g_strdup_printf("Frame Lock Connection Status (Screen %u)",
- NvCtrlGetTargetId(handle));
+ NvCtrlGetTargetId(ctrl_target));
ctk_config_add_timer(ctk_config, DEFAULT_UPDATE_STATUS_TIME_INTERVAL,
string,
@@ -5046,11 +5025,11 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle,
(gpointer) ctk_framelock);
g_free(string);
-
+
/* register a timer callback to check the rj45 ports */
string = g_strdup_printf("Frame Lock RJ45 Check (Screen %u)",
- NvCtrlGetTargetId(handle));
+ NvCtrlGetTargetId(ctrl_target));
ctk_config_add_timer(ctk_config, DEFAULT_CHECK_FOR_ETHERNET_TIME_INTERVAL,
string,
@@ -5193,14 +5172,13 @@ static void remove_devices_response(GtkWidget *button, gint response,
/** add_display_device() *********************************************
*
- * Adds an display device to the give GPU entry.
+ * Adds a display device to the give GPU entry.
*
*/
-static gboolean add_display_device(CtkFramelock *ctk_framelock,
- nvListEntryPtr gpu_entry,
- int display_id)
+static void add_display_device(CtkFramelock *ctk_framelock,
+ nvListEntryPtr gpu_entry,
+ CtrlTarget *ctrl_target)
{
- nvGPUDataPtr gpu_data = (nvGPUDataPtr)(gpu_entry->data);
nvDisplayDataPtr display_data = NULL;
nvListEntryPtr entry = NULL;
nvListTreePtr tree = (nvListTreePtr)(ctk_framelock->tree);
@@ -5212,21 +5190,17 @@ static gboolean add_display_device(CtkFramelock *ctk_framelock,
gboolean hdmi3D;
int i;
-
- display_data = (nvDisplayDataPtr) calloc(1, sizeof(nvDisplayDataRec));
- if (!display_data) {
+ /* Only add enabled display devices */
+ if (!ctrl_target->display.enabled) {
goto fail;
}
- display_data->handle =
- NvCtrlAttributeInit(NvCtrlGetDisplayPtr(gpu_data->handle),
- NV_CTRL_TARGET_TYPE_DISPLAY,
- display_id,
- NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM);
- if (!display_data->handle) {
+ display_data = (nvDisplayDataPtr) calloc(1, sizeof(nvDisplayDataRec));
+ if (!display_data) {
goto fail;
}
+ display_data->ctrl_target = ctrl_target;
/* Create, pack and link the display device UI widgets */
@@ -5264,11 +5238,9 @@ static gboolean add_display_device(CtkFramelock *ctk_framelock,
update_entry_label(ctk_framelock, entry);
/* Refresh rate */
- ret = NvCtrlGetAttribute(display_data->handle, NV_CTRL_REFRESH_RATE_3,
- &rate);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_REFRESH_RATE_3, &rate);
if (ret != NvCtrlSuccess) {
- ret = NvCtrlGetAttribute(display_data->handle, NV_CTRL_REFRESH_RATE,
- &rate);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_REFRESH_RATE, &rate);
if (ret != NvCtrlSuccess) {
rate = 0;
precision = 0;
@@ -5282,13 +5254,13 @@ static gboolean add_display_device(CtkFramelock *ctk_framelock,
update_display_rate_txt(display_data, rate, precision);
/* HDMI 3D */
- ret = NvCtrlGetDisplayAttribute(display_data->handle,
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
display_data->device_mask,
NV_CTRL_DPY_HDMI_3D, &hdmi3D);
display_data->hdmi3D = hdmi3D;
/* Configuration */
- ret = NvCtrlGetAttribute(display_data->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FRAMELOCK_DISPLAY_CONFIG,
&val);
if (ret != NvCtrlSuccess) {
@@ -5325,15 +5297,14 @@ static gboolean add_display_device(CtkFramelock *ctk_framelock,
"toggled",
G_CALLBACK(toggle_client),
(gpointer) entry);
- return TRUE;
+ return;
fail:
if (entry) {
list_entry_free(entry);
- } else if (display_data) {
- display_data_free(display_data);
+ } else {
+ free(display_data);
}
- return FALSE;
}
@@ -5348,40 +5319,22 @@ static void add_display_devices(CtkFramelock *ctk_framelock,
nvListEntryPtr gpu_entry)
{
nvGPUDataPtr gpu_data;
- ReturnStatus ret;
- int *pData;
+ CtrlTargetNode *node;
if (!gpu_entry || gpu_entry->data_type != ENTRY_DATA_GPU) {
return;
}
gpu_data = (nvGPUDataPtr)(gpu_entry->data);
- ret =
- NvCtrlGetBinaryAttribute(gpu_data->handle, 0,
- NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU,
- (unsigned char **)(&pData),
- NULL);
- if (ret == NvCtrlSuccess) {
- int i;
-
- for (i = 0; i < pData[0]; i++) {
- int display_id = pData[1+i];
- Bool valid;
- int enabled;
-
- /* Only add enabled display devices */
- valid =
- XNVCTRLQueryTargetAttribute(NvCtrlGetDisplayPtr(gpu_data->handle),
- NV_CTRL_TARGET_TYPE_DISPLAY,
- display_id,
- 0,
- NV_CTRL_DISPLAY_ENABLED,
- &enabled);
- if (valid && enabled) {
- add_display_device(ctk_framelock, gpu_entry, display_id);
- }
+ for (node = gpu_data->ctrl_target->relations; node; node = node->next) {
+ CtrlTarget *ctrl_target = node->t;
+
+ if (NvCtrlGetTargetType(ctrl_target) != DISPLAY_TARGET ||
+ !(ctrl_target->display.connected)) {
+ continue;
}
- XFree(pData);
+
+ add_display_device(ctk_framelock, gpu_entry, ctrl_target);
}
}
@@ -5397,39 +5350,28 @@ static void add_display_devices(CtkFramelock *ctk_framelock,
static void add_gpu_devices(CtkFramelock *ctk_framelock,
nvListEntryPtr framelock_entry)
{
- unsigned int num_gpus;
- unsigned int gpu_id;
- unsigned int gpu_idx;
- nvGPUDataPtr gpu_data = NULL;
- nvFrameLockDataPtr framelock_data;
- nvListEntryPtr entry;
- ReturnStatus ret;
-
- unsigned char *data = NULL;
- int len = 0;
- int *gpus;
-
+ nvGPUDataPtr gpu_data = NULL;
+ nvFrameLockDataPtr framelock_data;
+ nvListEntryPtr entry;
+ CtrlTargetNode *node;
if (!framelock_entry ||
framelock_entry->data_type != ENTRY_DATA_FRAMELOCK) {
goto fail;
}
- /* Get number of GPU devices connected to this frame lock board */
framelock_data = (nvFrameLockDataPtr)(framelock_entry->data);
- ret = NvCtrlGetBinaryAttribute(framelock_data->handle,
- 0,
- NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK,
- &data,
- &len);
- if (ret != NvCtrlSuccess) {
- goto fail;
- }
- gpus = (int *)data;
- num_gpus = gpus[0];
- for (gpu_idx = 0; gpu_idx < num_gpus; gpu_idx++) {
- gpu_id = gpus[gpu_idx +1];
+ for (node = framelock_data->ctrl_target->relations;
+ node;
+ node = node->next) {
+
+ CtrlTarget *ctrl_target = node->t;
+
+ if (NvCtrlGetTargetType(ctrl_target) != GPU_TARGET) {
+ continue;
+ }
+
/* Create the GPU data structure */
gpu_data = (nvGPUDataPtr) calloc(1, sizeof(nvGPUDataRec));
@@ -5438,11 +5380,7 @@ static void add_gpu_devices(CtkFramelock *ctk_framelock,
}
/* Create the GPU handle and label */
- gpu_data->handle =
- NvCtrlAttributeInit(NvCtrlGetDisplayPtr(framelock_data->handle),
- NV_CTRL_TARGET_TYPE_GPU,
- gpu_id,
- NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM);
+ gpu_data->ctrl_target = ctrl_target;
gpu_data->label = gtk_label_new("");
gpu_data->timing_label = gtk_label_new("Timing");
@@ -5466,7 +5404,7 @@ static void add_gpu_devices(CtkFramelock *ctk_framelock,
* frame lock is enabled. This should happen if we are
* adding a gpu that has FRAMELOCK_SYNC set to enable.
*/
- NvCtrlGetAttribute(gpu_data->handle,
+ NvCtrlGetAttribute(gpu_data->ctrl_target,
NV_CTRL_FRAMELOCK_SYNC,
&(gpu_data->enabled));
ctk_framelock->framelock_enabled |= gpu_data->enabled;
@@ -5483,49 +5421,36 @@ static void add_gpu_devices(CtkFramelock *ctk_framelock,
}
}
- XFree(data);
-
return;
-
/* Handle failures */
fail:
- XFree(data);
- gpu_data_free(gpu_data);
+ free(gpu_data);
}
/** add_framelock_devices() ******************************************
*
- * Adds all frame lock devices found on the given server handle to
+ * Adds all frame lock devices found on the given system to
* the frame lock group,
*
*/
static void add_framelock_devices(CtkFramelock *ctk_framelock,
- gpointer handle,
+ CtrlSystem *system,
int server_id)
{
- unsigned int num_framelocks;
- unsigned int framelock_id;
- nvFrameLockDataPtr framelock_data = NULL;
- nvListEntryPtr entry;
- ReturnStatus ret;
-
-
- /* Get number of Quadro Sync devices on this server */
-
- ret = NvCtrlQueryTargetCount(handle,
- NV_CTRL_TARGET_TYPE_FRAMELOCK,
- (int *)&num_framelocks);
- if (ret != NvCtrlSuccess) {
- goto fail;
- }
+ nvFrameLockDataPtr framelock_data = NULL;
+ CtrlTargetNode *node;
/* Add frame lock devices found */
- for (framelock_id = 0; framelock_id < num_framelocks; framelock_id++) {
- int val;
- char *revision_str = NULL;
+ for (node = system->targets[FRAMELOCK_TARGET]; node; node = node->next) {
+ nvListEntryPtr entry;
+ ReturnStatus ret;
+ int val;
+ char *revision_str = NULL;
+ CtrlTarget *ctrl_target = node->t;
+
/* Create the frame lock data structure */
framelock_data =
@@ -5534,15 +5459,11 @@ static void add_framelock_devices(CtkFramelock *ctk_framelock,
goto fail;
}
- /* Create the frame lock handle */
- framelock_data->handle =
- NvCtrlAttributeInit(NvCtrlGetDisplayPtr(handle),
- NV_CTRL_TARGET_TYPE_FRAMELOCK,
- framelock_id,
- NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM);
+ /* Get the frame lock target */
+ framelock_data->ctrl_target = ctrl_target;
/* Gather framelock device information */
- ret = NvCtrlGetAttribute(framelock_data->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION,
&val);
if (ret == NvCtrlSuccess) {
@@ -5554,7 +5475,7 @@ static void add_framelock_devices(CtkFramelock *ctk_framelock,
framelock_data->sync_delay_resolution = 7810;
}
- ret = NvCtrlGetAttribute(framelock_data->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FRAMELOCK_FPGA_REVISION,
&val);
if (ret != NvCtrlSuccess) {
@@ -5627,7 +5548,7 @@ static void add_framelock_devices(CtkFramelock *ctk_framelock,
/* Handle failures */
fail:
- framelock_data_free(framelock_data);
+ free(framelock_data);
}
@@ -5642,8 +5563,9 @@ static void add_devices(CtkFramelock *ctk_framelock,
const gchar *display_name,
gboolean error_dialog)
{
- gpointer handle = NULL;
- Display *display;
+ CtrlSystemList *systems = NULL;
+ CtrlSystem *system = NULL;
+ CtrlTarget *ctrl_target = NULL;
int server_id = -1;
char *server_name = NULL;
char *ptr;
@@ -5684,10 +5606,12 @@ static void add_devices(CtkFramelock *ctk_framelock,
sprintf(server_name + strlen(server_name), ":0");
}
- /* open an X Display connection to that X server */
-
- display = XOpenDisplay(server_name);
- if (!display) {
+ /* Connect to the corresponding CtrlSystem */
+
+ systems = ctk_framelock->ctrl_target->system->system_list;
+ system = NvCtrlConnectToSystem(server_name, systems);
+
+ if (!system || !system->dpy) {
if (error_dialog) {
error_msg(ctk_framelock, "<span weight=\"bold\" "
"size=\"larger\">Unable "
@@ -5700,27 +5624,25 @@ static void add_devices(CtkFramelock *ctk_framelock,
goto done;
}
- /* create a new NV-CONTROL handle */
-
- handle = NvCtrlAttributeInit(display, NV_CTRL_TARGET_TYPE_X_SCREEN,
- DefaultScreen(display),
- NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM);
- if (!handle) {
+ /* Get a control target to make queries about the system */
+
+ ctrl_target = NvCtrlGetDefaultTarget(system);
+ if (ctrl_target == NULL) {
if (error_dialog) {
error_msg(ctk_framelock, "<span weight=\"bold\" "
"size=\"larger\">Unable "
"to add devices to frame lock group</span>\n\nUnable to "
- "create NV-CONTROL handle.");
+ "create control target.");
} else {
nv_error_msg("Unable to add devices to frame lock group; unable "
- "create NV-CONTROL handle.");
+ "create control target.");
}
goto done;
}
/* Try to prevent users from adding the same X server more than once */
- if (get_server_id(handle, &server_id) &&
+ if (get_server_id(ctrl_target, &server_id) &&
server_id != -1 &&
find_server_by_id(ctk_framelock->tree, server_id)) {
if (error_dialog) {
@@ -5739,7 +5661,7 @@ static void add_devices(CtkFramelock *ctk_framelock,
/* Add frame lock devices found on server */
- add_framelock_devices(ctk_framelock, handle, server_id);
+ add_framelock_devices(ctk_framelock, system, server_id);
if (!ctk_framelock->tree ||
!((nvListTreePtr)(ctk_framelock->tree))->nentries) {
if (error_dialog) {
@@ -5763,12 +5685,7 @@ static void add_devices(CtkFramelock *ctk_framelock,
/* Fall through */
done:
- if (server_name) {
- free(server_name);
- }
- if (handle) {
- NvCtrlAttributeClose(handle);
- }
+ free(server_name);
return;
}
@@ -5791,7 +5708,7 @@ static void add_devices(CtkFramelock *ctk_framelock,
a.target_type = target_type; \
a.target_id = target_id; \
a.attr_entry = \
- nv_get_attribute_entry((ATTR), NV_PARSER_ATTRIBUTE_TYPE_INTEGER); \
+ nv_get_attribute_entry((ATTR), CTRL_ATTRIBUTE_TYPE_INTEGER); \
a.val.i = (VAL); \
a.parser_flags.has_target = NV_TRUE; \
\
@@ -5802,8 +5719,8 @@ static void add_entry_to_parsed_attributes(nvListEntryPtr entry,
ParsedAttribute *head)
{
char *display_name = NULL;
- int target_type = 0;
- int target_id = 0;
+ int target_type;
+ int target_id;
if (!entry) {
return;
@@ -5815,12 +5732,13 @@ static void add_entry_to_parsed_attributes(nvListEntryPtr entry,
{
int use_house_sync;
nvFrameLockDataPtr data = (nvFrameLockDataPtr)(entry->data);
+ CtrlTarget *ctrl_target = data->ctrl_target;
- display_name = NvCtrlGetDisplayName(data->handle);
- target_type = NV_CTRL_TARGET_TYPE_FRAMELOCK;
- target_id = NvCtrlGetTargetId(data->handle);
+ display_name = NvCtrlGetDisplayName(ctrl_target);
+ target_type = FRAMELOCK_TARGET;
+ target_id = NvCtrlGetTargetId(ctrl_target);
- NvCtrlGetAttribute(data->handle, NV_CTRL_USE_HOUSE_SYNC,
+ NvCtrlGetAttribute(ctrl_target, NV_CTRL_USE_HOUSE_SYNC,
&use_house_sync);
__ADD_ATTR(NV_CTRL_USE_HOUSE_SYNC, use_house_sync);
@@ -5831,13 +5749,13 @@ static void add_entry_to_parsed_attributes(nvListEntryPtr entry,
int sync_edge;
int video_mode;
- NvCtrlGetAttribute(data->handle,
+ NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FRAMELOCK_SYNC_INTERVAL,
&sync_interval);
- NvCtrlGetAttribute(data->handle,
+ NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FRAMELOCK_POLARITY,
&sync_edge);
- NvCtrlGetAttribute(data->handle,
+ NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FRAMELOCK_VIDEO_MODE,
&video_mode);
@@ -5846,9 +5764,7 @@ static void add_entry_to_parsed_attributes(nvListEntryPtr entry,
__ADD_ATTR(NV_CTRL_FRAMELOCK_VIDEO_MODE, video_mode);
}
- if (display_name) {
- free(display_name);
- }
+ free(display_name);
}
break;
@@ -5859,14 +5775,15 @@ static void add_entry_to_parsed_attributes(nvListEntryPtr entry,
case ENTRY_DATA_DISPLAY:
{
nvDisplayDataPtr data = (nvDisplayDataPtr)(entry->data);
+ CtrlTarget *ctrl_target = data->ctrl_target;
int config;
ReturnStatus ret;
- display_name = NvCtrlGetDisplayName(data->handle);
- target_type = NV_CTRL_TARGET_TYPE_DISPLAY;
- target_id = NvCtrlGetTargetId(data->handle);
+ display_name = NvCtrlGetDisplayName(ctrl_target);
+ target_type = DISPLAY_TARGET;
+ target_id = NvCtrlGetTargetId(ctrl_target);
- ret = NvCtrlGetAttribute(data->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FRAMELOCK_DISPLAY_CONFIG,
&config);
if (ret != NvCtrlSuccess) {
@@ -5875,9 +5792,7 @@ static void add_entry_to_parsed_attributes(nvListEntryPtr entry,
__ADD_ATTR(NV_CTRL_FRAMELOCK_DISPLAY_CONFIG, config);
- if (display_name) {
- free(display_name);
- }
+ free(display_name);
}
break;
@@ -5962,9 +5877,7 @@ static void apply_parsed_attribute_list(CtkFramelock *ctk_framelock,
}
/* Check to see if the server is already added */
- if (server_name) {
- free(server_name);
- }
+ free(server_name);
server_name = nv_standardize_screen_name(p->display, -2);
if (!server_name) {
continue;
@@ -5979,9 +5892,7 @@ static void apply_parsed_attribute_list(CtkFramelock *ctk_framelock,
add_devices(ctk_framelock, server_name, FALSE);
}
- if (server_name) {
- free(server_name);
- }
+ free(server_name);
}
diff --git a/src/gtk+-2.x/ctkframelock.h b/src/gtk+-2.x/ctkframelock.h
index ac21f22..1cc76f9 100644
--- a/src/gtk+-2.x/ctkframelock.h
+++ b/src/gtk+-2.x/ctkframelock.h
@@ -55,9 +55,9 @@ struct _CtkFramelock
{
GtkVBox parent;
- NvCtrlAttributeHandle *attribute_handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
-
+
GtkWindow *parent_window;
GdkCursor *wait_cursor;
@@ -130,8 +130,8 @@ struct _CtkFramelockClass
};
GType ctk_framelock_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_framelock_new (NvCtrlAttributeHandle *, GtkWidget *,
- CtkConfig *, ParsedAttribute *);
+GtkWidget* ctk_framelock_new (CtrlTarget *, GtkWidget *, CtkConfig *,
+ ParsedAttribute *);
GtkTextBuffer *ctk_framelock_create_help(GtkTextTagTable *);
diff --git a/src/gtk+-2.x/ctkglx.c b/src/gtk+-2.x/ctkglx.c
index feec275..7652adc 100644
--- a/src/gtk+-2.x/ctkglx.c
+++ b/src/gtk+-2.x/ctkglx.c
@@ -157,14 +157,6 @@ GType ctk_glx_get_type(void)
} /* ctk_glx_get_type() */
-static void dummy_button_signal(GtkWidget *widget,
- gpointer user_data)
-{
- /* This is a dummy function so tooltips are enabled
- * for the fbconfig table column titles
- */
-}
-
/*
* show_fbc_toggled() - called when the show GLX Frame Buffer Configurations
@@ -211,6 +203,138 @@ fbc_window_destroy(GtkWidget *widget, GdkEvent *event, gpointer user_data)
} /* fbc_window_destroy() */
+/*
+ * create_fbconfig_model() - called to create and populate the model for
+ * the GLX Frame Buffer Configurations table.
+ */
+static GtkTreeModel *create_fbconfig_model(GLXFBConfigAttr *fbconfig_attribs)
+{
+ GtkListStore *model;
+ GtkTreeIter iter;
+ int i;
+ GValue v = G_VALUE_INIT;
+
+ if (!fbconfig_attribs) {
+ return NULL;
+ }
+
+ g_value_init(&v, G_TYPE_STRING);
+
+ model = gtk_list_store_new(NUM_FBCONFIG_ATTRIBS,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+
+ /* Populate FBConfig table */
+ i = 0;
+ while ( fbconfig_attribs[i].fbconfig_id != 0 ) {
+ char str[NUM_FBCONFIG_ATTRIBS + 1][16];
+ int cell = 0; /* Used for putting information into cells */
+
+ if ( fbconfig_attribs[i].fbconfig_id ) {
+ snprintf((char *) (&(str[cell++])), 16, "0x%02X",
+ fbconfig_attribs[i].fbconfig_id);
+ } else {
+ sprintf((char *) (&(str[cell++])),".");
+ }
+
+ if ( fbconfig_attribs[i].visual_id ) {
+ snprintf((char *) (&(str[cell++])), 16, "0x%02X",
+ fbconfig_attribs[i].visual_id);
+ } else {
+ sprintf((char *) (&(str[cell++])),".");
+ }
+ snprintf((char *) (&(str[cell++])), 16, "%s",
+ x_visual_type_abbrev(fbconfig_attribs[i].x_visual_type));
+ snprintf((char *) (&(str[cell++])), 16, "%3d",
+ fbconfig_attribs[i].buffer_size);
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].level);
+ snprintf((char *) (&(str[cell++])), 16, "%s",
+ render_type_abbrev(fbconfig_attribs[i].render_type) );
+ snprintf((char *) (&(str[cell++])), 16, "%c",
+ fbconfig_attribs[i].doublebuffer ? 'y' : '.');
+ snprintf((char *) (&(str[cell++])), 16, "%c",
+ fbconfig_attribs[i].stereo ? 'y' : '.');
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].red_size);
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].green_size);
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].blue_size);
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].alpha_size);
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].aux_buffers);
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].depth_size);
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].stencil_size);
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].accum_red_size);
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].accum_green_size);
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].accum_blue_size);
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].accum_alpha_size);
+ if (fbconfig_attribs[i].multi_sample_valid) {
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].multi_samples);
+ if (fbconfig_attribs[i].multi_sample_coverage_valid) {
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].multi_samples_color);
+ } else {
+ snprintf((char *) (&(str[cell++])), 16, "%2d",
+ fbconfig_attribs[i].multi_samples);
+ }
+ } else {
+ snprintf((char *) (&(str[cell++])), 16, " 0");
+ snprintf((char *) (&(str[cell++])), 16, " 0");
+ }
+ snprintf((char *) (&(str[cell++])), 16, "%1d",
+ fbconfig_attribs[i].multi_sample_buffers);
+ snprintf((char *) (&(str[cell++])), 16, "%s",
+ caveat_abbrev( fbconfig_attribs[i].config_caveat) );
+ snprintf((char *) (&(str[cell++])), 16, "0x%04X",
+ fbconfig_attribs[i].pbuffer_width);
+ snprintf((char *) (&(str[cell++])), 16, "0x%04X",
+ fbconfig_attribs[i].pbuffer_height);
+ snprintf((char *) (&(str[cell++])), 16, "0x%07X",
+ fbconfig_attribs[i].pbuffer_max);
+ snprintf((char *) (&(str[cell++])), 16, "%s",
+ transparent_type_abbrev(fbconfig_attribs[i].transparent_type));
+ snprintf((char *) (&(str[cell++])), 16, "%3d",
+ fbconfig_attribs[i].transparent_red_value);
+ snprintf((char *) (&(str[cell++])), 16, "%3d",
+ fbconfig_attribs[i].transparent_green_value);
+ snprintf((char *) (&(str[cell++])), 16, "%3d",
+ fbconfig_attribs[i].transparent_blue_value);
+ snprintf((char *) (&(str[cell++])), 16, "%3d",
+ fbconfig_attribs[i].transparent_alpha_value);
+ snprintf((char *) (&(str[cell++])), 16, "%3d",
+ fbconfig_attribs[i].transparent_index_value);
+ str[NUM_FBCONFIG_ATTRIBS][0] = '\0';
+
+ /* Populate cells for this row */
+ gtk_list_store_append (model, &iter);
+ for (cell=0; cell<NUM_FBCONFIG_ATTRIBS; cell++) {
+ g_value_set_string(&v, str[cell]);
+ gtk_list_store_set_value(model, &iter, cell, &v);
+ }
+
+ i++;
+
+ } /* Done - Populating FBconfig table */
+
+ return GTK_TREE_MODEL(model);
+}
+
/* Creates the GLX information widget
*
* NOTE: The GLX information other than the FBConfigs will
@@ -224,8 +348,9 @@ typedef struct WidgetSizeRec {
int width;
} WidgetSize;
-GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
- CtkConfig *ctk_config, CtkEvent *ctk_event)
+GtkWidget* ctk_glx_new(CtrlTarget *ctrl_target,
+ CtkConfig *ctk_config,
+ CtkEvent *ctk_event)
{
GObject *object;
CtkGLX *ctk_glx;
@@ -236,11 +361,10 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
GtkWidget *vbox;
GtkWidget *scrollWin;
GtkWidget *event; /* For setting the background color to white */
- GtkWidget *data_table, *header_table;
- GtkWidget *data_viewport, *full_viewport;
- GtkWidget *vscrollbar, *hscrollbar;
+ GtkWidget *fbc_scroll_win;
+ GtkWidget *fbc_view;
+ GtkTreeModel *fbc_model;
GtkWidget *show_fbc_button, *window;
- GtkRequisition req;
ReturnStatus ret;
char * glx_info_str = NULL; /* Test if GLX supported */
@@ -261,8 +385,6 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
"trt", "trr", "trg", "trb", "tra", "tri"
};
- WidgetSize fbconfig_header_sizes[NUM_FBCONFIG_ATTRIBS];
-
const char *fbconfig_tooltips[NUM_FBCONFIG_ATTRIBS] = {
__fid_help, __vid_help, __vt_help, __bfs_help, __lvl_help,
__bf_help, __db_help, __st_help,
@@ -282,8 +404,8 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
ctk_glx = CTK_GLX(object);
- /* Cache the attribute handle */
- ctk_glx->handle = handle;
+ /* Cache the target */
+ ctk_glx->ctrl_target = ctrl_target;
/* Set container properties of the object */
ctk_glx->ctk_config = ctk_config;
@@ -295,7 +417,7 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
gtk_box_pack_start(GTK_BOX(ctk_glx), banner, FALSE, FALSE, 0);
/* Determine if GLX is supported */
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_SERVER_VENDOR,
&glx_info_str);
free(glx_info_str);
@@ -325,7 +447,8 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
#ifdef GLX_VERSION_1_3
/* Grab the FBConfigs */
- ret = NvCtrlGetVoidAttribute(handle, NV_CTRL_ATTR_GLX_FBCONFIG_ATTRIBS,
+ ret = NvCtrlGetVoidAttribute(ctrl_target,
+ NV_CTRL_ATTR_GLX_FBCONFIG_ATTRIBS,
(void *)(&fbconfig_attribs));
if ( ret != NvCtrlSuccess ) {
err_str = "Failed to query list of GLX frame buffer configurations.";
@@ -340,7 +463,7 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
}
if ( ! num_fbconfigs ) {
err_str = "No frame buffer configurations found.";
-
+
goto fail;
}
@@ -355,7 +478,7 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "GLX Frame Buffer Configurations");
gtk_container_set_border_width(GTK_CONTAINER(window), CTK_WINDOW_PAD);
- gtk_widget_set_size_request(window, 400, 200);
+ gtk_window_set_default_size(GTK_WINDOW(window), 400, 200);
g_signal_connect(G_OBJECT(window), "destroy-event",
G_CALLBACK(fbc_window_destroy),
(gpointer) ctk_glx);
@@ -369,64 +492,46 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
hbox = gtk_hbox_new(FALSE, 0);
vbox = gtk_vbox_new(FALSE, 10);
- data_viewport = gtk_viewport_new(NULL, NULL);
- gtk_widget_set_size_request(data_viewport, 400, 50);
- vscrollbar = gtk_vscrollbar_new(gtk_viewport_get_vadjustment
- (GTK_VIEWPORT(data_viewport)));
-
- full_viewport = gtk_viewport_new(NULL, NULL);
- gtk_widget_set_size_request(full_viewport, 400, 50);
- hscrollbar = gtk_hscrollbar_new(gtk_viewport_get_hadjustment
- (GTK_VIEWPORT(full_viewport)));
- /*
- * NODE: Because clists have a hard time displaying tooltips in their
- * column labels/buttons, we make the fbconfig table using a
- * table widget.
- */
- /* Create the header table */
+ /* Create fbconfig window */
+ fbc_view = gtk_tree_view_new();
- header_table = gtk_table_new(num_fbconfigs, NUM_FBCONFIG_ATTRIBS, FALSE);
-
+ /* Create columns and column headers with tooltips */
for ( i = 0; i < NUM_FBCONFIG_ATTRIBS; i++ ) {
- GtkWidget * btn = gtk_button_new_with_label(fbconfig_titles[i]);
- g_signal_connect(G_OBJECT(btn), "clicked",
- G_CALLBACK(dummy_button_signal),
- (gpointer) ctk_glx);
- ctk_config_set_tooltip(ctk_config, btn, fbconfig_tooltips[i]);
- gtk_table_attach(GTK_TABLE(header_table), btn, i, i+1, 0, 1,
- GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
-
- fbconfig_header_sizes[i].widget = btn;
- ctk_widget_get_preferred_size(btn, &req);
- fbconfig_header_sizes[i].width = req.width;
+ GtkWidget *label;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *col;
+
+ renderer = gtk_cell_renderer_text_new();
+ ctk_cell_renderer_set_alignment(renderer, 0.5, 0.5);
+
+ col = gtk_tree_view_column_new_with_attributes(fbconfig_titles[i],
+ renderer,
+ "text", i,
+ NULL);
+
+ label = gtk_label_new(fbconfig_titles[i]);
+ ctk_config_set_tooltip(ctk_config, label, fbconfig_tooltips[i]);
+ gtk_widget_show(label);
+
+ gtk_tree_view_column_set_widget(col, label);
+ gtk_tree_view_insert_column(GTK_TREE_VIEW(fbc_view), col, -1);
}
-
- /* Create the data table */
- data_table = gtk_table_new(num_fbconfigs, NUM_FBCONFIG_ATTRIBS, FALSE);
- event = gtk_event_box_new();
- ctk_force_text_colors_on_widget(event);
- gtk_container_add (GTK_CONTAINER(event), data_table);
- gtk_container_add(GTK_CONTAINER(data_viewport), event);
+ /* Create data model and add view to the window */
+ fbc_model = create_fbconfig_model(fbconfig_attribs);
+ free(fbconfig_attribs);
- /* Pack the fbconfig header and data tables */
+ gtk_tree_view_set_model(GTK_TREE_VIEW(fbc_view), fbc_model);
+ g_object_unref(fbc_model);
- vbox = gtk_vbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), header_table, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), data_viewport, TRUE, TRUE, 0);
- gtk_container_add (GTK_CONTAINER(full_viewport), vbox);
+ fbc_scroll_win = gtk_scrolled_window_new(NULL, NULL);
- vbox = gtk_vbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), full_viewport, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), hscrollbar, FALSE, FALSE, 0);
-
- hbox = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), vscrollbar, FALSE, FALSE, 0);
-
- gtk_container_add(GTK_CONTAINER(window), hbox);
+ gtk_container_add (GTK_CONTAINER (fbc_scroll_win), fbc_view);
+ gtk_container_add (GTK_CONTAINER (window), fbc_scroll_win);
+
+ /* Create main page layout */
vbox = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), show_fbc_button, FALSE, FALSE, 0);
hbox = gtk_hbox_new(FALSE, 0);
@@ -440,136 +545,8 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ctk_glx), vbox, TRUE, TRUE, 0);
-
- /* Fill the data table */
- if ( fbconfig_attribs ) {
- /* Populate FBConfig table */
- i = 0;
- while ( fbconfig_attribs[i].fbconfig_id != 0 ) {
- char str[NUM_FBCONFIG_ATTRIBS + 1][16];
- int cell = 0; /* Used for putting information into cells */
-
- if ( fbconfig_attribs[i].fbconfig_id ) {
- snprintf((char *) (&(str[cell++])), 16, "0x%02X",
- fbconfig_attribs[i].fbconfig_id);
- } else {
- sprintf((char *) (&(str[cell++])),".");
- }
-
- if ( fbconfig_attribs[i].visual_id ) {
- snprintf((char *) (&(str[cell++])), 16, "0x%02X",
- fbconfig_attribs[i].visual_id);
- } else {
- sprintf((char *) (&(str[cell++])),".");
- }
- snprintf((char *) (&(str[cell++])), 16, "%s",
- x_visual_type_abbrev(fbconfig_attribs[i].x_visual_type));
- snprintf((char *) (&(str[cell++])), 16, "%3d",
- fbconfig_attribs[i].buffer_size);
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].level);
- snprintf((char *) (&(str[cell++])), 16, "%s",
- render_type_abbrev(fbconfig_attribs[i].render_type) );
- snprintf((char *) (&(str[cell++])), 16, "%c",
- fbconfig_attribs[i].doublebuffer ? 'y' : '.');
- snprintf((char *) (&(str[cell++])), 16, "%c",
- fbconfig_attribs[i].stereo ? 'y' : '.');
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].red_size);
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].green_size);
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].blue_size);
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].alpha_size);
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].aux_buffers);
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].depth_size);
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].stencil_size);
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].accum_red_size);
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].accum_green_size);
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].accum_blue_size);
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].accum_alpha_size);
- if (fbconfig_attribs[i].multi_sample_valid) {
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].multi_samples);
- if (fbconfig_attribs[i].multi_sample_coverage_valid) {
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].multi_samples_color);
- } else {
- snprintf((char *) (&(str[cell++])), 16, "%2d",
- fbconfig_attribs[i].multi_samples);
- }
- } else {
- snprintf((char *) (&(str[cell++])), 16, " 0");
- snprintf((char *) (&(str[cell++])), 16, " 0");
- }
- snprintf((char *) (&(str[cell++])), 16, "%1d",
- fbconfig_attribs[i].multi_sample_buffers);
- snprintf((char *) (&(str[cell++])), 16, "%s",
- caveat_abbrev( fbconfig_attribs[i].config_caveat) );
- snprintf((char *) (&(str[cell++])), 16, "0x%04X",
- fbconfig_attribs[i].pbuffer_width);
- snprintf((char *) (&(str[cell++])), 16, "0x%04X",
- fbconfig_attribs[i].pbuffer_height);
- snprintf((char *) (&(str[cell++])), 16, "0x%07X",
- fbconfig_attribs[i].pbuffer_max);
- snprintf((char *) (&(str[cell++])), 16, "%s",
- transparent_type_abbrev(fbconfig_attribs[i].transparent_type));
- snprintf((char *) (&(str[cell++])), 16, "%3d",
- fbconfig_attribs[i].transparent_red_value);
- snprintf((char *) (&(str[cell++])), 16, "%3d",
- fbconfig_attribs[i].transparent_green_value);
- snprintf((char *) (&(str[cell++])), 16, "%3d",
- fbconfig_attribs[i].transparent_blue_value);
- snprintf((char *) (&(str[cell++])), 16, "%3d",
- fbconfig_attribs[i].transparent_alpha_value);
- snprintf((char *) (&(str[cell++])), 16, "%3d",
- fbconfig_attribs[i].transparent_index_value);
- str[NUM_FBCONFIG_ATTRIBS][0] = '\0';
-
- /* Populate row cells */
- for ( cell = 0; cell < NUM_FBCONFIG_ATTRIBS ; cell++) {
- GtkWidget * label = gtk_label_new( str[cell] );
- gtk_label_set_justify( GTK_LABEL(label), GTK_JUSTIFY_CENTER);
- gtk_table_attach(GTK_TABLE(data_table), label,
- cell, cell+1,
- i+1, i+2,
- GTK_EXPAND, GTK_EXPAND, 0, 0);
-
- /* Make sure the table headers are the same width
- * as their table data column
- */
- ctk_widget_get_preferred_size(label, &req);
-
- if ( fbconfig_header_sizes[cell].width > req.width ) {
- gtk_widget_set_size_request(label,
- fbconfig_header_sizes[cell].width,
- -1);
- } else if ( fbconfig_header_sizes[cell].width < req.width ) {
- fbconfig_header_sizes[cell].width = req.width + 6;
- gtk_widget_set_size_request(fbconfig_header_sizes[cell].widget,
- fbconfig_header_sizes[cell].width,
- -1);
- }
- }
- i++;
-
- } /* Done - Populating FBconfig table */
-
-
- free(fbconfig_attribs);
-
- } /* Done - FBConfigs exist */
-
#endif /* GLX_VERSION_1_3 */
@@ -589,7 +566,7 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
/* Free memory that may have been allocated */
free(fbconfig_attribs);
-
+
gtk_widget_show_all(GTK_WIDGET(object));
return GTK_WIDGET(object);
@@ -604,6 +581,7 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle,
void ctk_glx_probe_info(GtkWidget *widget)
{
CtkGLX *ctk_glx = CTK_GLX(widget);
+ CtrlTarget *ctrl_target = ctk_glx->ctrl_target;
ReturnStatus ret;
@@ -638,60 +616,60 @@ void ctk_glx_probe_info(GtkWidget *widget)
/* Get GLX information */
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_DIRECT_RENDERING,
&direct_rendering);
if ( ret != NvCtrlSuccess ) { goto done; }
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_GLX_EXTENSIONS,
&glx_extensions);
if ( ret != NvCtrlSuccess ) { goto done; }
/* Get Server GLX information */
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_SERVER_VENDOR,
&server_vendor);
if ( ret != NvCtrlSuccess ) { goto done; }
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_SERVER_VERSION,
&server_version);
if ( ret != NvCtrlSuccess ) { goto done; }
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_SERVER_EXTENSIONS,
&server_extensions);
if ( ret != NvCtrlSuccess ) { goto done; }
/* Get Client GLX information */
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_CLIENT_VENDOR,
&client_vendor);
if ( ret != NvCtrlSuccess ) { goto done; }
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_CLIENT_VERSION,
&client_version);
if ( ret != NvCtrlSuccess ) { goto done; }
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_CLIENT_EXTENSIONS,
&client_extensions);
if ( ret != NvCtrlSuccess ) { goto done; }
/* Get OpenGL information */
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_OPENGL_VENDOR,
&opengl_vendor);
if ( ret != NvCtrlSuccess ) { goto done; }
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_OPENGL_RENDERER,
&opengl_renderer);
if ( ret != NvCtrlSuccess ) { goto done; }
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_OPENGL_VERSION,
&opengl_version);
if ( ret != NvCtrlSuccess ) { goto done; }
- ret = NvCtrlGetStringAttribute(ctk_glx->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GLX_OPENGL_EXTENSIONS,
&opengl_extensions);
if ( ret != NvCtrlSuccess ) { goto done; }
@@ -791,7 +769,7 @@ void ctk_glx_probe_info(GtkWidget *widget)
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 5);
gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0);
-
+
/* Add OpenGL information to widget */
hbox = gtk_hbox_new(FALSE, 0);
@@ -846,7 +824,7 @@ void ctk_glx_probe_info(GtkWidget *widget)
free(opengl_renderer);
free(opengl_version);
free(opengl_extensions);
-
+
} /* ctk_glx_probe_info() */
@@ -858,7 +836,7 @@ GtkTextBuffer *ctk_glx_create_help(GtkTextTagTable *table,
GtkTextBuffer *b;
b = gtk_text_buffer_new(table);
-
+
gtk_text_buffer_get_iter_at_offset(b, &i, 0);
ctk_help_title(b, &i, "GLX Help");
diff --git a/src/gtk+-2.x/ctkglx.h b/src/gtk+-2.x/ctkglx.h
index ff7eada..fe0d4e5 100644
--- a/src/gtk+-2.x/ctkglx.h
+++ b/src/gtk+-2.x/ctkglx.h
@@ -50,7 +50,7 @@ struct _CtkGLX
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
GtkWidget *glxinfo_vpane;
@@ -65,8 +65,7 @@ struct _CtkGLXClass
};
GType ctk_glx_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_glx_new (NvCtrlAttributeHandle *,
- CtkConfig *, CtkEvent *);
+GtkWidget* ctk_glx_new (CtrlTarget *, CtkConfig *, CtkEvent *);
GtkTextBuffer *ctk_glx_create_help(GtkTextTagTable *, CtkGLX *);
diff --git a/src/gtk+-2.x/ctkgpu.c b/src/gtk+-2.x/ctkgpu.c
index 99ba6e5..02c5d86 100644
--- a/src/gtk+-2.x/ctkgpu.c
+++ b/src/gtk+-2.x/ctkgpu.c
@@ -35,7 +35,7 @@
#include "XF86Config-parser/xf86Parser.h"
-static void probe_displays_received(GObject *object, gpointer arg1,
+static void probe_displays_received(GObject *object, CtrlEvent *event,
gpointer user_data);
static gboolean update_gpu_usage(gpointer);
@@ -82,23 +82,22 @@ GType ctk_gpu_get_type(
}
-static gchar *make_display_device_list(NvCtrlAttributeHandle *handle)
+static gchar *make_display_device_list(CtrlTarget *ctrl_target)
{
- return create_display_name_list_string(handle,
+ return create_display_name_list_string(ctrl_target,
NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU);
} /* make_display_device_list() */
-void get_bus_type_str(NvCtrlAttributeHandle *handle,
- gchar **bus)
+void get_bus_type_str(CtrlTarget *ctrl_target, gchar **bus)
{
int tmp, ret, bus_type;
gchar *bus_type_str, *bus_rate, *pcie_gen;
bus_type = 0xffffffff;
bus_type_str = "Unknown";
- ret = NvCtrlGetAttribute(handle, NV_CTRL_BUS_TYPE, &bus_type);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_BUS_TYPE, &bus_type);
if (ret == NvCtrlSuccess) {
if (bus_type == NV_CTRL_BUS_TYPE_AGP)
bus_type_str = "AGP";
@@ -115,7 +114,8 @@ void get_bus_type_str(NvCtrlAttributeHandle *handle,
bus_rate = NULL;
if (bus_type == NV_CTRL_BUS_TYPE_AGP ||
bus_type == NV_CTRL_BUS_TYPE_PCI_EXPRESS) {
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH,
+ &tmp);
if (ret == NvCtrlSuccess) {
if (bus_type == NV_CTRL_BUS_TYPE_PCI_EXPRESS) {
bus_rate = g_strdup_printf("x%u", tmp);
@@ -129,7 +129,7 @@ void get_bus_type_str(NvCtrlAttributeHandle *handle,
pcie_gen = NULL;
if (bus_type == NV_CTRL_BUS_TYPE_PCI_EXPRESS) {
- pcie_gen = get_pcie_generation_string(handle);
+ pcie_gen = get_pcie_generation_string(ctrl_target);
}
/* concatenate all the available bus related information */
@@ -146,7 +146,7 @@ void get_bus_type_str(NvCtrlAttributeHandle *handle,
}
}
-gchar *get_bus_id_str(NvCtrlAttributeHandle *handle)
+gchar *get_bus_id_str(CtrlTarget *ctrl_target)
{
int ret;
int pci_domain, pci_bus, pci_device, pci_func;
@@ -156,22 +156,22 @@ gchar *get_bus_id_str(NvCtrlAttributeHandle *handle)
* NV_CTRL_PCI_DEVICE & NV__CTRL_PCI_FUNCTION
*/
- ret = NvCtrlGetAttribute(handle, NV_CTRL_PCI_DOMAIN, &pci_domain);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_PCI_DOMAIN, &pci_domain);
if (ret != NvCtrlSuccess) {
return NULL;
}
- ret = NvCtrlGetAttribute(handle, NV_CTRL_PCI_BUS, &pci_bus);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_PCI_BUS, &pci_bus);
if (ret != NvCtrlSuccess) {
return NULL;
}
- ret = NvCtrlGetAttribute(handle, NV_CTRL_PCI_DEVICE, &pci_device);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_PCI_DEVICE, &pci_device);
if (ret != NvCtrlSuccess) {
return NULL;
}
- ret = NvCtrlGetAttribute(handle, NV_CTRL_PCI_FUNCTION, &pci_func);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_PCI_FUNCTION, &pci_func);
if (ret != NvCtrlSuccess) {
return NULL;
}
@@ -204,12 +204,9 @@ static void apply_gpu_utilization_token(char *token, char *value, void *data)
-GtkWidget* ctk_gpu_new(
- NvCtrlAttributeHandle *handle,
- CtrlHandleTarget *t,
- CtkEvent *ctk_event,
- CtkConfig *ctk_config
-)
+GtkWidget* ctk_gpu_new(CtrlTarget *ctrl_target,
+ CtkEvent *ctk_event,
+ CtkConfig *ctk_config)
{
GObject *object;
CtkGpu *ctk_gpu;
@@ -252,27 +249,27 @@ GtkWidget* ctk_gpu_new(
/*
* get the data that we will display below
- *
+ *
* XXX should be able to update any of this if an attribute
* changes.
*/
/* NV_CTRL_XINERAMA */
-
- ret = NvCtrlGetAttribute(handle, NV_CTRL_XINERAMA, &xinerama_enabled);
+
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_XINERAMA, &xinerama_enabled);
if (ret != NvCtrlSuccess) {
xinerama_enabled = FALSE;
}
/* NV_CTRL_STRING_PRODUCT_NAME */
- ret = NvCtrlGetStringAttribute(handle, NV_CTRL_STRING_PRODUCT_NAME,
+ ret = NvCtrlGetStringAttribute(ctrl_target, NV_CTRL_STRING_PRODUCT_NAME,
&product_name);
if (ret != NvCtrlSuccess) {
product_name = NULL;
}
- ret = NvCtrlGetStringAttribute(handle, NV_CTRL_STRING_GPU_UUID,
+ ret = NvCtrlGetStringAttribute(ctrl_target, NV_CTRL_STRING_GPU_UUID,
&gpu_uuid);
if (ret != NvCtrlSuccess) {
gpu_uuid = NULL;
@@ -280,14 +277,14 @@ GtkWidget* ctk_gpu_new(
/* Get Bus related information */
- pci_bus_id = get_bus_id_str(handle);
+ pci_bus_id = get_bus_id_str(ctrl_target);
/* NV_CTRL_PCI_ID */
memset(&pci_device_id, 0, sizeof(pci_device_id));
memset(&pci_vendor_id, 0, sizeof(pci_vendor_id));
- ret = NvCtrlGetAttribute(handle, NV_CTRL_PCI_ID, &pci_id);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_PCI_ID, &pci_id);
if (ret == NvCtrlSuccess) {
snprintf(pci_device_id, ARRAY_ELEMENTS, "0x%04x", (pci_id & 0xFFFF));
@@ -296,13 +293,13 @@ GtkWidget* ctk_gpu_new(
/* NV_CTRL_STRING_VBIOS_VERSION */
- ret = NvCtrlGetStringAttribute(handle, NV_CTRL_STRING_VBIOS_VERSION,
+ ret = NvCtrlGetStringAttribute(ctrl_target, NV_CTRL_STRING_VBIOS_VERSION,
&vbios_version);
if (ret != NvCtrlSuccess) vbios_version = NULL;
/* NV_CTRL_VIDEO_RAM */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_VIDEO_RAM, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_VIDEO_RAM, &tmp);
if (ret != NvCtrlSuccess) {
video_ram = NULL;
} else {
@@ -311,7 +308,7 @@ GtkWidget* ctk_gpu_new(
/* NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY,
&gpu_memory);
if (ret != NvCtrlSuccess) {
gpu_memory_text = NULL;
@@ -321,7 +318,7 @@ GtkWidget* ctk_gpu_new(
/* NV_CTRL_GPU_CORES */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CORES, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_CORES, &tmp);
if (ret != NvCtrlSuccess) {
gpu_cores = NULL;
} else {
@@ -330,7 +327,7 @@ GtkWidget* ctk_gpu_new(
/* NV_CTRL_GPU_MEMORY_BUS_WIDTH */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_MEMORY_BUS_WIDTH, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_MEMORY_BUS_WIDTH, &tmp);
if (ret != NvCtrlSuccess) {
memory_interface = NULL;
} else {
@@ -339,7 +336,7 @@ GtkWidget* ctk_gpu_new(
/* NV_CTRL_IRQ */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_IRQ, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_IRQ, &tmp);
if (ret != NvCtrlSuccess) {
irq = NULL;
} else {
@@ -350,19 +347,19 @@ GtkWidget* ctk_gpu_new(
memset(&entry, 0, sizeof(entry));
- ret = NvCtrlGetStringAttribute(handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GPU_UTILIZATION,
&tmp_str);
if (ret == NvCtrlSuccess) {
parse_token_value_pairs(tmp_str, apply_gpu_utilization_token, &entry);
- XFree(tmp_str);
+ free(tmp_str);
}
-
-
+
+
/* List of X Screens using the GPU */
screens = NULL;
- ret = NvCtrlGetBinaryAttribute(handle,
+ ret = NvCtrlGetBinaryAttribute(ctrl_target,
0,
NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU,
(unsigned char **)(&pData),
@@ -371,7 +368,7 @@ GtkWidget* ctk_gpu_new(
if (pData[0] == 0) {
screens = g_strdup("None");
} else {
- NvCtrlAttributeHandle *screen_handle;
+ CtrlTarget *screen_target;
if (xinerama_enabled) {
screens = g_strdup("Screen 0 (Xinerama)");
@@ -383,7 +380,9 @@ GtkWidget* ctk_gpu_new(
* then we would need to get a handle
* for the correct screen instead.
*/
- screen_handle = t[0].h;
+ screen_target = NvCtrlGetDefaultTargetByType(
+ ctrl_target->system,
+ X_SCREEN_TARGET);
} else {
for (i = 1; i <= pData[0]; i++) {
if (screens) {
@@ -395,10 +394,11 @@ GtkWidget* ctk_gpu_new(
g_free(screens);
screens = tmp_str;
}
- screen_handle = t[pData[1]].h;
+ screen_target = NvCtrlGetTarget(ctrl_target->system,
+ X_SCREEN_TARGET, pData[1]);
}
- ret = NvCtrlGetAttribute(screen_handle,
+ ret = NvCtrlGetAttribute(screen_target,
NV_CTRL_SHOW_SLI_VISUAL_INDICATOR,
&tmp);
if (ret == NvCtrlSuccess) {
@@ -407,7 +407,7 @@ GtkWidget* ctk_gpu_new(
screens = tmp_str;
}
}
- XFree(pData);
+ free(pData);
}
if (!screens) {
screens = g_strdup("Unknown");
@@ -418,9 +418,9 @@ GtkWidget* ctk_gpu_new(
object = g_object_new(CTK_TYPE_GPU, NULL);
ctk_gpu = CTK_GPU(object);
- /* cache the attribute handle */
+ /* cache the control target */
- ctk_gpu->handle = handle;
+ ctk_gpu->ctrl_target = ctrl_target;
ctk_gpu->gpu_cores = (gpu_cores != NULL) ? 1 : 0;
ctk_gpu->gpu_uuid = (gpu_uuid != NULL) ? 1 : 0;
ctk_gpu->memory_interface = (memory_interface != NULL) ? 1 : 0;
@@ -439,15 +439,16 @@ GtkWidget* ctk_gpu_new(
gtk_box_pack_start(GTK_BOX(ctk_gpu), banner, FALSE, FALSE, 0);
/* PCIe link information */
- get_bus_type_str(handle, &bus);
- pcie_gen_str = get_pcie_generation_string(handle);
+ get_bus_type_str(ctrl_target, &bus);
+ pcie_gen_str = get_pcie_generation_string(ctrl_target);
if (pcie_gen_str) {
ctk_gpu->pcie_gen_queriable = TRUE;
link_speed_str =
- get_pcie_link_speed_string(ctk_gpu->handle,
+ get_pcie_link_speed_string(ctrl_target,
NV_CTRL_GPU_PCIE_MAX_LINK_SPEED);
- link_width_str = get_pcie_link_width_string(ctk_gpu->handle,
- NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH);
+ link_width_str =
+ get_pcie_link_width_string(ctrl_target,
+ NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH);
}
/*
@@ -582,7 +583,7 @@ GtkWidget* ctk_gpu_new(
0, 0, "X Screens:",
0, 0, screens);
/* spacing */
- displays = make_display_device_list(handle);
+ displays = make_display_device_list(ctrl_target);
row += 3;
ctk_gpu->displays =
@@ -590,8 +591,8 @@ GtkWidget* ctk_gpu_new(
0, 0, "Display Devices:",
0, 0, displays);
- XFree(product_name);
- XFree(vbios_version);
+ free(product_name);
+ free(vbios_version);
g_free(video_ram);
g_free(gpu_cores);
g_free(memory_interface);
@@ -612,7 +613,7 @@ GtkWidget* ctk_gpu_new(
(gpointer) ctk_gpu);
tmp_str = g_strdup_printf("Memory Used (GPU %d)",
- NvCtrlGetTargetId(handle));
+ NvCtrlGetTargetId(ctrl_target));
ctk_config_add_timer(ctk_gpu->ctk_config,
DEFAULT_UPDATE_GPU_INFO_TIME_INTERVAL,
@@ -754,13 +755,14 @@ GtkTextBuffer *ctk_gpu_create_help(GtkTextTagTable *table,
-static void probe_displays_received(GObject *object, gpointer arg1,
+static void probe_displays_received(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
CtkGpu *ctk_object = CTK_GPU(user_data);
gchar *str;
- str = make_display_device_list(ctk_object->handle);
+ str = make_display_device_list(ctk_object->ctrl_target);
gtk_label_set_text(GTK_LABEL(ctk_object->displays), str);
@@ -778,11 +780,12 @@ static gboolean update_gpu_usage(gpointer user_data)
gchar *utilizationStr = NULL;
gint value = 0;
utilizationEntry entry;
+ CtrlTarget *ctrl_target;
ctk_gpu = CTK_GPU(user_data);
+ ctrl_target = ctk_gpu->ctrl_target;
- ret = NvCtrlGetAttribute(ctk_gpu->handle,
- NV_CTRL_USED_DEDICATED_GPU_MEMORY,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_USED_DEDICATED_GPU_MEMORY,
&value);
if (ret != NvCtrlSuccess || value > ctk_gpu->gpu_memory || value < 0) {
gtk_label_set_text(GTK_LABEL(ctk_gpu->gpu_memory_used_label), "Unknown");
@@ -802,7 +805,7 @@ static gboolean update_gpu_usage(gpointer user_data)
}
/* GPU utilization */
- ret = NvCtrlGetStringAttribute(ctk_gpu->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GPU_UTILIZATION,
&utilizationStr);
if (ret != NvCtrlSuccess) {
@@ -852,7 +855,7 @@ static gboolean update_gpu_usage(gpointer user_data)
g_free(utilization_text);
}
- XFree(utilizationStr);
+ free(utilizationStr);
return TRUE;
}
diff --git a/src/gtk+-2.x/ctkgpu.h b/src/gtk+-2.x/ctkgpu.h
index 38d96e0..57e593f 100644
--- a/src/gtk+-2.x/ctkgpu.h
+++ b/src/gtk+-2.x/ctkgpu.h
@@ -26,8 +26,6 @@
#include "ctkevent.h"
#include "ctkconfig.h"
-#include "NvCtrlAttributes.h"
-
G_BEGIN_DECLS
#define CTK_TYPE_GPU (ctk_gpu_get_type())
@@ -55,7 +53,7 @@ struct _CtkGpu
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
CtkEvent *ctk_event;
@@ -78,14 +76,12 @@ struct _CtkGpuClass
};
GType ctk_gpu_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_gpu_new (NvCtrlAttributeHandle *handle,
- CtrlHandleTarget *t,
+GtkWidget* ctk_gpu_new (CtrlTarget *ctrl_target,
CtkEvent *ctk_event,
CtkConfig *ctk_config);
-void get_bus_type_str(NvCtrlAttributeHandle *handle,
- gchar **bus);
-gchar *get_bus_id_str(NvCtrlAttributeHandle *handle);
+void get_bus_type_str(CtrlTarget *ctrl_target, gchar **bus);
+gchar *get_bus_id_str(CtrlTarget *ctrl_target);
GtkTextBuffer *ctk_gpu_create_help(GtkTextTagTable *,
CtkGpu *);
diff --git a/src/gtk+-2.x/ctkgvi.c b/src/gtk+-2.x/ctkgvi.c
index 65d5691..d30167b 100644
--- a/src/gtk+-2.x/ctkgvi.c
+++ b/src/gtk+-2.x/ctkgvi.c
@@ -128,20 +128,21 @@ typedef struct {
static void query_channel_info(CtkGvi *ctk_gvi, int jack, int channel, ChannelInfo *channel_info)
{
+ CtrlTarget *ctrl_target = ctk_gvi->ctrl_target;
gint ret;
unsigned int jack_channel = ((channel & 0xFFFF) << 16);
jack_channel |= (jack & 0xFFFF);
-
- ret = NvCtrlGetDisplayAttribute(ctk_gvi->handle,
+
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
jack_channel,
NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT,
&(channel_info->video_format));
if (ret != NvCtrlSuccess) {
channel_info->video_format = NV_CTRL_GVIO_VIDEO_FORMAT_NONE;
}
-
- ret = NvCtrlGetDisplayAttribute(ctk_gvi->handle,
+
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
jack_channel,
NV_CTRL_GVI_DETECTED_CHANNEL_COMPONENT_SAMPLING,
&(channel_info->component_sampling));
@@ -149,24 +150,24 @@ static void query_channel_info(CtkGvi *ctk_gvi, int jack, int channel, ChannelIn
channel_info->component_sampling =
NV_CTRL_GVI_COMPONENT_SAMPLING_UNKNOWN;
}
-
- ret = NvCtrlGetDisplayAttribute(ctk_gvi->handle,
+
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
jack_channel,
NV_CTRL_GVI_DETECTED_CHANNEL_COLOR_SPACE,
&(channel_info->color_space));
if (ret != NvCtrlSuccess) {
channel_info->color_space = NV_CTRL_GVI_COLOR_SPACE_UNKNOWN;
}
-
- ret = NvCtrlGetDisplayAttribute(ctk_gvi->handle,
+
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
jack_channel,
NV_CTRL_GVI_DETECTED_CHANNEL_BITS_PER_COMPONENT,
&(channel_info->bpc));
if (ret != NvCtrlSuccess) {
channel_info->bpc = NV_CTRL_GVI_BITS_PER_COMPONENT_UNKNOWN;
}
-
- ret = NvCtrlGetDisplayAttribute(ctk_gvi->handle,
+
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
jack_channel,
NV_CTRL_GVI_DETECTED_CHANNEL_LINK_ID,
&(channel_info->link_id));
@@ -174,7 +175,7 @@ static void query_channel_info(CtkGvi *ctk_gvi, int jack, int channel, ChannelIn
channel_info->link_id = NV_CTRL_GVI_LINK_ID_UNKNOWN;
}
- ret = NvCtrlGetDisplayAttribute(ctk_gvi->handle,
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
jack_channel,
NV_CTRL_GVI_DETECTED_CHANNEL_SMPTE352_IDENTIFIER,
&(channel_info->smpte352_id));
@@ -479,32 +480,40 @@ static void show_detailed_info_button_toggled(GtkWidget *button,
update_sdi_input_info(ctk_gvi);
}
-static gchar* gpu_name_string(gint gpu, CtrlHandles *handle)
+static gchar* gpu_name_string(gint gpu_id, CtrlSystem *system)
{
gchar *gpu_name;
+ CtrlTarget *ctrl_target;
+
+ ctrl_target = NvCtrlGetTarget(system, GPU_TARGET, gpu_id);
- if ((gpu < 0) || (gpu >= handle->targets[GPU_TARGET].n)) {
+ if (ctrl_target == NULL) {
gpu_name = g_strdup_printf("None");
} else {
- NvCtrlAttributeHandle *gpu_handle = handle->targets[GPU_TARGET].t[gpu].h;
- gpu_name = create_gpu_name_string(gpu_handle);
+ gpu_name = create_gpu_name_string(ctrl_target);
}
+
return gpu_name;
}
-static void bound_gpu_changed(GObject *object, gpointer arg1,
+static void bound_gpu_changed(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
CtkGvi *ctk_gvi = (CtkGvi *) user_data;
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
gchar *gpu_name;
- gpu_name = gpu_name_string(event_struct->value, ctk_gvi->ctk_config->pCtrlHandles);
-
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ gpu_name = gpu_name_string(event->int_attr.value,
+ ctk_gvi->ctk_config->pCtrlSystem);
+
gtk_label_set_label(GTK_LABEL(ctk_gvi->gpu_name), gpu_name);
}
-GtkWidget* ctk_gvi_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_gvi_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
CtkEvent *ctk_event)
{
@@ -517,18 +526,19 @@ GtkWidget* ctk_gvi_new(NvCtrlAttributeHandle *handle,
ReturnStatus ret;
gchar *firmware_version;
gchar *s;
-
- /* make sure we have a handle */
- g_return_val_if_fail(handle != NULL, NULL);
+ /* make sure we have a target */
+
+ g_return_val_if_fail((ctrl_target != NULL) &&
+ (ctrl_target->h != NULL), NULL);
/*
* get the static data that we will display below
*/
/* Firmware Version */
-
- ret = NvCtrlGetStringAttribute(handle,
+
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GVIO_FIRMWARE_VERSION,
&firmware_version);
if (ret != NvCtrlSuccess) {
@@ -537,43 +547,43 @@ GtkWidget* ctk_gvi_new(NvCtrlAttributeHandle *handle,
/* Get Bus related information */
- get_bus_type_str(handle, &bus);
- pci_bus_id = get_bus_id_str(handle);
+ get_bus_type_str(ctrl_target, &bus);
+ pci_bus_id = get_bus_id_str(ctrl_target);
/* NV_CTRL_IRQ */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_IRQ, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_IRQ, &tmp);
if (ret != NvCtrlSuccess) {
irq = NULL;
} else {
irq = g_strdup_printf("%d", tmp);
}
-
+
/* NV_CTRL_GVI_BOUND_GPU */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVI_BOUND_GPU, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVI_BOUND_GPU, &tmp);
if (ret != NvCtrlSuccess) {
tmp = -1;
}
- gpu_name = gpu_name_string(tmp, ctk_config->pCtrlHandles);
+ gpu_name = gpu_name_string(tmp, ctk_config->pCtrlSystem);
/* create the CtkGvi object */
object = g_object_new(CTK_TYPE_GVI, NULL);
-
+
ctk_gvi = CTK_GVI(object);
- ctk_gvi->handle = handle;
+ ctk_gvi->ctrl_target = ctrl_target;
ctk_gvi->ctk_config = ctk_config;
/* Query static GVI properties */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVI_NUM_JACKS,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVI_NUM_JACKS,
&(ctk_gvi->num_jacks));
if (ret != NvCtrlSuccess) {
ctk_gvi->num_jacks = 0;
}
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVI_MAX_CHANNELS_PER_JACK,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVI_MAX_CHANNELS_PER_JACK,
&(ctk_gvi->max_channels_per_jack));
if (ret != NvCtrlSuccess) {
ctk_gvi->max_channels_per_jack = 0;
@@ -674,7 +684,7 @@ GtkWidget* ctk_gvi_new(NvCtrlAttributeHandle *handle,
/* Register a timer callback to update the video format info */
s = g_strdup_printf("Graphics Video In (GVI %d)",
- NvCtrlGetTargetId(handle));
+ NvCtrlGetTargetId(ctrl_target));
ctk_config_add_timer(ctk_gvi->ctk_config,
DEFAULT_UPDATE_VIDEO_FORMAT_INFO_TIME_INTERVAL,
diff --git a/src/gtk+-2.x/ctkgvi.h b/src/gtk+-2.x/ctkgvi.h
index 3f5e5df..fba7469 100644
--- a/src/gtk+-2.x/ctkgvi.h
+++ b/src/gtk+-2.x/ctkgvi.h
@@ -20,7 +20,6 @@
#ifndef __CTK_GVI_H__
#define __CTK_GVI_H__
-#include "NvCtrlAttributes.h"
#include "ctkevent.h"
#include "ctkconfig.h"
@@ -51,7 +50,7 @@ struct _CtkGvi
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
int num_jacks;
@@ -74,8 +73,7 @@ struct _CtkGviClass
};
GType ctk_gvi_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_gvi_new (NvCtrlAttributeHandle *, CtkConfig *,
- CtkEvent *);
+GtkWidget* ctk_gvi_new (CtrlTarget *, CtkConfig *, CtkEvent *);
GtkTextBuffer* ctk_gvi_create_help (GtkTextTagTable *, CtkGvi *);
void ctk_gvi_start_timer (GtkWidget *);
diff --git a/src/gtk+-2.x/ctkgvo-banner.c b/src/gtk+-2.x/ctkgvo-banner.c
index c75a538..4a34767 100644
--- a/src/gtk+-2.x/ctkgvo-banner.c
+++ b/src/gtk+-2.x/ctkgvo-banner.c
@@ -85,7 +85,7 @@ static gboolean update_gvo_banner_led_images_shared_sync_bnc(gpointer data);
static void update_gvo_banner_led_state(CtkGvoBanner *ctk_gvo_banner);
static void gvo_event_received(GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data);
static void ctk_gvo_banner_class_init(CtkGvoBannerClass *ctk_object_class);
@@ -153,7 +153,7 @@ static void ctk_gvo_banner_finalize(GObject *object)
* ctk_gvo_banner_new() - constructor for the CtkGvoBanner widget
*/
-GtkWidget* ctk_gvo_banner_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_gvo_banner_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
CtkEvent *ctk_event)
{
@@ -162,15 +162,16 @@ GtkWidget* ctk_gvo_banner_new(NvCtrlAttributeHandle *handle,
ReturnStatus ret;
gint val;
gint caps;
-
- /* make sure we have a handle */
-
- g_return_val_if_fail(handle != NULL, NULL);
-
+
+ /* make sure we have a valid target */
+
+ g_return_val_if_fail((ctrl_target != NULL) &&
+ (ctrl_target->h != NULL), NULL);
+
/* check if this screen supports GVO */
-
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_SUPPORTED, &val);
+
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_SUPPORTED, &val);
if ((ret != NvCtrlSuccess) || (val != NV_CTRL_GVO_SUPPORTED_TRUE)) {
/* GVO not available */
return NULL;
@@ -178,7 +179,7 @@ GtkWidget* ctk_gvo_banner_new(NvCtrlAttributeHandle *handle,
/* get the GVO capabilities */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_CAPABILITIES, &caps);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_CAPABILITIES, &caps);
if (ret != NvCtrlSuccess) {
return NULL;
}
@@ -190,7 +191,7 @@ GtkWidget* ctk_gvo_banner_new(NvCtrlAttributeHandle *handle,
/* initialize fields in the CtkGvoBanner object */
ctk_gvo_banner = CTK_GVO_BANNER(object);
- ctk_gvo_banner->handle = handle;
+ ctk_gvo_banner->ctrl_target = ctrl_target;
ctk_gvo_banner->ctk_config = ctk_config;
ctk_gvo_banner->ctk_event = ctk_event;
ctk_gvo_banner->parent_box = NULL;
@@ -236,31 +237,32 @@ GtkWidget* ctk_gvo_banner_new(NvCtrlAttributeHandle *handle,
/* Get the current GVO state */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_LOCK_OWNER, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_LOCK_OWNER, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_LOCK_OWNER_NONE;
}
ctk_gvo_banner->gvo_lock_owner = val;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_SYNC_MODE, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_SYNC_MODE, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_SYNC_MODE_FREE_RUNNING;
}
ctk_gvo_banner->sync_mode = val;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_SYNC_SOURCE, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_SYNC_SOURCE, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_SYNC_SOURCE_COMPOSITE;
}
ctk_gvo_banner->sync_source = val;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT, &val);
+ ret = NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVIO_VIDEO_FORMAT_NONE;
}
ctk_gvo_banner->output_video_format = val;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_DATA_FORMAT, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_DATA_FORMAT, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_YCRCB444;
}
@@ -715,6 +717,7 @@ gint ctk_gvo_banner_probe(gpointer data)
ReturnStatus ret;
gint val;
CtkGvoBanner *ctk_gvo_banner = CTK_GVO_BANNER(data);
+ CtrlTarget *ctrl_target = ctk_gvo_banner->ctrl_target;
// XXX We could get notified of these (sync source/mode) and
@@ -725,8 +728,7 @@ gint ctk_gvo_banner_probe(gpointer data)
/* query NV_CTRL_GVO_SYNC_MODE */
- ret = NvCtrlGetAttribute(ctk_gvo_banner->handle,
- NV_CTRL_GVO_SYNC_MODE, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_SYNC_MODE, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_SYNC_MODE_FREE_RUNNING;
@@ -737,8 +739,7 @@ gint ctk_gvo_banner_probe(gpointer data)
/* query NV_CTRL_GVO_SYNC_SOURCE */
- ret = NvCtrlGetAttribute(ctk_gvo_banner->handle,
- NV_CTRL_GVO_SYNC_SOURCE, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_SYNC_SOURCE, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_SYNC_SOURCE_COMPOSITE;
@@ -748,22 +749,22 @@ gint ctk_gvo_banner_probe(gpointer data)
/* query NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT */
-
- ret = NvCtrlGetAttribute(ctk_gvo_banner->handle,
+
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT, &val);
-
+
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVIO_VIDEO_FORMAT_NONE;
}
-
+
ctk_gvo_banner->input_video_format = val;
/* query COMPOSITE_SYNC_INPUT_DETECTED */
- ret = NvCtrlGetAttribute(ctk_gvo_banner->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED, &val);
-
+
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED_FALSE;
}
@@ -773,9 +774,9 @@ gint ctk_gvo_banner_probe(gpointer data)
/* query SDI_SYNC_INPUT_DETECTED */
- ret = NvCtrlGetAttribute(ctk_gvo_banner->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED, &val);
-
+
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_NONE;
}
@@ -785,9 +786,9 @@ gint ctk_gvo_banner_probe(gpointer data)
/* query SYNC_LOCK_STATUS */
- ret = NvCtrlGetAttribute(ctk_gvo_banner->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVO_SYNC_LOCK_STATUS, &val);
-
+
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_SYNC_LOCK_STATUS_UNLOCKED;
}
@@ -818,15 +819,19 @@ gint ctk_gvo_banner_probe(gpointer data)
*/
static void gvo_event_received(GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkGvoBanner *ctk_gvo_banner = CTK_GVO_BANNER(user_data);
- gint attribute = event_struct->attribute;
- gint value = event_struct->value;
+ gint value;
+
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ value = event->int_attr.value;
- switch (attribute) {
+ switch (event->int_attr.attribute) {
case NV_CTRL_GVO_SYNC_MODE:
ctk_gvo_banner->sync_mode = value;
break;
diff --git a/src/gtk+-2.x/ctkgvo-banner.h b/src/gtk+-2.x/ctkgvo-banner.h
index f46cd1c..86a7b47 100644
--- a/src/gtk+-2.x/ctkgvo-banner.h
+++ b/src/gtk+-2.x/ctkgvo-banner.h
@@ -20,7 +20,6 @@
#ifndef __CTK_GVO_BANNER_H__
#define __CTK_GVO_BANNER_H__
-#include "NvCtrlAttributes.h"
#include "ctkconfig.h"
#include "ctkevent.h"
@@ -60,7 +59,7 @@ struct _CtkGvoBanner
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
GtkWidget *parent_box;
CtkConfig *ctk_config;
CtkEvent *ctk_event;
@@ -96,7 +95,7 @@ struct _CtkGvoBannerClass
GType ctk_gvo_banner_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_gvo_banner_new (NvCtrlAttributeHandle *, CtkConfig *,
+GtkWidget* ctk_gvo_banner_new (CtrlTarget *, CtkConfig *,
CtkEvent *);
gint ctk_gvo_banner_probe(gpointer data);
diff --git a/src/gtk+-2.x/ctkgvo-csc.c b/src/gtk+-2.x/ctkgvo-csc.c
index 59779ca..1faf68b 100644
--- a/src/gtk+-2.x/ctkgvo-csc.c
+++ b/src/gtk+-2.x/ctkgvo-csc.c
@@ -106,7 +106,7 @@ static void set_apply_button_sensitive (CtkGvoCsc *ctk_gvo_csc);
static void apply_csc_values (CtkGvoCsc *ctk_gvo_csc);
static void gvo_csc_event_received (GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data);
static GtkWidget *build_opengl_only_msg (void);
@@ -185,7 +185,7 @@ GType ctk_gvo_csc_get_type(void)
* ctk_gvo_csc_new() - create a CtkGvoCsc widget
*/
-GtkWidget* ctk_gvo_csc_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_gvo_csc_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
CtkEvent *ctk_event,
CtkGvo *gvo_parent)
@@ -205,21 +205,22 @@ GtkWidget* ctk_gvo_csc_new(NvCtrlAttributeHandle *handle,
float initialCSCMatrix[3][3];
float initialCSCOffset[3];
float initialCSCScale[3];
-
+
/* retrieve all the NV-CONTROL attributes that we will need */
-
- ret = NvCtrlGetGvoColorConversion(handle,
+
+ ret = NvCtrlGetGvoColorConversion(ctrl_target,
initialCSCMatrix,
initialCSCOffset,
initialCSCScale);
-
+
if (ret != NvCtrlSuccess) return NULL;
-
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_OVERRIDE_HW_CSC, &override);
+
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_OVERRIDE_HW_CSC,
+ &override);
if (ret != NvCtrlSuccess) return NULL;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_CAPABILITIES, &caps);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_CAPABILITIES, &caps);
if (ret != NvCtrlSuccess) return NULL;
@@ -228,14 +229,14 @@ GtkWidget* ctk_gvo_csc_new(NvCtrlAttributeHandle *handle,
* XXX setup to receive events when another NV-CONTROL client
* changes any of the above attributes
*/
-
-
+
+
/* create the object */
-
+
object = g_object_new(CTK_TYPE_GVO_CSC, NULL);
-
+
ctk_gvo_csc = CTK_GVO_CSC(object);
- ctk_gvo_csc->handle = handle;
+ ctk_gvo_csc->ctrl_target = ctrl_target;
ctk_gvo_csc->ctk_config = ctk_config;
ctk_gvo_csc->ctk_event = ctk_event;
ctk_gvo_csc->gvo_parent = gvo_parent;
@@ -684,6 +685,7 @@ static void override_button_toggled(GtkToggleButton *overrideButton,
gpointer user_data)
{
CtkGvoCsc *ctk_gvo_csc = (CtkGvoCsc *) user_data;
+ CtrlTarget *ctrl_target = ctk_gvo_csc->ctrl_target;
gboolean enabled = gtk_toggle_button_get_active(overrideButton);
override_state_toggled(ctk_gvo_csc, enabled);
@@ -693,26 +695,26 @@ static void override_button_toggled(GtkToggleButton *overrideButton,
* user applies it. However, if override was disabled, apply that
* immediately.
*/
-
+
if (enabled) {
-
+
if (ctk_gvo_csc->applyImmediately) {
- NvCtrlSetAttribute(ctk_gvo_csc->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GVO_OVERRIDE_HW_CSC,
NV_CTRL_GVO_OVERRIDE_HW_CSC_TRUE);
} else {
-
+
// make the "Apply" button hot
-
+
gtk_widget_set_sensitive(ctk_gvo_csc->applyButton, TRUE);
}
} else {
- NvCtrlSetAttribute(ctk_gvo_csc->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GVO_OVERRIDE_HW_CSC,
NV_CTRL_GVO_OVERRIDE_HW_CSC_FALSE);
}
-
+
} /* override_button_toggled() */
@@ -1000,12 +1002,14 @@ static void set_apply_button_sensitive(CtkGvoCsc *ctk_gvo_csc)
static void apply_csc_values(CtkGvoCsc *ctk_gvo_csc)
{
- NvCtrlSetGvoColorConversion(ctk_gvo_csc->handle,
+ CtrlTarget *ctrl_target = ctk_gvo_csc->ctrl_target;
+
+ NvCtrlSetGvoColorConversion(ctrl_target,
ctk_gvo_csc->matrix,
ctk_gvo_csc->offset,
ctk_gvo_csc->scale);
-
- NvCtrlSetAttribute(ctk_gvo_csc->handle,
+
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GVO_OVERRIDE_HW_CSC,
NV_CTRL_GVO_OVERRIDE_HW_CSC_TRUE);
@@ -1018,14 +1022,14 @@ static void apply_csc_values(CtkGvoCsc *ctk_gvo_csc)
*/
static void gvo_csc_event_received(GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkGvoCsc *ctk_gvo_csc = CTK_GVO_CSC(user_data);
+ CtrlTarget *ctrl_target = ctk_gvo_csc->ctrl_target;
GtkWidget *widget;
- gint attribute = event_struct->attribute;
- gint value = event_struct->value;
+ gint attribute;
+ gint value;
ReturnStatus ret;
float newCSCMatrix[3][3];
@@ -1033,6 +1037,12 @@ static void gvo_csc_event_received(GObject *object,
float newCSCScale[3];
int row, column;
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ attribute = event->int_attr.attribute;
+ value = event->int_attr.value;
switch (attribute) {
@@ -1040,7 +1050,7 @@ static void gvo_csc_event_received(GObject *object,
/* Re-query the GVO CSC matrix */
- ret = NvCtrlGetGvoColorConversion(ctk_gvo_csc->handle,
+ ret = NvCtrlGetGvoColorConversion(ctrl_target,
newCSCMatrix,
newCSCOffset,
newCSCScale);
diff --git a/src/gtk+-2.x/ctkgvo-csc.h b/src/gtk+-2.x/ctkgvo-csc.h
index bd392a0..d2cbe77 100644
--- a/src/gtk+-2.x/ctkgvo-csc.h
+++ b/src/gtk+-2.x/ctkgvo-csc.h
@@ -55,7 +55,7 @@ struct _CtkGvoCsc
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
CtkEvent *ctk_event;
@@ -92,8 +92,8 @@ struct _CtkGvoCscClass
};
GType ctk_gvo_csc_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_gvo_csc_new (NvCtrlAttributeHandle *,
- CtkConfig *, CtkEvent *, CtkGvo *);
+GtkWidget* ctk_gvo_csc_new (CtrlTarget *, CtkConfig *, CtkEvent *,
+ CtkGvo *);
GtkTextBuffer *ctk_gvo_csc_create_help(GtkTextTagTable *, CtkGvoCsc *);
diff --git a/src/gtk+-2.x/ctkgvo-sync.c b/src/gtk+-2.x/ctkgvo-sync.c
index 6a6609d..125ad39 100644
--- a/src/gtk+-2.x/ctkgvo-sync.c
+++ b/src/gtk+-2.x/ctkgvo-sync.c
@@ -93,8 +93,7 @@ static void hsync_delay_changed(GtkSpinButton *spinbutton, gpointer user_data);
static void vsync_delay_changed(GtkSpinButton *spinbutton, gpointer user_data);
-static void gvo_sync_event_received(GObject *object,
- gpointer arg1,
+static void gvo_sync_event_received(GObject *object, CtrlEvent *event,
gpointer user_data);
static gint gvo_sync_probe_callback(gpointer data);
@@ -315,7 +314,7 @@ static void update_sync_lock_status_text(CtkGvoSync *ctk_gvo_sync)
* ctk_gvo_sync_new() - create a CtkGvoSync widget
*/
-GtkWidget* ctk_gvo_sync_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_gvo_sync_new(CtrlTarget *ctrl_target,
GtkWidget *parent_window,
CtkConfig *ctk_config,
CtkEvent *ctk_event,
@@ -337,23 +336,23 @@ GtkWidget* ctk_gvo_sync_new(NvCtrlAttributeHandle *handle,
gint row;
const char *help_text;
-
- /* make sure we have a handle */
-
- g_return_val_if_fail(handle != NULL, NULL);
-
+ /* make sure we have a valid target */
+
+ g_return_val_if_fail((ctrl_target != NULL) &&
+ (ctrl_target->h != NULL), NULL);
+
/* create and initialize the object */
object = g_object_new(CTK_TYPE_GVO_SYNC, NULL);
-
+
ctk_gvo_sync = CTK_GVO_SYNC(object);
- ctk_gvo_sync->handle = handle;
+ ctk_gvo_sync->ctrl_target = ctrl_target;
ctk_gvo_sync->parent_window = parent_window;
ctk_gvo_sync->ctk_config = ctk_config;
ctk_gvo_sync->ctk_event = ctk_event;
ctk_gvo_sync->gvo_parent = gvo_parent;
-
+
/* Query the current GVO state */
if ( !query_init_gvo_sync_state(ctk_gvo_sync) ) {
@@ -550,11 +549,13 @@ GtkWidget* ctk_gvo_sync_new(NvCtrlAttributeHandle *handle,
/* NV_CTRL_GVO_SYNC_DELAY_PIXELS */
- ret = NvCtrlGetValidAttributeValues(handle, NV_CTRL_GVO_SYNC_DELAY_PIXELS,
+ ret = NvCtrlGetValidAttributeValues(ctrl_target,
+ NV_CTRL_GVO_SYNC_DELAY_PIXELS,
&valid);
if ((ret == NvCtrlSuccess) && (valid.type == ATTRIBUTE_TYPE_RANGE)) {
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_SYNC_DELAY_PIXELS, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_SYNC_DELAY_PIXELS,
+ &val);
if (ret != NvCtrlSuccess) val = 0;
if (ctk_gvo_sync->caps & NV_CTRL_GVO_CAPABILITIES_ADVANCE_SYNC_SKEW) {
@@ -602,12 +603,14 @@ GtkWidget* ctk_gvo_sync_new(NvCtrlAttributeHandle *handle,
}
/* NV_CTRL_GVO_SYNC_DELAY_LINES */
-
- ret = NvCtrlGetValidAttributeValues(handle, NV_CTRL_GVO_SYNC_DELAY_LINES,
+
+ ret = NvCtrlGetValidAttributeValues(ctrl_target,
+ NV_CTRL_GVO_SYNC_DELAY_LINES,
&valid);
if ((ret == NvCtrlSuccess) && (valid.type == ATTRIBUTE_TYPE_RANGE)) {
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_SYNC_DELAY_LINES, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_SYNC_DELAY_LINES,
+ &val);
if (ret != NvCtrlSuccess) val = 0;
if (ctk_gvo_sync->caps & NV_CTRL_GVO_CAPABILITIES_ADVANCE_SYNC_SKEW) {
@@ -727,13 +730,14 @@ static void finish_menu(GtkWidget *menu, GtkWidget *table, const gint row)
static gboolean query_init_gvo_sync_state(CtkGvoSync *ctk_gvo_sync)
{
+ CtrlTarget *ctrl_target = ctk_gvo_sync->ctrl_target;
gint val;
ReturnStatus ret;
/* Check if this screen supports GVO */
-
- ret = NvCtrlGetAttribute(ctk_gvo_sync->handle, NV_CTRL_GVO_SUPPORTED,
+
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_SUPPORTED,
&val);
if ((ret != NvCtrlSuccess) || (val != NV_CTRL_GVO_SUPPORTED_TRUE)) {
/* GVO not available */
@@ -741,15 +745,15 @@ static gboolean query_init_gvo_sync_state(CtkGvoSync *ctk_gvo_sync)
}
/* Get this GVO device's capabilities */
-
- ret = NvCtrlGetAttribute(ctk_gvo_sync->handle, NV_CTRL_GVO_CAPABILITIES,
+
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_CAPABILITIES,
&val);
if (ret != NvCtrlSuccess) return FALSE;
ctk_gvo_sync->caps = val;
/* Query the current input video formats */
- ret = NvCtrlGetAttribute(ctk_gvo_sync->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVIO_VIDEO_FORMAT_NONE;
@@ -758,7 +762,7 @@ static gboolean query_init_gvo_sync_state(CtkGvoSync *ctk_gvo_sync)
/* Query the sync mode */
- ret = NvCtrlGetAttribute(ctk_gvo_sync->handle, NV_CTRL_GVO_SYNC_MODE,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_SYNC_MODE,
&val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_SYNC_MODE_FREE_RUNNING;
@@ -767,7 +771,7 @@ static gboolean query_init_gvo_sync_state(CtkGvoSync *ctk_gvo_sync)
/* query COMPOSITE_SYNC_INPUT_DETECTED */
- ret = NvCtrlGetAttribute(ctk_gvo_sync->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED_FALSE;
@@ -776,17 +780,17 @@ static gboolean query_init_gvo_sync_state(CtkGvoSync *ctk_gvo_sync)
/* query COMPOSITE_SYNC_INPUT_DETECT_MODE */
- ret = NvCtrlGetAttribute(ctk_gvo_sync->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE,
&val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE_AUTO;
}
ctk_gvo_sync->comp_mode = val;
-
+
/* query SDI_SYNC_INPUT_DETECTED */
- ret = NvCtrlGetAttribute(ctk_gvo_sync->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_NONE;
@@ -795,7 +799,7 @@ static gboolean query_init_gvo_sync_state(CtkGvoSync *ctk_gvo_sync)
/* query sync source */
- ret = NvCtrlGetAttribute(ctk_gvo_sync->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVO_SYNC_SOURCE,
&val);
if (ret != NvCtrlSuccess) {
@@ -805,7 +809,7 @@ static gboolean query_init_gvo_sync_state(CtkGvoSync *ctk_gvo_sync)
/* Query framelock/genlock status */
- ret = NvCtrlGetAttribute(ctk_gvo_sync->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVO_SYNC_LOCK_STATUS,
&val);
if (ret != NvCtrlSuccess) {
@@ -826,17 +830,18 @@ static gboolean query_init_gvo_sync_state(CtkGvoSync *ctk_gvo_sync)
static void init_composite_termination(CtkGvoSync *ctk_gvo_sync)
{
+ CtrlTarget *ctrl_target = ctk_gvo_sync->ctrl_target;
ReturnStatus ret;
gint val;
if (!ctk_gvo_sync->composite_termination_button) return;
- ret = NvCtrlGetAttribute(ctk_gvo_sync->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVO_COMPOSITE_TERMINATION, &val);
if (ret != NvCtrlSuccess) {
val = NV_CTRL_GVO_COMPOSITE_TERMINATION_DISABLE;
}
-
+
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON(ctk_gvo_sync->composite_termination_button),
val == NV_CTRL_GVO_COMPOSITE_TERMINATION_ENABLE);
@@ -1050,6 +1055,7 @@ static void post_sync_format_menu_changed(CtkGvoSync *ctk_gvo_sync)
static void detect_input_toggled(GtkToggleButton *togglebutton,
CtkGvoSync *ctk_gvo_sync)
{
+ CtrlTarget *ctrl_target = ctk_gvo_sync->ctrl_target;
gboolean enabled;
enabled = gtk_toggle_button_get_active(togglebutton);
@@ -1072,10 +1078,10 @@ static void detect_input_toggled(GtkToggleButton *togglebutton,
/* enable REACQUIRE */
- NvCtrlSetAttribute(ctk_gvo_sync->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE,
NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE_TRUE);
-
+
/* update the statusbar */
ctk_config_statusbar_message(ctk_gvo_sync->ctk_config,
@@ -1098,13 +1104,14 @@ static void detect_input_toggled(GtkToggleButton *togglebutton,
static gint detect_input_done(gpointer data)
{
CtkGvoSync *ctk_gvo_sync = CTK_GVO_SYNC(data);
-
+ CtrlTarget *ctrl_target = ctk_gvo_sync->ctrl_target;
+
/* disable REACQUIRE */
- NvCtrlSetAttribute(ctk_gvo_sync->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE,
NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE_FALSE);
-
+
/* reprobe */
ctk_gvo_banner_probe((gpointer)(ctk_gvo_sync->gvo_parent->banner));
@@ -1156,11 +1163,12 @@ static gint detect_input_done(gpointer data)
static void composite_termination_toggled(GtkWidget *button,
CtkGvoSync *ctk_gvo_sync)
{
+ CtrlTarget *ctrl_target = ctk_gvo_sync->ctrl_target;
gboolean enabled;
-
+
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
- NvCtrlSetAttribute(ctk_gvo_sync->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GVO_COMPOSITE_TERMINATION,
(enabled ? NV_CTRL_GVO_COMPOSITE_TERMINATION_ENABLE :
NV_CTRL_GVO_COMPOSITE_TERMINATION_DISABLE));
@@ -1179,14 +1187,15 @@ static void composite_termination_toggled(GtkWidget *button,
static void sync_mode_changed(CtkDropDownMenu *menu, gpointer user_data)
{
CtkGvoSync *ctk_gvo_sync = CTK_GVO_SYNC(user_data);
+ CtrlTarget *ctrl_target = ctk_gvo_sync->ctrl_target;
gint value;
value = ctk_drop_down_menu_get_current_value(menu);
- NvCtrlSetAttribute(ctk_gvo_sync->handle, NV_CTRL_GVO_SYNC_MODE, value);
-
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_GVO_SYNC_MODE, value);
+
if (value != NV_CTRL_GVO_SYNC_MODE_FREE_RUNNING) {
- NvCtrlSetAttribute(ctk_gvo_sync->handle, NV_CTRL_GVO_SYNC_SOURCE,
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_GVO_SYNC_SOURCE,
ctk_gvo_sync->sync_source);
}
@@ -1206,10 +1215,11 @@ static void sync_mode_changed(CtkDropDownMenu *menu, gpointer user_data)
static void sync_format_changed(CtkDropDownMenu *menu, gpointer user_data)
{
CtkGvoSync *ctk_gvo_sync = CTK_GVO_SYNC(user_data);
+ CtrlTarget *ctrl_target = ctk_gvo_sync->ctrl_target;
gint value, sync_source, comp_mode;
value = ctk_drop_down_menu_get_current_value(menu);
-
+
switch (value) {
case SYNC_FORMAT_SDI:
sync_source = NV_CTRL_GVO_SYNC_SOURCE_SDI;
@@ -1234,15 +1244,15 @@ static void sync_format_changed(CtkDropDownMenu *menu, gpointer user_data)
ctk_gvo_sync->sync_source = sync_source;
ctk_gvo_sync->comp_mode = comp_mode;
- NvCtrlSetAttribute(ctk_gvo_sync->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GVO_SYNC_SOURCE, sync_source);
- NvCtrlSetAttribute(ctk_gvo_sync->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE,
comp_mode);
post_sync_format_menu_changed(ctk_gvo_sync);
-
+
} /* sync_format_changed() */
@@ -1255,13 +1265,13 @@ static void sync_format_changed(CtkDropDownMenu *menu, gpointer user_data)
static void hsync_delay_changed(GtkSpinButton *spinbutton, gpointer user_data)
{
CtkGvoSync *ctk_gvo_sync = CTK_GVO_SYNC(user_data);
+ CtrlTarget *ctrl_target = ctk_gvo_sync->ctrl_target;
gint val;
-
+
val = gtk_spin_button_get_value(spinbutton);
-
- NvCtrlSetAttribute(ctk_gvo_sync->handle, NV_CTRL_GVO_SYNC_DELAY_PIXELS,
- val);
-
+
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_GVO_SYNC_DELAY_PIXELS, val);
+
} /* hsync_delay_changed() */
@@ -1274,13 +1284,13 @@ static void hsync_delay_changed(GtkSpinButton *spinbutton, gpointer user_data)
static void vsync_delay_changed(GtkSpinButton *spinbutton, gpointer user_data)
{
CtkGvoSync *ctk_gvo_sync = CTK_GVO_SYNC(user_data);
+ CtrlTarget *ctrl_target = ctk_gvo_sync->ctrl_target;
gint val;
-
+
val = gtk_spin_button_get_value(spinbutton);
-
- NvCtrlSetAttribute(ctk_gvo_sync->handle, NV_CTRL_GVO_SYNC_DELAY_LINES,
- val);
-
+
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_GVO_SYNC_DELAY_LINES, val);
+
} /* vsync_delay_changed() */
@@ -1294,17 +1304,21 @@ static void vsync_delay_changed(GtkSpinButton *spinbutton, gpointer user_data)
*/
static void gvo_sync_event_received(GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkGvoSync *ctk_gvo_sync = CTK_GVO_SYNC(user_data);
GtkWidget *widget;
- gint attribute = event_struct->attribute;
- gint value = event_struct->value;
+ gint value;
gboolean update_sync_format = FALSE;
- switch (attribute) {
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ value = event->int_attr.value;
+
+ switch (event->int_attr.attribute) {
case NV_CTRL_GVO_SYNC_MODE:
ctk_gvo_sync->sync_mode = value;
widget = ctk_gvo_sync->sync_mode_menu;
diff --git a/src/gtk+-2.x/ctkgvo-sync.h b/src/gtk+-2.x/ctkgvo-sync.h
index 1850e34..4eefb13 100644
--- a/src/gtk+-2.x/ctkgvo-sync.h
+++ b/src/gtk+-2.x/ctkgvo-sync.h
@@ -56,7 +56,7 @@ struct _CtkGvoSync
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
GtkWidget *parent_window;
CtkConfig *ctk_config;
CtkEvent *ctk_event;
@@ -102,8 +102,8 @@ struct _CtkGvoSyncClass
GType ctk_gvo_sync_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_gvo_sync_new (NvCtrlAttributeHandle *, GtkWidget *,
- CtkConfig *, CtkEvent *, CtkGvo *);
+GtkWidget* ctk_gvo_sync_new (CtrlTarget *, GtkWidget *, CtkConfig *,
+ CtkEvent *, CtkGvo *);
GtkTextBuffer* ctk_gvo_sync_create_help(GtkTextTagTable *, CtkGvoSync *);
diff --git a/src/gtk+-2.x/ctkgvo.c b/src/gtk+-2.x/ctkgvo.c
index 239a38f..02f0e7c 100644
--- a/src/gtk+-2.x/ctkgvo.c
+++ b/src/gtk+-2.x/ctkgvo.c
@@ -70,7 +70,7 @@ static void register_for_gvo_events(CtkGvo *ctk_gvo, CtkEvent *ctk_event);
static void update_gvo_current_info(CtkGvo *ctk_gvo);
static void gvo_event_received(GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data);
/*
@@ -355,7 +355,7 @@ GType ctk_gvo_get_type(void)
* ctk_gvo_new() - constructor for the CtkGvo widget
*/
-GtkWidget* ctk_gvo_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_gvo_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
CtkEvent *ctk_event)
{
@@ -365,27 +365,28 @@ GtkWidget* ctk_gvo_new(NvCtrlAttributeHandle *handle,
ReturnStatus ret;
gchar scratch[64], *firmware, *string;
gint val;
-
+
GtkWidget *frame, *table;
-
- /* make sure we have a handle */
-
- g_return_val_if_fail(handle != NULL, NULL);
+
+ /* make sure we have a valid target */
+
+ g_return_val_if_fail((ctrl_target != NULL) &&
+ (ctrl_target->h != NULL), NULL);
/* Check if this screen supports GVO */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_SUPPORTED, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_SUPPORTED, &val);
if ((ret != NvCtrlSuccess) || (val != NV_CTRL_GVO_SUPPORTED_TRUE)) {
/* GVO not available */
return NULL;
}
/* create and initialize the object */
-
+
object = g_object_new(CTK_TYPE_GVO, NULL);
-
+
ctk_gvo = CTK_GVO(object);
- ctk_gvo->handle = handle;
+ ctk_gvo->ctrl_target = ctrl_target;
/*
* Query the validness, width, height and refresh rate for each
@@ -405,7 +406,7 @@ GtkWidget* ctk_gvo_new(NvCtrlAttributeHandle *handle,
ctk_gvo->banner_box = hbox;
- ctk_gvo->banner = ctk_gvo_banner_new(handle, ctk_config, ctk_event);
+ ctk_gvo->banner = ctk_gvo_banner_new(ctrl_target, ctk_config, ctk_event);
g_object_ref(ctk_gvo->banner);
/*
@@ -428,7 +429,7 @@ GtkWidget* ctk_gvo_new(NvCtrlAttributeHandle *handle,
string = NULL;
- ret = NvCtrlGetStringAttribute(handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GVIO_FIRMWARE_VERSION,
&string);
@@ -441,9 +442,9 @@ GtkWidget* ctk_gvo_new(NvCtrlAttributeHandle *handle,
* older X servers may not know about it; fallback to
* NV_CTRL_GVO_FIRMWARE_VERSION
*/
-
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GVO_FIRMWARE_VERSION, &val);
-
+
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GVO_FIRMWARE_VERSION, &val);
+
if (ret == NvCtrlSuccess) {
snprintf(scratch, 64, "1.%02d", val);
firmware = strdup(scratch);
@@ -521,13 +522,14 @@ GtkWidget* ctk_gvo_new(NvCtrlAttributeHandle *handle,
static void query_video_format_details(CtkGvo *ctk_gvo)
{
+ CtrlTarget *ctrl_target = ctk_gvo->ctrl_target;
ReturnStatus ret;
NVCTRLAttributeValidValuesRec valid;
gint i, val;
/* Valid output video formats */
- ret = NvCtrlGetValidAttributeValues(ctk_gvo->handle,
+ ret = NvCtrlGetValidAttributeValues(ctrl_target,
NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT,
&valid);
if ((ret != NvCtrlSuccess) || (valid.type != ATTRIBUTE_TYPE_INT_BITS)) {
@@ -536,7 +538,7 @@ static void query_video_format_details(CtkGvo *ctk_gvo)
ctk_gvo->valid_output_video_format_mask[0] = valid.u.bits.ints;
}
- ret = NvCtrlGetValidAttributeValues(ctk_gvo->handle,
+ ret = NvCtrlGetValidAttributeValues(ctrl_target,
NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2,
&valid);
@@ -546,7 +548,7 @@ static void query_video_format_details(CtkGvo *ctk_gvo)
ctk_gvo->valid_output_video_format_mask[1] = valid.u.bits.ints;
}
- ret = NvCtrlGetValidAttributeValues(ctk_gvo->handle,
+ ret = NvCtrlGetValidAttributeValues(ctrl_target,
NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3,
&valid);
@@ -557,32 +559,32 @@ static void query_video_format_details(CtkGvo *ctk_gvo)
}
for (i = 0; videoFormatDetails[i].format != -1; i++) {
-
- ret = NvCtrlGetDisplayAttribute(ctk_gvo->handle,
+
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
videoFormatDetails[i].format,
NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE,
&val);
-
+
if (ret != NvCtrlSuccess) val = 0;
-
+
videoFormatDetails[i].rate = val;
-
- ret = NvCtrlGetDisplayAttribute(ctk_gvo->handle,
+
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
videoFormatDetails[i].format,
NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH,
&val);
-
+
if (ret != NvCtrlSuccess) val = 0;
-
+
videoFormatDetails[i].width = val;
-
- ret = NvCtrlGetDisplayAttribute(ctk_gvo->handle,
+
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
videoFormatDetails[i].format,
NV_CTRL_GVIO_VIDEO_FORMAT_HEIGHT,
&val);
-
+
if (ret != NvCtrlSuccess) val = 0;
-
+
videoFormatDetails[i].height = val;
}
@@ -625,6 +627,7 @@ static void register_for_gvo_events(CtkGvo *ctk_gvo, CtkEvent *ctk_event)
static void update_gvo_current_info(CtkGvo *ctk_gvo)
{
+ CtrlTarget *ctrl_target = ctk_gvo->ctrl_target;
int width;
int height;
ReturnStatus ret;
@@ -633,21 +636,21 @@ static void update_gvo_current_info(CtkGvo *ctk_gvo)
int output_data_format;
int lock_owner;
- ret = NvCtrlGetAttribute(ctk_gvo->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT,
&output_video_format);
if (ret != NvCtrlSuccess) {
output_video_format = NV_CTRL_GVIO_VIDEO_FORMAT_NONE;
}
- ret = NvCtrlGetAttribute(ctk_gvo->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVO_DATA_FORMAT,
&output_data_format);
if (ret != NvCtrlSuccess) {
output_data_format = -1;
}
- ret = NvCtrlGetAttribute(ctk_gvo->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GVO_LOCK_OWNER,
&lock_owner);
if (ret != NvCtrlSuccess) {
@@ -714,7 +717,7 @@ static void update_gvo_current_info(CtkGvo *ctk_gvo)
*/
static void gvo_event_received(GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data)
{
update_gvo_current_info(CTK_GVO(user_data));
diff --git a/src/gtk+-2.x/ctkgvo.h b/src/gtk+-2.x/ctkgvo.h
index a5a073c..807777e 100644
--- a/src/gtk+-2.x/ctkgvo.h
+++ b/src/gtk+-2.x/ctkgvo.h
@@ -20,7 +20,6 @@
#ifndef __CTK_GVO_H__
#define __CTK_GVO_H__
-#include "NvCtrlAttributes.h"
#include "ctkconfig.h"
#include "ctkevent.h"
#include "ctkgvo-banner.h"
@@ -54,7 +53,7 @@ typedef struct _CtkGvoClass CtkGvoClass;
struct _CtkGvo
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
/* State */
@@ -93,8 +92,7 @@ typedef struct {
GType ctk_gvo_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_gvo_new (NvCtrlAttributeHandle *,
- CtkConfig *, CtkEvent *);
+GtkWidget* ctk_gvo_new (CtrlTarget *, CtkConfig *, CtkEvent *);
void ctk_gvo_select (GtkWidget *);
void ctk_gvo_unselect (GtkWidget *);
GtkTextBuffer* ctk_gvo_create_help (GtkTextTagTable *);
diff --git a/src/gtk+-2.x/ctkimagesliders.c b/src/gtk+-2.x/ctkimagesliders.c
index 85dfe75..50e64c2 100644
--- a/src/gtk+-2.x/ctkimagesliders.c
+++ b/src/gtk+-2.x/ctkimagesliders.c
@@ -56,7 +56,7 @@ static void setup_reset_button(CtkImageSliders *ctk_image_sliders);
static void scale_value_changed(GtkAdjustment *adjustment,
gpointer user_data);
-static void scale_value_received(GObject *, gpointer arg1, gpointer);
+static void scale_value_received(GObject *, CtrlEvent *, gpointer);
GType ctk_image_sliders_get_type(void)
@@ -109,7 +109,7 @@ static void ctk_image_sliders_finalize(
-GtkWidget* ctk_image_sliders_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_image_sliders_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config, CtkEvent *ctk_event,
GtkWidget *reset_button,
char *name)
@@ -132,7 +132,7 @@ GtkWidget* ctk_image_sliders_new(NvCtrlAttributeHandle *handle,
if (!object) return NULL;
ctk_image_sliders = CTK_IMAGE_SLIDERS(object);
- ctk_image_sliders->handle = handle;
+ ctk_image_sliders->ctrl_target = ctrl_target;
ctk_image_sliders->ctk_config = ctk_config;
ctk_image_sliders->ctk_event = ctk_event;
ctk_image_sliders->reset_button = reset_button;
@@ -166,7 +166,7 @@ GtkWidget* ctk_image_sliders_new(NvCtrlAttributeHandle *handle,
/* Image Sharpening */
- status = NvCtrlGetAttribute(ctk_image_sliders->handle,
+ status = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_IMAGE_SHARPENING_DEFAULT,
&val);
if (status != NvCtrlSuccess) {
@@ -272,22 +272,21 @@ static void post_scale_value_changed(GtkAdjustment *adjustment,
static void scale_value_changed(GtkAdjustment *adjustment,
gpointer user_data)
{
- CtkImageSliders *ctk_image_sliders =
- CTK_IMAGE_SLIDERS(user_data);
-
+ CtkImageSliders *ctk_image_sliders = CTK_IMAGE_SLIDERS(user_data);
+ CtrlTarget *ctrl_target = ctk_image_sliders->ctrl_target;
+
gint value;
gint attribute;
-
+
value = (gint) gtk_adjustment_get_value(adjustment);
-
+
user_data = g_object_get_data(G_OBJECT(adjustment), "attribute");
attribute = GPOINTER_TO_INT(user_data);
- NvCtrlSetAttribute(ctk_image_sliders->handle,
- attribute, (int) value);
+ NvCtrlSetAttribute(ctrl_target, attribute, (int) value);
post_scale_value_changed(adjustment, ctk_image_sliders, value);
-
+
} /* scale_value_changed() */
@@ -298,19 +297,20 @@ static void scale_value_changed(GtkAdjustment *adjustment,
void ctk_image_sliders_reset(CtkImageSliders *ctk_image_sliders)
{
+ CtrlTarget *ctrl_target;
GtkAdjustment *adj;
gint val;
if (!ctk_image_sliders) return;
+ ctrl_target = ctk_image_sliders->ctrl_target;
+
if (ctk_widget_get_sensitive(ctk_image_sliders->digital_vibrance)) {
adj = CTK_SCALE(ctk_image_sliders->digital_vibrance)->gtk_adjustment;
val = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(adj),
"attribute default value"));
- NvCtrlSetAttribute(ctk_image_sliders->handle,
- NV_CTRL_DIGITAL_VIBRANCE,
- val);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_DIGITAL_VIBRANCE, val);
}
if (ctk_widget_get_sensitive(ctk_image_sliders->image_sharpening)) {
@@ -318,9 +318,7 @@ void ctk_image_sliders_reset(CtkImageSliders *ctk_image_sliders)
val = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(adj),
"attribute default value"));
- NvCtrlSetAttribute(ctk_image_sliders->handle,
- NV_CTRL_IMAGE_SHARPENING,
- val);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_IMAGE_SHARPENING, val);
}
/*
@@ -354,20 +352,21 @@ void ctk_image_sliders_reset(CtkImageSliders *ctk_image_sliders)
* NV-CONTROL client changed any of the settings that we care about.
*/
-static void scale_value_received(GObject *object, gpointer arg1,
+static void scale_value_received(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
- CtkEventStruct *event_struct;
CtkImageSliders *ctk_image_sliders = CTK_IMAGE_SLIDERS(user_data);
GtkAdjustment *adj;
GtkWidget *scale;
gint val;
-
-
- event_struct = (CtkEventStruct *) arg1;
- switch (event_struct->attribute) {
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ switch (event->int_attr.attribute) {
case NV_CTRL_DIGITAL_VIBRANCE:
scale = ctk_image_sliders->digital_vibrance;
break;
@@ -378,16 +377,16 @@ static void scale_value_received(GObject *object, gpointer arg1,
return;
}
- if (event_struct->is_availability_changed) {
- setup_scale(ctk_image_sliders, event_struct->attribute, scale);
+ if (event->int_attr.is_availability_changed) {
+ setup_scale(ctk_image_sliders, event->int_attr.attribute, scale);
}
adj = CTK_SCALE(scale)->gtk_adjustment;
val = gtk_adjustment_get_value(GTK_ADJUSTMENT(adj));
- if (val != event_struct->value) {
+ if (val != event->int_attr.value) {
- val = event_struct->value;
+ val = event->int_attr.value;
g_signal_handlers_block_by_func(adj, scale_value_changed,
ctk_image_sliders);
@@ -437,17 +436,17 @@ static void setup_scale(CtkImageSliders *ctk_image_sliders,
int attribute,
GtkWidget *scale)
{
+ CtrlTarget *ctrl_target = ctk_image_sliders->ctrl_target;
ReturnStatus ret0, ret1;
NVCTRLAttributeValidValuesRec valid;
- NvCtrlAttributeHandle *handle = ctk_image_sliders->handle;
int val;
GtkAdjustment *adj = CTK_SCALE(scale)->gtk_adjustment;
/* Read settings from X server */
- ret0 = NvCtrlGetValidAttributeValues(handle, attribute, &valid);
+ ret0 = NvCtrlGetValidAttributeValues(ctrl_target, attribute, &valid);
- ret1 = NvCtrlGetAttribute(handle, attribute, &val);
+ ret1 = NvCtrlGetAttribute(ctrl_target, attribute, &val);
if ((ret0 == NvCtrlSuccess) && (ret1 == NvCtrlSuccess) &&
(valid.type == ATTRIBUTE_TYPE_RANGE)) {
diff --git a/src/gtk+-2.x/ctkimagesliders.h b/src/gtk+-2.x/ctkimagesliders.h
index 1ded2ac..40d8dc8 100644
--- a/src/gtk+-2.x/ctkimagesliders.h
+++ b/src/gtk+-2.x/ctkimagesliders.h
@@ -52,7 +52,7 @@ struct _CtkImageSliders
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
char *name;
CtkConfig *ctk_config;
@@ -71,7 +71,7 @@ struct _CtkImageSlidersClass
};
GType ctk_image_sliders_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_image_sliders_new (NvCtrlAttributeHandle *,
+GtkWidget* ctk_image_sliders_new (CtrlTarget *,
CtkConfig *, CtkEvent *,
GtkWidget *reset_button,
char *name);
diff --git a/src/gtk+-2.x/ctkmultisample.c b/src/gtk+-2.x/ctkmultisample.c
index a5ee7d6..fff5642 100644
--- a/src/gtk+-2.x/ctkmultisample.c
+++ b/src/gtk+-2.x/ctkmultisample.c
@@ -51,22 +51,21 @@ static void fsaa_setting_checkbox_toggled(GtkWidget *widget,
static void fsaa_setting_menu_changed(GObject *object, gpointer user_data);
-static void fsaa_setting_update_received(GObject *object,
- gpointer arg1,
+static void fsaa_setting_update_received(GObject *object, CtrlEvent *event,
gpointer user_data);
static void post_fsaa_value_changed(CtkMultisample *ctk_multisample, gint val);
static void fsaa_value_changed(GtkRange *range, gpointer user_data);
-static void fsaa_update_received(GObject *object,
- gpointer arg1, gpointer user_data);
+static void fsaa_update_received(GObject *object, CtrlEvent *event,
+ gpointer user_data);
static void fxaa_checkbox_toggled(GtkWidget *widget,
gpointer user_data);
-static void fxaa_update_received(GObject *object,
- gpointer arg1, gpointer user_data);
+static void fxaa_update_received(GObject *object, CtrlEvent *event,
+ gpointer user_data);
static void post_fxaa_toggled(CtkMultisample *ctk_multisample,
gboolean enable);
@@ -78,8 +77,7 @@ post_log_aniso_app_override_toggled(CtkMultisample *ctk_multisample,
static void log_aniso_app_override_toggled(GtkWidget *widget,
gpointer user_data);
-static void log_app_override_update_received(GObject *object,
- gpointer arg1,
+static void log_app_override_update_received(GObject *object, CtrlEvent *event,
gpointer user_data);
static const gchar *get_log_aniso_name(gint val);
@@ -92,8 +90,7 @@ static void post_log_aniso_value_changed(CtkMultisample *ctk_multisample,
static void log_aniso_value_changed(GtkRange *range, gpointer user_data);
-static void log_aniso_range_update_received(GObject *object,
- gpointer arg1,
+static void log_aniso_range_update_received(GObject *object, CtrlEvent *event,
gpointer user_data);
static void post_texture_sharpening_toggled(CtkMultisample *ctk_multisample,
@@ -101,8 +98,7 @@ static void post_texture_sharpening_toggled(CtkMultisample *ctk_multisample,
static void texture_sharpening_toggled(GtkWidget *widget, gpointer user_data);
-static void texture_sharpening_update_received(GObject *object,
- gpointer arg1,
+static void texture_sharpening_update_received(GObject *object, CtrlEvent *event,
gpointer user_data);
static void update_fxaa_from_fsaa_change(CtkMultisample *ctk_multisample,
@@ -216,8 +212,9 @@ GType ctk_multisample_get_type(
* ctk_multisample_new() - constructor for the Multisample widget
*/
-GtkWidget *ctk_multisample_new(NvCtrlAttributeHandle *handle,
- CtkConfig *ctk_config, CtkEvent *ctk_event)
+GtkWidget *ctk_multisample_new(CtrlTarget *ctrl_target,
+ CtkConfig *ctk_config,
+ CtkEvent *ctk_event)
{
GObject *object;
CtkMultisample *ctk_multisample;
@@ -229,26 +226,26 @@ GtkWidget *ctk_multisample_new(NvCtrlAttributeHandle *handle,
GtkWidget *scale;
GtkAdjustment *adjustment;
gint min, max;
-
+
gint val, app_control, override, enhance, mode, i;
-
+
NVCTRLAttributeValidValuesRec valid;
ReturnStatus ret, ret0;
/* create the new object */
-
+
object = g_object_new(CTK_TYPE_MULTISAMPLE, NULL);
ctk_multisample = CTK_MULTISAMPLE(object);
- ctk_multisample->handle = handle;
+ ctk_multisample->ctrl_target = ctrl_target;
ctk_multisample->ctk_config = ctk_config;
ctk_multisample->active_attributes = 0;
gtk_box_set_spacing(GTK_BOX(object), 10);
/* banner */
-
+
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(object), hbox, FALSE, FALSE, 0);
@@ -257,17 +254,18 @@ GtkWidget *ctk_multisample_new(NvCtrlAttributeHandle *handle,
/* FSAA slider */
- ret = NvCtrlGetValidAttributeValues(handle, NV_CTRL_FSAA_MODE, &valid);
-
+ ret = NvCtrlGetValidAttributeValues(ctrl_target, NV_CTRL_FSAA_MODE,
+ &valid);
+
if (ret == NvCtrlSuccess) {
-
+
build_fsaa_translation_table(ctk_multisample, valid);
-
- ret = NvCtrlGetAttribute(handle, NV_CTRL_FSAA_MODE, &mode);
-
+
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_FSAA_MODE, &mode);
+
val = map_nv_ctrl_fsaa_value_to_slider(ctk_multisample, mode);
- ret0 = NvCtrlGetAttribute(handle,
+ ret0 = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FSAA_APPLICATION_CONTROLLED,
&app_control);
/*
@@ -292,10 +290,10 @@ GtkWidget *ctk_multisample_new(NvCtrlAttributeHandle *handle,
vbox = gtk_vbox_new(FALSE, 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox), FRAME_PADDING);
gtk_container_add(GTK_CONTAINER(frame), vbox);
-
+
/* "Application Setting" widget */
-
- ret = NvCtrlGetAttribute(ctk_multisample->handle,
+
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FSAA_APPLICATION_ENHANCED,
&enhance);
@@ -387,7 +385,7 @@ GtkWidget *ctk_multisample_new(NvCtrlAttributeHandle *handle,
check_button = gtk_check_button_new_with_label("Enable FXAA");
if (mode == NV_CTRL_FSAA_MODE_NONE) {
- ret = NvCtrlGetAttribute(handle, NV_CTRL_FXAA, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_FXAA, &val);
if (val == NV_CTRL_FXAA_ENABLE) {
gtk_widget_set_sensitive(GTK_WIDGET(scale), FALSE);
}
@@ -415,18 +413,18 @@ GtkWidget *ctk_multisample_new(NvCtrlAttributeHandle *handle,
ctk_multisample->fxaa_enable_check_button = check_button;
}
}
-
+
/* Anisotropic filtering slider */
- ret = NvCtrlGetValidAttributeValues(handle, NV_CTRL_LOG_ANISO, &valid);
-
+ ret = NvCtrlGetValidAttributeValues(ctrl_target, NV_CTRL_LOG_ANISO, &valid);
+
ctk_multisample->log_aniso_scale = NULL;
if (ret == NvCtrlSuccess) {
-
- ret = NvCtrlGetAttribute(handle, NV_CTRL_LOG_ANISO, &val);
- ret0 = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_LOG_ANISO, &val);
+
+ ret0 = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED,
&app_control);
/*
@@ -521,8 +519,8 @@ GtkWidget *ctk_multisample_new(NvCtrlAttributeHandle *handle,
* If one of the supported multisample modes was enabled by the
* user, this check button controls texture sharpening.
*/
-
- ret = NvCtrlGetAttribute(handle, NV_CTRL_TEXTURE_SHARPEN, &val);
+
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_TEXTURE_SHARPEN, &val);
if (ret == NvCtrlSuccess) {
@@ -784,18 +782,19 @@ static void post_fsaa_setting_changed(CtkMultisample *ctk_multisample,
static void update_fsaa_setting(CtkMultisample *ctk_multisample,
gboolean override, gboolean enhance)
{
+ CtrlTarget *ctrl_target = ctk_multisample->ctrl_target;
GtkRange *range = GTK_RANGE(ctk_multisample->fsaa_scale);
- NvCtrlSetAttribute(ctk_multisample->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_FSAA_APPLICATION_CONTROLLED, !override);
-
+
if (ctk_multisample->active_attributes & __FSAA_ENHANCE) {
- NvCtrlSetAttribute(ctk_multisample->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_FSAA_APPLICATION_ENHANCED, enhance);
}
if (!override) {
- NvCtrlSetAttribute(ctk_multisample->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_FSAA_MODE, NV_CTRL_FSAA_MODE_NONE);
g_signal_handlers_block_by_func(G_OBJECT(range),
@@ -877,11 +876,11 @@ static void fsaa_setting_menu_changed(GObject *object, gpointer user_data)
*/
static void fsaa_setting_update_received(GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkMultisample *ctk_multisample = CTK_MULTISAMPLE(user_data);
+ CtrlTarget *ctrl_target = ctk_multisample->ctrl_target;
gint idx;
gboolean override;
gboolean enhance = FALSE;
@@ -889,15 +888,18 @@ static void fsaa_setting_update_received(GObject *object,
gint val;
ReturnStatus ret;
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
- switch (event_struct->attribute) {
+ switch (event->int_attr.attribute) {
case NV_CTRL_FSAA_APPLICATION_CONTROLLED:
- override = !event_struct->value;
+ override = !event->int_attr.value;
if (!override) {
idx = 0;
} else if (ctk_multisample->active_attributes & __FSAA_ENHANCE) {
- ret = NvCtrlGetAttribute(ctk_multisample->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FSAA_APPLICATION_ENHANCED,
&val);
if (ret == NvCtrlSuccess) {
@@ -913,9 +915,9 @@ static void fsaa_setting_update_received(GObject *object,
break;
case NV_CTRL_FSAA_APPLICATION_ENHANCED:
- enhance = event_struct->value;
+ enhance = event->int_attr.value;
- ret = NvCtrlGetAttribute(ctk_multisample->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_FSAA_APPLICATION_CONTROLLED,
&val);
if (ret == NvCtrlSuccess) {
@@ -1081,20 +1083,19 @@ static void update_fsaa_from_fxaa_change (CtkMultisample *ctk_multisample,
static void fsaa_value_changed(GtkRange *range, gpointer user_data)
{
- CtkMultisample *ctk_multisample;
+ CtkMultisample *ctk_multisample = CTK_MULTISAMPLE(user_data);
+ CtrlTarget *ctrl_target = ctk_multisample->ctrl_target;
gint val;
- ctk_multisample = CTK_MULTISAMPLE(user_data);
-
val = gtk_range_get_value(range);
if (val > NV_CTRL_FSAA_MODE_MAX) val = NV_CTRL_FSAA_MODE_MAX;
if (val < 0) val = 0;
val = ctk_multisample->fsaa_translation_table[val];
- NvCtrlSetAttribute(ctk_multisample->handle, NV_CTRL_FSAA_MODE, val);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_FSAA_MODE, val);
update_fxaa_from_fsaa_change(ctk_multisample, val);
-
+
post_fsaa_value_changed(ctk_multisample, val);
} /* fsaa_value_changed() */
@@ -1108,11 +1109,12 @@ static void fxaa_checkbox_toggled(GtkWidget *widget,
gpointer user_data)
{
CtkMultisample *ctk_multisample = CTK_MULTISAMPLE(user_data);
+ CtrlTarget *ctrl_target = ctk_multisample->ctrl_target;
gboolean enabled;
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- NvCtrlSetAttribute(ctk_multisample->handle, NV_CTRL_FXAA, enabled);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_FXAA, enabled);
update_fsaa_from_fxaa_change(ctk_multisample, enabled);
@@ -1128,13 +1130,19 @@ static void fxaa_checkbox_toggled(GtkWidget *widget,
*/
static void fxaa_update_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkMultisample *ctk_multisample = CTK_MULTISAMPLE(user_data);
- gboolean fxaa_value = event_struct->value;
+ gboolean fxaa_value;
GtkWidget *check_button = ctk_multisample->fxaa_enable_check_button;
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ fxaa_value = event->int_attr.value;
+
g_signal_handlers_block_by_func(G_OBJECT(check_button),
G_CALLBACK(fxaa_checkbox_toggled),
(gpointer) ctk_multisample);
@@ -1175,19 +1183,22 @@ post_fxaa_toggled(CtkMultisample *ctk_multisample, gboolean enable)
*/
static void fsaa_update_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
- CtkEventStruct *event_struct;
CtkMultisample *ctk_multisample;
GtkRange *range;
gint val;
- event_struct = (CtkEventStruct *) arg1;
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
ctk_multisample = CTK_MULTISAMPLE(user_data);
range = GTK_RANGE(ctk_multisample->fsaa_scale);
val = map_nv_ctrl_fsaa_value_to_slider(ctk_multisample,
- event_struct->value);
+ event->int_attr.value);
g_signal_handlers_block_by_func(G_OBJECT(range),
G_CALLBACK(fsaa_value_changed),
@@ -1195,13 +1206,13 @@ static void fsaa_update_received(GObject *object,
gtk_range_set_value(range, val);
- update_fxaa_from_fsaa_change(ctk_multisample, event_struct->value);
+ update_fxaa_from_fsaa_change(ctk_multisample, event->int_attr.value);
g_signal_handlers_unblock_by_func(G_OBJECT(range),
G_CALLBACK(fsaa_value_changed),
(gpointer) ctk_multisample);
- post_fsaa_value_changed(ctk_multisample, event_struct->value);
+ post_fsaa_value_changed(ctk_multisample, event->int_attr.value);
} /* fsaa_update_received() */
@@ -1242,15 +1253,16 @@ static void log_aniso_app_override_toggled(GtkWidget *widget,
gpointer user_data)
{
CtkMultisample *ctk_multisample = CTK_MULTISAMPLE(user_data);
+ CtrlTarget *ctrl_target = ctk_multisample->ctrl_target;
GtkRange *range = GTK_RANGE(ctk_multisample->log_aniso_scale);
gboolean override;
override = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- NvCtrlSetAttribute(ctk_multisample->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED, !override);
if (!override) {
- NvCtrlSetAttribute(ctk_multisample->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_LOG_ANISO, 0 /* default(?) */);
g_signal_handlers_block_by_func(G_OBJECT(range),
@@ -1277,13 +1289,19 @@ static void log_aniso_app_override_toggled(GtkWidget *widget,
*/
static void log_app_override_update_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkMultisample *ctk_multisample = CTK_MULTISAMPLE(user_data);
- gboolean override = !event_struct->value;
+ gboolean override;
GtkWidget *check_button;
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ override = !event->int_attr.value;
+
check_button = ctk_multisample->log_aniso_app_override_check_button;
g_signal_handlers_block_by_func(G_OBJECT(check_button),
@@ -1344,10 +1362,15 @@ static gchar *format_log_aniso_value(GtkScale *scale, gdouble arg1,
static void post_log_aniso_value_changed(CtkMultisample *ctk_multisample,
gint val)
{
- ctk_config_statusbar_message(ctk_multisample->ctk_config,
- "Anisotropic Filtering set to %s.",
- get_log_aniso_name(val));
-
+ gboolean override = gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(ctk_multisample->log_aniso_app_override_check_button));
+
+ if (override) {
+ ctk_config_statusbar_message(ctk_multisample->ctk_config,
+ "Anisotropic Filtering set to %s.",
+ get_log_aniso_name(val));
+ }
+
} /* post_log_aniso_value_changed() */
@@ -1359,15 +1382,14 @@ static void post_log_aniso_value_changed(CtkMultisample *ctk_multisample,
static void log_aniso_value_changed(GtkRange *range, gpointer user_data)
{
- CtkMultisample *ctk_multisample;
+ CtkMultisample *ctk_multisample = CTK_MULTISAMPLE(user_data);
+ CtrlTarget *ctrl_target = ctk_multisample->ctrl_target;
gint val;
- ctk_multisample = CTK_MULTISAMPLE(user_data);
-
val = gtk_range_get_value(range);
- NvCtrlSetAttribute(ctk_multisample->handle, NV_CTRL_LOG_ANISO, val);
-
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_LOG_ANISO, val);
+
post_log_aniso_value_changed(ctk_multisample, val);
} /* log_aniso_value_changed() */
@@ -1381,13 +1403,16 @@ static void log_aniso_value_changed(GtkRange *range, gpointer user_data)
*/
static void log_aniso_range_update_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
- CtkEventStruct *event_struct;
CtkMultisample *ctk_multisample;
GtkRange *range;
- event_struct = (CtkEventStruct *) arg1;
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
ctk_multisample = CTK_MULTISAMPLE(user_data);
range = GTK_RANGE(ctk_multisample->log_aniso_scale);
@@ -1395,9 +1420,9 @@ static void log_aniso_range_update_received(GObject *object,
G_CALLBACK(log_aniso_value_changed),
(gpointer) ctk_multisample);
- gtk_range_set_value(range, event_struct->value);
+ gtk_range_set_value(range, event->int_attr.value);
- post_log_aniso_value_changed(ctk_multisample, event_struct->value);
+ post_log_aniso_value_changed(ctk_multisample, event->int_attr.value);
g_signal_handlers_unblock_by_func(G_OBJECT(range),
G_CALLBACK(log_aniso_value_changed),
@@ -1433,18 +1458,16 @@ static void post_texture_sharpening_toggled(CtkMultisample *ctk_multisample,
static void texture_sharpening_toggled(GtkWidget *widget, gpointer user_data)
{
- CtkMultisample *ctk_multisample;
+ CtkMultisample *ctk_multisample = CTK_MULTISAMPLE(user_data);
+ CtrlTarget *ctrl_target = ctk_multisample->ctrl_target;
gboolean enabled;
- ctk_multisample = CTK_MULTISAMPLE(user_data);
-
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- NvCtrlSetAttribute(ctk_multisample->handle, NV_CTRL_TEXTURE_SHARPEN,
- enabled);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_TEXTURE_SHARPEN, enabled);
post_texture_sharpening_toggled(ctk_multisample, enabled);
-
+
} /* texture_sharpening_toggled() */
@@ -1456,14 +1479,16 @@ static void texture_sharpening_toggled(GtkWidget *widget, gpointer user_data)
*/
static void texture_sharpening_update_received(GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data)
{
- CtkEventStruct *event_struct;
CtkMultisample *ctk_multisample;
GtkToggleButton *button;
+
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
- event_struct = (CtkEventStruct *) arg1;
ctk_multisample = CTK_MULTISAMPLE(user_data);
button = GTK_TOGGLE_BUTTON(ctk_multisample->texture_sharpening_button);
@@ -1471,9 +1496,9 @@ static void texture_sharpening_update_received(GObject *object,
G_CALLBACK(texture_sharpening_toggled),
(gpointer) ctk_multisample);
- gtk_toggle_button_set_active(button, event_struct->value);
+ gtk_toggle_button_set_active(button, event->int_attr.value);
- post_texture_sharpening_toggled(ctk_multisample, event_struct->value);
+ post_texture_sharpening_toggled(ctk_multisample, event->int_attr.value);
g_signal_handlers_unblock_by_func(G_OBJECT(button),
G_CALLBACK(texture_sharpening_toggled),
diff --git a/src/gtk+-2.x/ctkmultisample.h b/src/gtk+-2.x/ctkmultisample.h
index b7d0690..7ed8270 100644
--- a/src/gtk+-2.x/ctkmultisample.h
+++ b/src/gtk+-2.x/ctkmultisample.h
@@ -52,7 +52,7 @@ typedef struct _CtkMultisampleClass CtkMultisampleClass;
struct _CtkMultisample
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
GtkWidget *fsaa_app_override_check_button;
@@ -63,7 +63,7 @@ struct _CtkMultisample
GtkWidget *log_aniso_scale;
GtkWidget *texture_sharpening_button;
CtkDropDownMenu *d;
-
+
guint active_attributes;
gint fsaa_translation_table[NV_CTRL_FSAA_MODE_MAX + 1];
@@ -76,8 +76,7 @@ struct _CtkMultisampleClass
};
GType ctk_multisample_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_multisample_new (NvCtrlAttributeHandle *,
- CtkConfig *, CtkEvent *);
+GtkWidget* ctk_multisample_new (CtrlTarget *, CtkConfig *, CtkEvent *);
GtkTextBuffer *ctk_multisample_create_help(GtkTextTagTable *,
CtkMultisample *);
diff --git a/src/gtk+-2.x/ctkopengl.c b/src/gtk+-2.x/ctkopengl.c
index bfce5bf..ee8781e 100644
--- a/src/gtk+-2.x/ctkopengl.c
+++ b/src/gtk+-2.x/ctkopengl.c
@@ -70,7 +70,7 @@ static void show_sli_visual_indicator_button_toggled (GtkWidget *, gpointer);
static void show_multigpu_visual_indicator_button_toggled (GtkWidget *, gpointer);
-static void value_changed (GObject *, gpointer, gpointer);
+static void value_changed (GObject *, CtrlEvent *, gpointer);
static const gchar *get_image_settings_string(gint val);
@@ -79,15 +79,15 @@ static gchar *format_image_settings_value(GtkScale *scale, gdouble arg1,
static void post_slider_value_changed(CtkOpenGL *ctk_opengl, gint val);
-static void aa_line_gamma_update_received(GObject *object,
- gpointer arg1, gpointer user_data);
+static void aa_line_gamma_update_received(GObject *object, CtrlEvent *event,
+ gpointer user_data);
static void post_image_settings_value_changed(CtkOpenGL *ctk_opengl, gint val);
static void image_settings_value_changed(GtkRange *range, gpointer user_data);
-static void image_settings_update_received(GObject *object,
- gpointer arg1, gpointer user_data);
+static void image_settings_update_received(GObject *object, CtrlEvent *event,
+ gpointer user_data);
static GtkWidget *create_slider(CtkOpenGL *ctk_opengl,
GtkWidget *vbox,
@@ -200,8 +200,9 @@ GType ctk_opengl_get_type(
}
-GtkWidget* ctk_opengl_new(NvCtrlAttributeHandle *handle,
- CtkConfig *ctk_config, CtkEvent *ctk_event)
+GtkWidget* ctk_opengl_new(CtrlTarget *ctrl_target,
+ CtkConfig *ctk_config,
+ CtkEvent *ctk_event)
{
GObject *object;
CtkOpenGL *ctk_opengl;
@@ -243,51 +244,67 @@ GtkWidget* ctk_opengl_new(NvCtrlAttributeHandle *handle,
/* Query OpenGL settings */
ret_sync_to_vblank =
- NvCtrlGetAttribute(handle, NV_CTRL_SYNC_TO_VBLANK, &sync_to_vblank);
+ NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_SYNC_TO_VBLANK,
+ &sync_to_vblank);
ret_flipping_allowed =
- NvCtrlGetAttribute(handle, NV_CTRL_FLIPPING_ALLOWED,
+ NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_FLIPPING_ALLOWED,
&flipping_allowed);
ret_gsync_allowed =
- NvCtrlGetAttribute(handle, NV_CTRL_GSYNC_ALLOWED,
+ NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_GSYNC_ALLOWED,
&gsync_allowed);
ret_force_stereo =
- NvCtrlGetAttribute(handle, NV_CTRL_FORCE_STEREO, &force_stereo);
+ NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_FORCE_STEREO,
+ &force_stereo);
ret_xinerama_stereo =
- NvCtrlGetAttribute(handle, NV_CTRL_XINERAMA_STEREO, &xinerama_stereo);
+ NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_XINERAMA_STEREO,
+ &xinerama_stereo);
ret_stereo_eyes_exchange =
- NvCtrlGetAttribute(handle, NV_CTRL_STEREO_EYES_EXCHANGE,
+ NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_STEREO_EYES_EXCHANGE,
&stereo_eyes_exchange);
- ret_image_settings =
- NvCtrlGetValidAttributeValues(handle, NV_CTRL_IMAGE_SETTINGS,
- &image_settings_valid);
+ ret_image_settings = NvCtrlGetValidAttributeValues(ctrl_target,
+ NV_CTRL_IMAGE_SETTINGS,
+ &image_settings_valid);
if ((ret_image_settings == NvCtrlSuccess) &&
(image_settings_valid.type == ATTRIBUTE_TYPE_RANGE)) {
ret_image_settings =
- NvCtrlGetAttribute(handle, NV_CTRL_IMAGE_SETTINGS,
+ NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_IMAGE_SETTINGS,
&image_settings_value);
} else {
ret_image_settings = NvCtrlError;
}
- ret_aa_line_gamma = NvCtrlGetAttribute(handle, NV_CTRL_OPENGL_AA_LINE_GAMMA,
- &aa_line_gamma);
+ ret_aa_line_gamma =
+ NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_OPENGL_AA_LINE_GAMMA,
+ &aa_line_gamma);
ret_use_conformant_clamping =
- NvCtrlGetAttribute(handle, NV_CTRL_TEXTURE_CLAMPING,
+ NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_TEXTURE_CLAMPING,
&use_conformant_clamping);
- ret_show_sli_visual_indicator = NvCtrlGetAttribute(handle,
- NV_CTRL_SHOW_SLI_VISUAL_INDICATOR,
- &show_sli_visual_indicator);
- ret_show_multigpu_visual_indicator = NvCtrlGetAttribute(handle,
- NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR,
- &show_multigpu_visual_indicator);
+ ret_show_sli_visual_indicator =
+ NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_SHOW_SLI_VISUAL_INDICATOR,
+ &show_sli_visual_indicator);
+
+ ret_show_multigpu_visual_indicator =
+ NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR,
+ &show_multigpu_visual_indicator);
/* There are no OpenGL settings to change (OpenGL disabled?) */
if ((ret_sync_to_vblank != NvCtrlSuccess) &&
@@ -307,7 +324,7 @@ GtkWidget* ctk_opengl_new(NvCtrlAttributeHandle *handle,
object = g_object_new(CTK_TYPE_OPENGL, NULL);
ctk_opengl = CTK_OPENGL(object);
- ctk_opengl->handle = handle;
+ ctk_opengl->ctrl_target = ctrl_target;
ctk_opengl->ctk_config = ctk_config;
ctk_opengl->active_attributes = 0;
@@ -820,19 +837,16 @@ post_use_conformant_clamping_button_toggled(CtkOpenGL *ctk_opengl,
"" : "Non-");
}
-static void vblank_sync_button_toggled(
- GtkWidget *widget,
- gpointer user_data
-)
+static void vblank_sync_button_toggled(GtkWidget *widget,
+ gpointer user_data)
{
- CtkOpenGL *ctk_opengl;
+ CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
gboolean enabled;
-
- ctk_opengl = CTK_OPENGL(user_data);
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- NvCtrlSetAttribute(ctk_opengl->handle, NV_CTRL_SYNC_TO_VBLANK, enabled);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_SYNC_TO_VBLANK, enabled);
post_vblank_sync_button_toggled(ctk_opengl, enabled);
}
@@ -841,72 +855,66 @@ static void vblank_sync_button_toggled(
static void allow_flipping_button_toggled(GtkWidget *widget,
gpointer user_data)
{
- CtkOpenGL *ctk_opengl;
+ CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
gboolean enabled;
-
- ctk_opengl = CTK_OPENGL(user_data);
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
-
- NvCtrlSetAttribute(ctk_opengl->handle, NV_CTRL_FLIPPING_ALLOWED, enabled);
+
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_FLIPPING_ALLOWED, enabled);
post_allow_flipping_button_toggled(ctk_opengl, enabled);
-
}
static void allow_gsync_button_toggled(GtkWidget *widget,
gpointer user_data)
{
- CtkOpenGL *ctk_opengl;
+ CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
gboolean enabled;
- ctk_opengl = CTK_OPENGL(user_data);
-
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- NvCtrlSetAttribute(ctk_opengl->handle, NV_CTRL_GSYNC_ALLOWED, enabled);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_GSYNC_ALLOWED, enabled);
post_allow_gsync_button_toggled(ctk_opengl, enabled);
}
static void force_stereo_button_toggled(GtkWidget *widget,
gpointer user_data)
{
- CtkOpenGL *ctk_opengl;
+ CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
gboolean enabled;
-
- ctk_opengl = CTK_OPENGL(user_data);
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- NvCtrlSetAttribute(ctk_opengl->handle, NV_CTRL_FORCE_STEREO, enabled);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_FORCE_STEREO, enabled);
post_force_stereo_button_toggled(ctk_opengl, enabled);
}
static void show_sli_visual_indicator_button_toggled(GtkWidget *widget,
gpointer user_data)
{
- CtkOpenGL *ctk_opengl;
+ CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
gboolean enabled;
- ctk_opengl = CTK_OPENGL(user_data);
-
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- NvCtrlSetAttribute(ctk_opengl->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_SHOW_SLI_VISUAL_INDICATOR, enabled);
- post_show_sli_visual_indicator_button_toggled(ctk_opengl, enabled);
+ post_show_sli_visual_indicator_button_toggled(ctk_opengl, enabled);
}
static void show_multigpu_visual_indicator_button_toggled(GtkWidget *widget,
gpointer user_data)
{
- CtkOpenGL *ctk_opengl;
+ CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
gboolean enabled;
- ctk_opengl = CTK_OPENGL(user_data);
-
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- NvCtrlSetAttribute(ctk_opengl->handle,
+ NvCtrlSetAttribute(ctrl_target,
NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR, enabled);
post_show_multigpu_visual_indicator_button_toggled(ctk_opengl, enabled);
}
@@ -914,47 +922,41 @@ static void show_multigpu_visual_indicator_button_toggled(GtkWidget *widget,
static void xinerama_stereo_button_toggled(GtkWidget *widget,
gpointer user_data)
{
- CtkOpenGL *ctk_opengl;
+ CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
gboolean enabled;
-
- ctk_opengl = CTK_OPENGL(user_data);
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- NvCtrlSetAttribute(ctk_opengl->handle, NV_CTRL_XINERAMA_STEREO, enabled);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_XINERAMA_STEREO, enabled);
post_xinerama_stereo_button_toggled(ctk_opengl, enabled);
}
static void stereo_eyes_exchange_button_toggled(GtkWidget *widget,
gpointer user_data)
{
- CtkOpenGL *ctk_opengl;
+ CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
gboolean enabled;
-
- ctk_opengl = CTK_OPENGL(user_data);
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- NvCtrlSetAttribute(ctk_opengl->handle, NV_CTRL_STEREO_EYES_EXCHANGE,
- enabled);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_STEREO_EYES_EXCHANGE, enabled);
post_stereo_eyes_exchange_button_toggled(ctk_opengl, enabled);
}
-static void aa_line_gamma_toggled(
- GtkWidget *widget,
- gpointer user_data
-)
+static void aa_line_gamma_toggled(GtkWidget *widget,
+ gpointer user_data)
{
- CtkOpenGL *ctk_opengl;
+ CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
gboolean enabled;
ReturnStatus ret;
-
- ctk_opengl = CTK_OPENGL(user_data);
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- ret = NvCtrlSetAttribute(ctk_opengl->handle,
+ ret = NvCtrlSetAttribute(ctrl_target,
NV_CTRL_OPENGL_AA_LINE_GAMMA, enabled);
if (ret != NvCtrlSuccess) return;
@@ -966,18 +968,17 @@ static void aa_line_gamma_toggled(
static void use_conformant_clamping_button_toggled(GtkWidget *widget,
gpointer user_data)
{
- CtkOpenGL *ctk_opengl;
+ CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
int clamping;
-
- ctk_opengl = CTK_OPENGL(user_data);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
clamping = NV_CTRL_TEXTURE_CLAMPING_SPEC;
} else {
clamping = NV_CTRL_TEXTURE_CLAMPING_EDGE;
}
-
- NvCtrlSetAttribute(ctk_opengl->handle, NV_CTRL_TEXTURE_CLAMPING, clamping);
+
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_TEXTURE_CLAMPING, clamping);
post_use_conformant_clamping_button_toggled(ctk_opengl, clamping);
}
@@ -987,77 +988,76 @@ static void use_conformant_clamping_button_toggled(GtkWidget *widget,
* value_changed() - callback function for changed OpenGL settings.
*/
-static void value_changed(GObject *object, gpointer arg1, gpointer user_data)
+static void value_changed(GObject *object, CtrlEvent *event, gpointer user_data)
{
- CtkEventStruct *event_struct;
CtkOpenGL *ctk_opengl;
gboolean enabled;
gboolean check_available = FALSE;
GtkToggleButton *button;
GCallback func;
+ gint value;
+
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
- event_struct = (CtkEventStruct *) arg1;
ctk_opengl = CTK_OPENGL(user_data);
+ value = event->int_attr.value;
- switch (event_struct->attribute) {
+ switch (event->int_attr.attribute) {
case NV_CTRL_SYNC_TO_VBLANK:
button = GTK_TOGGLE_BUTTON(ctk_opengl->sync_to_vblank_button);
func = G_CALLBACK(vblank_sync_button_toggled);
- post_vblank_sync_button_toggled(ctk_opengl, event_struct->value);
+ post_vblank_sync_button_toggled(ctk_opengl, value);
break;
case NV_CTRL_FLIPPING_ALLOWED:
button = GTK_TOGGLE_BUTTON(ctk_opengl->allow_flipping_button);
func = G_CALLBACK(allow_flipping_button_toggled);
- post_allow_flipping_button_toggled(ctk_opengl, event_struct->value);
+ post_allow_flipping_button_toggled(ctk_opengl, value);
break;
case NV_CTRL_GSYNC_ALLOWED:
button = GTK_TOGGLE_BUTTON(ctk_opengl->allow_gsync_button);
func = G_CALLBACK(allow_gsync_button_toggled);
- post_allow_gsync_button_toggled(ctk_opengl, event_struct->value);
+ post_allow_gsync_button_toggled(ctk_opengl, value);
check_available = TRUE;
break;
case NV_CTRL_FORCE_STEREO:
button = GTK_TOGGLE_BUTTON(ctk_opengl->force_stereo_button);
func = G_CALLBACK(force_stereo_button_toggled);
- post_force_stereo_button_toggled(ctk_opengl, event_struct->value);
+ post_force_stereo_button_toggled(ctk_opengl, value);
break;
case NV_CTRL_XINERAMA_STEREO:
button = GTK_TOGGLE_BUTTON(ctk_opengl->xinerama_stereo_button);
func = G_CALLBACK(xinerama_stereo_button_toggled);
- post_xinerama_stereo_button_toggled(ctk_opengl, event_struct->value);
+ post_xinerama_stereo_button_toggled(ctk_opengl, value);
break;
case NV_CTRL_STEREO_EYES_EXCHANGE:
button = GTK_TOGGLE_BUTTON(ctk_opengl->stereo_eyes_exchange_button);
func = G_CALLBACK(stereo_eyes_exchange_button_toggled);
- post_stereo_eyes_exchange_button_toggled(ctk_opengl,
- event_struct->value);
+ post_stereo_eyes_exchange_button_toggled(ctk_opengl, value);
break;
case NV_CTRL_OPENGL_AA_LINE_GAMMA:
button = GTK_TOGGLE_BUTTON(ctk_opengl->aa_line_gamma_button);
func = G_CALLBACK(aa_line_gamma_toggled);
- post_aa_line_gamma_toggled(ctk_opengl, event_struct->value);
- gtk_widget_set_sensitive(ctk_opengl->aa_line_gamma_scale,
- event_struct->value);
+ post_aa_line_gamma_toggled(ctk_opengl, value);
+ gtk_widget_set_sensitive(ctk_opengl->aa_line_gamma_scale, value);
break;
case NV_CTRL_TEXTURE_CLAMPING:
button =
GTK_TOGGLE_BUTTON(ctk_opengl->use_conformant_clamping_button);
func = G_CALLBACK(use_conformant_clamping_button_toggled);
- post_use_conformant_clamping_button_toggled(ctk_opengl,
- event_struct->value);
+ post_use_conformant_clamping_button_toggled(ctk_opengl, value);
break;
case NV_CTRL_SHOW_SLI_VISUAL_INDICATOR:
button = GTK_TOGGLE_BUTTON(ctk_opengl->show_sli_visual_indicator_button);
func = G_CALLBACK(show_sli_visual_indicator_button_toggled);
- post_show_sli_visual_indicator_button_toggled(ctk_opengl,
- event_struct->value);
+ post_show_sli_visual_indicator_button_toggled(ctk_opengl, value);
break;
case NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR:
button =
GTK_TOGGLE_BUTTON(ctk_opengl->show_multigpu_visual_indicator_button);
func = G_CALLBACK(show_multigpu_visual_indicator_button_toggled);
- post_show_multigpu_visual_indicator_button_toggled(ctk_opengl,
- event_struct->value);
+ post_show_multigpu_visual_indicator_button_toggled(ctk_opengl, value);
break;
default:
return;
@@ -1065,15 +1065,15 @@ static void value_changed(GObject *object, gpointer arg1, gpointer user_data)
enabled = gtk_toggle_button_get_active(button);
- if (enabled != event_struct->value) {
+ if (enabled != value) {
g_signal_handlers_block_by_func(button, func, ctk_opengl);
- gtk_toggle_button_set_active(button, event_struct->value);
+ gtk_toggle_button_set_active(button, value);
g_signal_handlers_unblock_by_func(button, func, ctk_opengl);
}
- if (check_available && event_struct->is_availability_changed) {
- if (event_struct->availability) {
+ if (check_available && event->int_attr.is_availability_changed) {
+ if (event->int_attr.availability) {
gtk_widget_show(GTK_WIDGET(button));
} else {
gtk_widget_hide(GTK_WIDGET(button));
@@ -1135,9 +1135,10 @@ static void post_image_settings_value_changed(CtkOpenGL *ctk_opengl, gint val)
static void image_settings_value_changed(GtkRange *range, gpointer user_data)
{
CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
gint val = gtk_range_get_value(range);
- NvCtrlSetAttribute(ctk_opengl->handle, NV_CTRL_IMAGE_SETTINGS, val);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_IMAGE_SETTINGS, val);
post_image_settings_value_changed(ctk_opengl, val);
} /* image_settings_value_changed() */
@@ -1148,18 +1149,22 @@ static void image_settings_value_changed(GtkRange *range, gpointer user_data)
*/
static void image_settings_update_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
GtkRange *range = GTK_RANGE(ctk_opengl->image_settings_scale);
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
g_signal_handlers_block_by_func(G_OBJECT(range),
G_CALLBACK(image_settings_value_changed),
(gpointer) ctk_opengl);
- gtk_range_set_value(range, event_struct->value);
- post_image_settings_value_changed(ctk_opengl, event_struct->value);
+ gtk_range_set_value(range, event->int_attr.value);
+ post_image_settings_value_changed(ctk_opengl, event->int_attr.value);
g_signal_handlers_unblock_by_func(G_OBJECT(range),
G_CALLBACK(image_settings_value_changed),
@@ -1191,12 +1196,17 @@ static void post_slider_value_changed(CtkOpenGL *ctk_opengl, gint val)
static void slider_changed(GtkAdjustment *adjustment, gpointer user_data)
{
CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
gint attribute, value;
+
user_data = g_object_get_data(G_OBJECT(adjustment), "opengl_attribute");
attribute = GPOINTER_TO_INT(user_data);
value = (gint) gtk_adjustment_get_value(adjustment);
- NvCtrlSetAttribute(ctk_opengl->handle, attribute, value);
+
+ NvCtrlSetAttribute(ctrl_target, attribute, value);
+
post_slider_value_changed(ctk_opengl, value);
+
} /* slider_changed() */
@@ -1207,20 +1217,25 @@ static void slider_changed(GtkAdjustment *adjustment, gpointer user_data)
*/
static void aa_line_gamma_update_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkOpenGL *ctk_opengl = CTK_OPENGL(user_data);
CtkScale *scale = CTK_SCALE(ctk_opengl->aa_line_gamma_scale);
GtkAdjustment *adjustment;
+
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
adjustment = GTK_ADJUSTMENT(scale->gtk_adjustment);
g_signal_handlers_block_by_func(G_OBJECT(adjustment),
G_CALLBACK(slider_changed),
(gpointer) ctk_opengl);
gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustment),
- (gint)event_struct->value);
- post_slider_value_changed(ctk_opengl, event_struct->value);
+ (gint)event->int_attr.value);
+ post_slider_value_changed(ctk_opengl, event->int_attr.value);
g_signal_handlers_unblock_by_func(G_OBJECT(adjustment),
G_CALLBACK(slider_changed),
@@ -1237,6 +1252,7 @@ static GtkWidget *create_slider(CtkOpenGL *ctk_opengl,
gint attribute,
unsigned int bit)
{
+ CtrlTarget *ctrl_target = ctk_opengl->ctrl_target;
GtkAdjustment *adjustment;
GtkWidget *scale, *widget;
gint min, max, val, step_incr, page_incr;
@@ -1244,11 +1260,11 @@ static GtkWidget *create_slider(CtkOpenGL *ctk_opengl,
ReturnStatus ret;
/* get the attribute value */
- ret = NvCtrlGetAttribute(ctk_opengl->handle, attribute, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, attribute, &val);
if (ret != NvCtrlSuccess) return NULL;
/* get the range for the attribute */
- NvCtrlGetValidAttributeValues(ctk_opengl->handle, attribute, &range);
+ NvCtrlGetValidAttributeValues(ctrl_target, attribute, &range);
if (range.type != ATTRIBUTE_TYPE_RANGE) return NULL;
min = range.u.range.min;
diff --git a/src/gtk+-2.x/ctkopengl.h b/src/gtk+-2.x/ctkopengl.h
index c8907d8..845f8e3 100644
--- a/src/gtk+-2.x/ctkopengl.h
+++ b/src/gtk+-2.x/ctkopengl.h
@@ -50,7 +50,7 @@ struct _CtkOpenGL
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
GtkWidget *sync_to_vblank_button;
@@ -65,7 +65,7 @@ struct _CtkOpenGL
GtkWidget *aa_line_gamma_scale;
GtkWidget *show_sli_visual_indicator_button;
GtkWidget *show_multigpu_visual_indicator_button;
-
+
unsigned int active_attributes;
};
@@ -75,8 +75,7 @@ struct _CtkOpenGLClass
};
GType ctk_opengl_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_opengl_new (NvCtrlAttributeHandle *,
- CtkConfig *, CtkEvent *);
+GtkWidget* ctk_opengl_new (CtrlTarget *, CtkConfig *, CtkEvent *);
GtkTextBuffer *ctk_opengl_create_help(GtkTextTagTable *, CtkOpenGL *);
diff --git a/src/gtk+-2.x/ctkpowermizer.c b/src/gtk+-2.x/ctkpowermizer.c
index e1bdc69..e52fef6 100644
--- a/src/gtk+-2.x/ctkpowermizer.c
+++ b/src/gtk+-2.x/ctkpowermizer.c
@@ -47,7 +47,7 @@ static void update_powermizer_menu_event(GObject *object,
static void dp_config_button_toggled(GtkWidget *, gpointer);
static void dp_set_config_status(CtkPowermizer *);
static void dp_update_config_status(CtkPowermizer *, gboolean);
-static void dp_configuration_update_received(GObject *, gpointer, gpointer);
+static void dp_configuration_update_received(GObject *, CtrlEvent *, gpointer);
static void post_dp_configuration_update(CtkPowermizer *);
static void show_dp_toggle_warning_dlg(CtkPowermizer *ctk_powermizer);
static void post_set_attribute_offset_value(CtkPowermizer *ctk_powermizer,
@@ -58,7 +58,7 @@ static void offset_entry_set_value(CtkPowermizer *ctk_powermizer,
gint offset);
static void offset_value_changed_event_received(GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data);
static void update_editable_perf_level_info(CtkPowermizer *ctk_powermizer);
@@ -114,7 +114,8 @@ static const char *__powermizer_menu_help =
"State for the GPU, provided the GPU has multiple Performance Levels. "
"If a single X server is running, the mode selected in nvidia-settings is what "
"the system will be using; if two or more X servers are running, the behavior "
-"is undefined. ";
+"is undefined. The value of this setting does not persist across X server or "
+"system restarts. ";
static const char *__powermizer_auto_mode_help =
"'Auto' mode lets the driver choose the best Performance State for your GPU. ";
@@ -240,16 +241,19 @@ static void apply_perf_mode_token(char *token, char *value, void *data)
static void offset_value_changed_event_received(GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkPowermizer *ctk_powermizer = CTK_POWERMIZER(user_data);
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
update_editable_perf_level_info(ctk_powermizer);
post_set_attribute_offset_value(ctk_powermizer,
- event_struct->attribute,
- event_struct->value);
+ event->int_attr.attribute,
+ event->int_attr.value);
}
@@ -282,6 +286,7 @@ static void set_attribute_offset_value(GtkWidget *widget,
gpointer user_data)
{
CtkPowermizer *ctk_powermizer = CTK_POWERMIZER(user_data);
+ CtrlTarget *ctrl_target = ctk_powermizer->ctrl_target;
gint offset;
gint perf_level, attribute, ret;
const gchar *txt_entry = gtk_entry_get_text(GTK_ENTRY(widget));
@@ -292,7 +297,7 @@ static void set_attribute_offset_value(GtkWidget *widget,
user_data = g_object_get_data(G_OBJECT(widget), "perf level");
perf_level = GPOINTER_TO_INT(user_data);
- ret = NvCtrlSetDisplayAttribute(ctk_powermizer->attribute_handle,
+ ret = NvCtrlSetDisplayAttribute(ctrl_target,
perf_level,
attribute,
offset);
@@ -327,6 +332,7 @@ static void offset_entry_set_value(CtkPowermizer *ctk_powermizer,
static void update_editable_perf_level_info(CtkPowermizer *ctk_powermizer)
{
+ CtrlTarget *ctrl_target = ctk_powermizer->ctrl_target;
GtkWidget *table;
GtkWidget *label;
char tmp_str[24];
@@ -440,13 +446,13 @@ static void update_editable_perf_level_info(CtkPowermizer *ctk_powermizer)
/* Query GPU clock offset information */
if (ctk_powermizer->gpu_clock) {
- ret = NvCtrlGetValidDisplayAttributeValues(ctk_powermizer->attribute_handle,
+ ret = NvCtrlGetValidDisplayAttributeValues(ctrl_target,
i,
NV_CTRL_GPU_NVCLOCK_OFFSET,
&gpu_clock_valid_val);
if ((ret == NvCtrlSuccess) &&
(gpu_clock_valid_val.permissions & ATTRIBUTE_TYPE_WRITE)) {
- ret = NvCtrlGetDisplayAttribute(ctk_powermizer->attribute_handle,
+ ret = NvCtrlGetDisplayAttribute(ctrl_target,
i,
NV_CTRL_GPU_NVCLOCK_OFFSET,
&gpu_clock_val);
@@ -467,16 +473,18 @@ static void update_editable_perf_level_info(CtkPowermizer *ctk_powermizer)
/* Query Memory transfer rate offset information */
if (ctk_powermizer->memory_transfer_rate) {
- ret = NvCtrlGetValidDisplayAttributeValues(ctk_powermizer->attribute_handle,
- i,
- NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET,
- &mem_transfer_rate_valid_val);
+ ret =
+ NvCtrlGetValidDisplayAttributeValues(ctrl_target,
+ i,
+ NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET,
+ &mem_transfer_rate_valid_val);
if ((ret == NvCtrlSuccess) &&
(mem_transfer_rate_valid_val.permissions & ATTRIBUTE_TYPE_WRITE)) {
- ret = NvCtrlGetDisplayAttribute(ctk_powermizer->attribute_handle,
- i,
- NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET,
- &mem_transfer_rate_val);
+ ret =
+ NvCtrlGetDisplayAttribute(ctrl_target,
+ i,
+ NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET,
+ &mem_transfer_rate_val);
if (ret == NvCtrlSuccess) {
/* Create input entry field */
txt_mem_transfer_rate_offset = gtk_entry_new();
@@ -585,6 +593,7 @@ static void update_editable_perf_level_info(CtkPowermizer *ctk_powermizer)
static void update_perf_mode_table(CtkPowermizer *ctk_powermizer,
gint perf_level)
{
+ CtrlTarget *ctrl_target = ctk_powermizer->ctrl_target;
GtkWidget *table;
GtkWidget *label;
char *perf_modes = NULL;
@@ -603,7 +612,7 @@ static void update_perf_mode_table(CtkPowermizer *ctk_powermizer,
/* Get the current list of perf levels */
- ret = NvCtrlGetStringAttribute(ctk_powermizer->attribute_handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_PERFORMANCE_MODES,
&perf_modes);
@@ -947,8 +956,8 @@ static void update_perf_mode_table(CtkPowermizer *ctk_powermizer,
gtk_widget_show_all(table);
- XFree(perf_modes);
- XFree(pEntry);
+ free(perf_modes);
+ free(pEntry);
pEntry = NULL;
}
@@ -959,17 +968,14 @@ static gboolean update_powermizer_info(gpointer user_data)
gint power_source, adaptive_clock, perf_level;
gint gpu_clock, memory_transfer_rate;
- CtkPowermizer *ctk_powermizer;
- NvCtrlAttributeHandle *handle;
+ CtkPowermizer *ctk_powermizer = CTK_POWERMIZER(user_data);
+ CtrlTarget *ctrl_target = ctk_powermizer->ctrl_target;
gint ret;
gchar *s;
char *clock_string = NULL;
perfModeEntry pEntry;
- ctk_powermizer = CTK_POWERMIZER(user_data);
- handle = ctk_powermizer->attribute_handle;
-
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE,
&adaptive_clock);
if (ret == NvCtrlSuccess && ctk_powermizer->adaptive_clock_status) {
@@ -989,7 +995,7 @@ static gboolean update_powermizer_info(gpointer user_data)
/* Get the current values of clocks */
- ret = NvCtrlGetStringAttribute(ctk_powermizer->attribute_handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS,
&clock_string);
@@ -1023,9 +1029,10 @@ static gboolean update_powermizer_info(gpointer user_data)
g_free(s);
}
}
- XFree(clock_string);
+ free(clock_string);
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_POWER_SOURCE, &power_source);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_POWER_SOURCE,
+ &power_source);
if (ret == NvCtrlSuccess && ctk_powermizer->power_source) {
if (power_source == NV_CTRL_GPU_POWER_SOURCE_AC) {
@@ -1044,19 +1051,20 @@ static gboolean update_powermizer_info(gpointer user_data)
if (ctk_powermizer->pcie_gen_queriable) {
/* NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH */
- s = get_pcie_link_width_string(handle,
+ s = get_pcie_link_width_string(ctrl_target,
NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH);
gtk_label_set_text(GTK_LABEL(ctk_powermizer->link_width), s);
g_free(s);
/* NV_CTRL_GPU_PCIE_MAX_LINK_SPEED */
- s = get_pcie_link_speed_string(handle,
+ s = get_pcie_link_speed_string(ctrl_target,
NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED);
gtk_label_set_text(GTK_LABEL(ctk_powermizer->link_speed), s);
g_free(s);
}
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL,
+ ret = NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL,
&perf_level);
if (ret == NvCtrlSuccess && ctk_powermizer->performance_level) {
s = g_strdup_printf("%d", perf_level);
@@ -1145,7 +1153,7 @@ static void create_powermizer_menu_entry(CtkDropDownMenu *menu,
-GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_powermizer_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
CtkEvent *ctk_event)
{
@@ -1172,24 +1180,27 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
char *clock_string = NULL;
perfModeEntry pEntry;
- /* make sure we have a handle */
+ /* make sure we have a valid target */
- g_return_val_if_fail(handle != NULL, NULL);
+ g_return_val_if_fail((ctrl_target != NULL) &&
+ (ctrl_target->h != NULL), NULL);
/* check if this screen supports powermizer querying */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_POWER_SOURCE, &val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_POWER_SOURCE, &val);
if (ret == NvCtrlSuccess) {
power_source_available = TRUE;
}
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL,
+ ret = NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL,
&val);
if (ret == NvCtrlSuccess) {
perf_level_available = TRUE;
}
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE,
+ ret = NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE,
&val);
if (ret == NvCtrlSuccess) {
adaptive_clock_state_available = TRUE;
@@ -1198,7 +1209,7 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
/* Check if reporting value of the clock supported */
- ret = NvCtrlGetStringAttribute(handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS,
&clock_string);
@@ -1220,15 +1231,15 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
processor_clock_available = TRUE;
}
}
- XFree(clock_string);
+ free(clock_string);
/* NV_CTRL_GPU_PCIE_GENERATION */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_PCIE_GENERATION, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_PCIE_GENERATION, &tmp);
if (ret == NvCtrlSuccess) {
pcie_gen_queriable = TRUE;
}
-
+
/* return early if query to attributes fail */
if (!power_source_available && !perf_level_available &&
!adaptive_clock_state_available && !gpu_clock_available &&
@@ -1240,7 +1251,7 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
object = g_object_new(CTK_TYPE_POWERMIZER, NULL);
ctk_powermizer = CTK_POWERMIZER(object);
- ctk_powermizer->attribute_handle = handle;
+ ctk_powermizer->ctrl_target = ctrl_target;
ctk_powermizer->ctk_config = ctk_config;
ctk_powermizer->pcie_gen_queriable = pcie_gen_queriable;
ctk_powermizer->hasDecoupledClock = FALSE;
@@ -1438,7 +1449,7 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
/* Register a timer callback to update the temperatures */
s = g_strdup_printf("PowerMizer Monitor (GPU %d)",
- NvCtrlGetTargetId(handle));
+ NvCtrlGetTargetId(ctrl_target));
ctk_config_add_timer(ctk_powermizer->ctk_config,
DEFAULT_UPDATE_POWERMIZER_INFO_TIME_INTERVAL,
@@ -1449,7 +1460,7 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
/* PowerMizer Settings */
- ret = NvCtrlGetValidAttributeValues(ctk_powermizer->attribute_handle,
+ ret = NvCtrlGetValidAttributeValues(ctrl_target,
NV_CTRL_GPU_POWER_MIZER_MODE,
&valid_modes);
@@ -1551,14 +1562,14 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
* check if CUDA - Double Precision Boost support available.
*/
- ret = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE,
&val);
if (ret == NvCtrlSuccess) {
attribute = NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE;
cuda_dp_ui = TRUE;
} else {
- ret1 = NvCtrlGetAttribute(handle,
+ ret1 = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT,
&val);
if (ret1 == NvCtrlSuccess) {
@@ -1730,6 +1741,7 @@ static void set_powermizer_menu_label_txt(CtkPowermizer *ctk_powermizer,
static void update_powermizer_menu_info(CtkPowermizer *ctk_powermizer)
{
+ CtrlTarget *ctrl_target = ctk_powermizer->ctrl_target;
gint powerMizerMode, defaultPowerMizerMode;
ReturnStatus ret1, ret2;
CtkDropDownMenu *menu;
@@ -1740,11 +1752,11 @@ static void update_powermizer_menu_info(CtkPowermizer *ctk_powermizer)
menu = CTK_DROP_DOWN_MENU(ctk_powermizer->powermizer_menu);
- ret1 = NvCtrlGetAttribute(ctk_powermizer->attribute_handle,
+ ret1 = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GPU_POWER_MIZER_MODE,
&powerMizerMode);
- ret2 = NvCtrlGetAttribute(ctk_powermizer->attribute_handle,
+ ret2 = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GPU_POWER_MIZER_DEFAULT_MODE,
&defaultPowerMizerMode);
@@ -1775,6 +1787,7 @@ static void powermizer_menu_changed(GtkWidget *widget,
gpointer user_data)
{
CtkPowermizer *ctk_powermizer = CTK_POWERMIZER(user_data);
+ CtrlTarget *ctrl_target = ctk_powermizer->ctrl_target;
CtkDropDownMenu *menu = CTK_DROP_DOWN_MENU(widget);
guint powerMizerMode;
ReturnStatus ret;
@@ -1783,7 +1796,7 @@ static void powermizer_menu_changed(GtkWidget *widget,
powerMizerMode = ctk_drop_down_menu_get_current_value(menu);
- ret = NvCtrlSetAttribute(ctk_powermizer->attribute_handle,
+ ret = NvCtrlSetAttribute(ctrl_target,
NV_CTRL_GPU_POWER_MIZER_MODE,
powerMizerMode);
if (ret != NvCtrlSuccess) {
@@ -1900,12 +1913,16 @@ static void dp_update_config_status(CtkPowermizer *ctk_powermizer, gboolean val)
*/
static void dp_configuration_update_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkPowermizer *ctk_powermizer = CTK_POWERMIZER(user_data);
- ctk_powermizer->dp_enabled = event_struct->value;
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
+ ctk_powermizer->dp_enabled = event->int_attr.value;
/* set CUDA - Double Precision Boost configuration buttion status */
dp_set_config_status(ctk_powermizer);
@@ -1925,6 +1942,7 @@ static void dp_config_button_toggled(GtkWidget *widget,
{
gboolean enabled;
CtkPowermizer *ctk_powermizer = CTK_POWERMIZER(user_data);
+ CtrlTarget *ctrl_target = ctk_powermizer->ctrl_target;
ReturnStatus ret;
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
@@ -1935,7 +1953,7 @@ static void dp_config_button_toggled(GtkWidget *widget,
}
/* set the newly specified CUDA - Double Precision Boost value */
- ret = NvCtrlSetAttribute(ctk_powermizer->attribute_handle,
+ ret = NvCtrlSetAttribute(ctrl_target,
ctk_powermizer->attribute,
enabled);
if (ret != NvCtrlSuccess) {
diff --git a/src/gtk+-2.x/ctkpowermizer.h b/src/gtk+-2.x/ctkpowermizer.h
index 7f55fe1..42f4595 100644
--- a/src/gtk+-2.x/ctkpowermizer.h
+++ b/src/gtk+-2.x/ctkpowermizer.h
@@ -20,7 +20,6 @@
#ifndef __CTK_POWERMIZER_H__
#define __CTK_POWERMIZER_H__
-#include "NvCtrlAttributes.h"
#include "ctkconfig.h"
#include "ctkevent.h"
@@ -50,7 +49,7 @@ struct _CtkPowermizer
{
GtkVBox parent;
- NvCtrlAttributeHandle *attribute_handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
GtkWidget *adaptive_clock_status;
@@ -90,8 +89,8 @@ struct _CtkPowermizerClass
};
GType ctk_powermizer_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_powermizer_new (NvCtrlAttributeHandle *,
- CtkConfig *, CtkEvent *);
+GtkWidget* ctk_powermizer_new (CtrlTarget *, CtkConfig *,
+ CtkEvent *);
GtkTextBuffer* ctk_powermizer_create_help (GtkTextTagTable *, CtkPowermizer *);
void ctk_powermizer_start_timer (GtkWidget *);
diff --git a/src/gtk+-2.x/ctkscreen.c b/src/gtk+-2.x/ctkscreen.c
index 6c384a3..b7e465d 100644
--- a/src/gtk+-2.x/ctkscreen.c
+++ b/src/gtk+-2.x/ctkscreen.c
@@ -35,7 +35,7 @@
#include "ctkbanner.h"
void ctk_screen_event_handler(GtkWidget *widget,
- XRRScreenChangeNotifyEvent *ev,
+ CtrlEvent *event,
gpointer data);
static void info_update_gpu_error(GObject *object, gpointer arg1,
@@ -72,11 +72,11 @@ GType ctk_screen_get_type(
/* Generates a list of display devices for the logical X screen
- * given as "handle".
+ * given as CtrlTarget.
*/
-static gchar *make_display_device_list(NvCtrlAttributeHandle *handle)
+static gchar *make_display_device_list(CtrlTarget *ctrl_target)
{
- return create_display_name_list_string(handle,
+ return create_display_name_list_string(ctrl_target,
NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN);
} /* make_display_device_list() */
@@ -121,8 +121,7 @@ in this Software without prior written authorization from The Open Group.
*
*/
-GtkWidget* ctk_screen_new(NvCtrlAttributeHandle *handle,
- CtkEvent *ctk_event)
+GtkWidget* ctk_screen_new(CtrlTarget *ctrl_target, CtkEvent *ctk_event)
{
GObject *object;
CtkScreen *ctk_screen;
@@ -157,15 +156,15 @@ GtkWidget* ctk_screen_new(NvCtrlAttributeHandle *handle,
* get the data that we will display below
*/
- screen_number = g_strdup_printf("%d", NvCtrlGetTargetId(handle));
-
- display_name = NvCtrlGetDisplayName(handle);
-
+ screen_number = g_strdup_printf("%d", NvCtrlGetTargetId(ctrl_target));
+
+ display_name = NvCtrlGetDisplayName(ctrl_target);
+
dimensions = g_strdup_printf("%dx%d pixels (%dx%d millimeters)",
- NvCtrlGetScreenWidth(handle),
- NvCtrlGetScreenHeight(handle),
- NvCtrlGetScreenWidthMM(handle),
- NvCtrlGetScreenHeightMM(handle));
+ NvCtrlGetScreenWidth(ctrl_target),
+ NvCtrlGetScreenHeight(ctrl_target),
+ NvCtrlGetScreenWidthMM(ctrl_target),
+ NvCtrlGetScreenHeightMM(ctrl_target));
/*
* there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
@@ -175,40 +174,42 @@ GtkWidget* ctk_screen_new(NvCtrlAttributeHandle *handle,
* = N * 25.4 pixels / M inch
*/
- xres = (((double) NvCtrlGetScreenWidth(handle)) * 25.4) /
- ((double) NvCtrlGetScreenWidthMM(handle));
+ xres = (((double) NvCtrlGetScreenWidth(ctrl_target)) * 25.4) /
+ ((double) NvCtrlGetScreenWidthMM(ctrl_target));
- yres = (((double) NvCtrlGetScreenHeight(handle)) * 25.4) /
- ((double) NvCtrlGetScreenHeightMM(handle));
+ yres = (((double) NvCtrlGetScreenHeight(ctrl_target)) * 25.4) /
+ ((double) NvCtrlGetScreenHeightMM(ctrl_target));
resolution = g_strdup_printf("%dx%d dots per inch",
(int) (xres + 0.5),
(int) (yres + 0.5));
- depth = g_strdup_printf("%d", NvCtrlGetScreenPlanes(handle));
+ depth = g_strdup_printf("%d", NvCtrlGetScreenPlanes(ctrl_target));
/* get the list of GPUs driving this (logical) X screen */
gpus = NULL;
- ret = NvCtrlGetBinaryAttribute(handle,
+ ret = NvCtrlGetBinaryAttribute(ctrl_target,
0,
NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN,
(unsigned char **)(&pData),
&len);
if (ret == NvCtrlSuccess) {
for (i = 1; i <= pData[0]; i++) {
+ CtrlTarget *gpu_target;
gchar *tmp_str;
gchar *gpu_name;
- Bool valid;
-
- valid =
- XNVCTRLQueryTargetStringAttribute(NvCtrlGetDisplayPtr(handle),
- NV_CTRL_TARGET_TYPE_GPU,
- pData[i],
- 0,
- NV_CTRL_STRING_PRODUCT_NAME,
- &gpu_name);
- if (!valid) {
+
+ gpu_target = NvCtrlGetTarget(ctrl_target->system,
+ GPU_TARGET, pData[i]);
+ if (gpu_target == NULL) {
+ continue;
+ }
+
+ ret = NvCtrlGetStringAttribute(gpu_target,
+ NV_CTRL_STRING_PRODUCT_NAME,
+ &gpu_name);
+ if (ret != NvCtrlSuccess) {
gpu_name = "Unknown";
}
if (gpus) {
@@ -217,8 +218,8 @@ GtkWidget* ctk_screen_new(NvCtrlAttributeHandle *handle,
} else {
tmp_str = g_strdup_printf("%s (GPU %d)", gpu_name, pData[i]);
}
- if (valid) {
- XFree(gpu_name);
+ if (ret == NvCtrlSuccess) {
+ free(gpu_name);
}
g_free(gpus);
gpus = tmp_str;
@@ -226,17 +227,17 @@ GtkWidget* ctk_screen_new(NvCtrlAttributeHandle *handle,
if (!gpus) {
gpus = g_strdup("None");
}
- XFree(pData);
+ free(pData);
}
/* get the list of Display Devices displaying this X screen */
- displays = make_display_device_list(handle);
+ displays = make_display_device_list(ctrl_target);
/* get the number of gpu errors occurred */
gpu_errors = 0;
- ret = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_NUM_GPU_ERRORS_RECOVERED,
(int *)&gpu_errors);
@@ -247,12 +248,12 @@ GtkWidget* ctk_screen_new(NvCtrlAttributeHandle *handle,
object = g_object_new(CTK_TYPE_SCREEN, NULL);
ctk_screen = CTK_SCREEN(object);
- /* cache the attribute handle */
+ /* cache the control target */
- ctk_screen->handle = handle;
+ ctk_screen->ctrl_target = ctrl_target;
/* get the stereo mode set for this X screen */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_STEREO, (int *)&stereo_mode);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_STEREO, (int *)&stereo_mode);
ctk_screen->stereo_available = (ret == NvCtrlSuccess);
/* set container properties of the object */
@@ -410,14 +411,21 @@ GtkTextBuffer *ctk_screen_create_help(GtkTextTagTable *table,
* with the new screen information.
*/
void ctk_screen_event_handler(GtkWidget *widget,
- XRRScreenChangeNotifyEvent *ev,
+ CtrlEvent *event,
gpointer data)
{
CtkScreen *ctk_screen = (CtkScreen *) data;
+ gchar *dimensions;
+
+ if (event->type != CTRL_EVENT_TYPE_SCREEN_CHANGE) {
+ return;
+ }
- gchar *dimensions = g_strdup_printf("%dx%d pixels (%dx%d millimeters)",
- ev->width, ev->height,
- ev->mwidth, ev->mheight);
+ dimensions = g_strdup_printf("%dx%d pixels (%dx%d millimeters)",
+ event->screen_change.width,
+ event->screen_change.height,
+ event->screen_change.mwidth,
+ event->screen_change.mheight);
gtk_label_set_text(GTK_LABEL(ctk_screen->dimensions),
dimensions);
@@ -442,7 +450,7 @@ static void info_update_gpu_error(GObject *object, gpointer arg1,
char tmp[16];
/* get the number of gpu errors occurred */
- ret = NvCtrlGetAttribute(ctk_screen->handle,
+ ret = NvCtrlGetAttribute(ctk_screen->ctrl_target,
NV_CTRL_NUM_GPU_ERRORS_RECOVERED,
(int *)&gpu_errors);
if (ret == NvCtrlSuccess) {
diff --git a/src/gtk+-2.x/ctkscreen.h b/src/gtk+-2.x/ctkscreen.h
index c950a75..5321a16 100644
--- a/src/gtk+-2.x/ctkscreen.h
+++ b/src/gtk+-2.x/ctkscreen.h
@@ -22,7 +22,7 @@
#include <gtk/gtk.h>
-#include "NvCtrlAttributes.h"
+#include "query-assign.h"
#include "ctkevent.h"
G_BEGIN_DECLS
@@ -52,7 +52,7 @@ struct _CtkScreen
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
GtkWidget *dimensions;
GtkWidget *displays;
@@ -67,8 +67,7 @@ struct _CtkScreenClass
};
GType ctk_screen_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_screen_new (NvCtrlAttributeHandle *handle,
- CtkEvent *ctk_event);
+GtkWidget* ctk_screen_new (CtrlTarget *ctrl_target, CtkEvent *ctk_event);
GtkTextBuffer *ctk_screen_create_help(GtkTextTagTable *, CtkScreen *,
const gchar *);
diff --git a/src/gtk+-2.x/ctkserver.c b/src/gtk+-2.x/ctkserver.c
index 755c30b..4c8d8a8 100644
--- a/src/gtk+-2.x/ctkserver.c
+++ b/src/gtk+-2.x/ctkserver.c
@@ -96,10 +96,10 @@ in this Software without prior written authorization from The Open Group.
***********************************************************************
*
*/
-static gchar * get_server_vendor_version(NvCtrlAttributeHandle *handle)
+static gchar * get_server_vendor_version(CtrlTarget *ctrl_target)
{
- int vendrel = NvCtrlGetVendorRelease(handle);
- char *vendstr = NvCtrlGetServerVendor(handle);
+ int vendrel = NvCtrlGetVendorRelease(ctrl_target);
+ char *vendstr = NvCtrlGetServerVendor(ctrl_target);
gchar *version = NULL;
gchar *tmp;
@@ -235,7 +235,7 @@ static gchar * get_server_vendor_version(NvCtrlAttributeHandle *handle)
* CTK Server widget creation
*
*/
-GtkWidget* ctk_server_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_server_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config)
{
GObject *object;
@@ -251,7 +251,7 @@ GtkWidget* ctk_server_new(NvCtrlAttributeHandle *handle,
gchar *arch;
gchar *driver_version;
- gchar *dname = NvCtrlGetDisplayName(handle);
+ gchar *dname = NvCtrlGetDisplayName(ctrl_target);
gchar *display_name;
gchar *server_version;
gchar *vendor_str;
@@ -267,10 +267,11 @@ GtkWidget* ctk_server_new(NvCtrlAttributeHandle *handle,
* get the data that we will display below
*
*/
-
+
/* NV_CTRL_XINERAMA */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_XINERAMA, &xinerama_enabled);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_XINERAMA,
+ &xinerama_enabled);
if (ret != NvCtrlSuccess) {
xinerama_enabled = FALSE;
}
@@ -278,7 +279,7 @@ GtkWidget* ctk_server_new(NvCtrlAttributeHandle *handle,
/* NV_CTRL_OPERATING_SYSTEM */
os_val = NV_CTRL_OPERATING_SYSTEM_LINUX;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_OPERATING_SYSTEM, &os_val);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_OPERATING_SYSTEM, &os_val);
os = NULL;
if (ret == NvCtrlSuccess) {
if (os_val == NV_CTRL_OPERATING_SYSTEM_LINUX) os = "Linux";
@@ -288,8 +289,8 @@ GtkWidget* ctk_server_new(NvCtrlAttributeHandle *handle,
if (!os) os = "Unknown";
/* NV_CTRL_ARCHITECTURE */
-
- ret = NvCtrlGetAttribute(handle, NV_CTRL_ARCHITECTURE, &tmp);
+
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_ARCHITECTURE, &tmp);
arch = NULL;
if (ret == NvCtrlSuccess) {
if (tmp == NV_CTRL_ARCHITECTURE_X86) arch = "x86";
@@ -303,10 +304,7 @@ GtkWidget* ctk_server_new(NvCtrlAttributeHandle *handle,
/* NV_CTRL_STRING_NVIDIA_DRIVER_VERSION */
- ret = NvCtrlGetStringAttribute(handle,
- NV_CTRL_STRING_NVIDIA_DRIVER_VERSION,
- &driver_version);
- if (ret != NvCtrlSuccess) driver_version = NULL;
+ driver_version = get_nvidia_driver_version(ctrl_target);
/* Display Name */
@@ -315,43 +313,40 @@ GtkWidget* ctk_server_new(NvCtrlAttributeHandle *handle,
/* X Server Version */
server_version = g_strdup_printf("%d.%d",
- NvCtrlGetProtocolVersion(handle),
- NvCtrlGetProtocolRevision(handle));
+ NvCtrlGetProtocolVersion(ctrl_target),
+ NvCtrlGetProtocolRevision(ctrl_target));
/* Server Vendor String */
-
- vendor_str = g_strdup(NvCtrlGetServerVendor(handle));
+
+ vendor_str = g_strdup(NvCtrlGetServerVendor(ctrl_target));
/* Server Vendor Version */
- vendor_ver = get_server_vendor_version(handle);
+ vendor_ver = get_server_vendor_version(ctrl_target);
/* NV_CTRL_STRING_NV_CONTROL_VERSION */
- ret = NvCtrlGetStringAttribute(handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_NV_CONTROL_VERSION,
&nv_control_server_version);
if (ret != NvCtrlSuccess) nv_control_server_version = NULL;
-
+
/* # Logical X Screens */
-
+
if (xinerama_enabled) {
num_screens = g_strdup_printf("%d (Xinerama)",
- NvCtrlGetScreenCount(handle));
+ NvCtrlGetScreenCount(ctrl_target));
} else {
- num_screens = g_strdup_printf("%d", NvCtrlGetScreenCount(handle));
+ num_screens = g_strdup_printf("%d",
+ NvCtrlGetScreenCount(ctrl_target));
}
-
+
/* now, create the object */
-
+
object = g_object_new(CTK_TYPE_SERVER, NULL);
ctk_object = CTK_SERVER(object);
- /* cache the attribute handle */
-
- ctk_object->handle = handle;
-
/* set container properties of the object */
gtk_box_set_spacing(GTK_BOX(ctk_object), 10);
@@ -469,20 +464,20 @@ GtkWidget* ctk_server_new(NvCtrlAttributeHandle *handle,
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
}
-
+
g_free(display_name);
g_free(os);
- XFree(driver_version);
-
+ free(driver_version);
+
g_free(server_version);
g_free(vendor_str);
g_free(vendor_ver);
- XFree(nv_control_server_version);
+ free(nv_control_server_version);
g_free(num_screens);
gtk_widget_show_all(GTK_WIDGET(object));
-
+
return GTK_WIDGET(object);
}
diff --git a/src/gtk+-2.x/ctkserver.h b/src/gtk+-2.x/ctkserver.h
index 240262d..76eb5b1 100644
--- a/src/gtk+-2.x/ctkserver.h
+++ b/src/gtk+-2.x/ctkserver.h
@@ -51,7 +51,6 @@ typedef struct _CtkServer
GtkVBox parent;
CtkConfig *ctk_config;
- NvCtrlAttributeHandle *handle;
} CtkServer;
@@ -62,7 +61,7 @@ typedef struct _CtkServerClass
GType ctk_server_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_server_new (NvCtrlAttributeHandle *, CtkConfig *);
+GtkWidget* ctk_server_new (CtrlTarget *, CtkConfig *);
GtkTextBuffer *ctk_server_create_help(GtkTextTagTable *,
CtkServer *);
diff --git a/src/gtk+-2.x/ctkslimm.c b/src/gtk+-2.x/ctkslimm.c
index 3d2529e..784c3dd 100644
--- a/src/gtk+-2.x/ctkslimm.c
+++ b/src/gtk+-2.x/ctkslimm.c
@@ -843,6 +843,7 @@ static Bool parse_slimm_layout(CtkSLIMM *ctk_slimm,
int *voverlap,
int *grid_config_id)
{
+ CtrlTarget *ctrl_target = ctk_slimm->ctrl_target;
ReturnStatus ret;
char *metamode_str = NULL;
char *str;
@@ -898,7 +899,7 @@ static Bool parse_slimm_layout(CtkSLIMM *ctk_slimm,
/* Get the current metamode string */
- ret = NvCtrlGetStringAttribute(ctk_slimm->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_CURRENT_METAMODE,
&metamode_str);
if ((ret != NvCtrlSuccess) || !metamode_str) {
@@ -1108,8 +1109,8 @@ static Bool parse_slimm_layout(CtkSLIMM *ctk_slimm,
*hoverlap += (*cur_modeline)->data.hdisplay;
}
}
-
- XFree(metamode_str);
+
+ free(metamode_str);
return TRUE;
@@ -1117,16 +1118,14 @@ static Bool parse_slimm_layout(CtkSLIMM *ctk_slimm,
*hoverlap = 0;
*voverlap = 0;
*grid_config_id = 0;
-
+
if (err_msg) {
nv_warning_msg("Unable to determine current SLI Mosaic Mode "
"configuration (will fall back to default): %s\n",
err_msg);
}
- if (metamode_str) {
- XFree(metamode_str);
- }
+ free(metamode_str);
return FALSE;
}
@@ -1273,8 +1272,9 @@ static int get_display_stereo_mode(nvDisplayPtr display)
}
}
-GtkWidget* ctk_slimm_new(NvCtrlAttributeHandle *handle,
- CtkEvent *ctk_event, CtkConfig *ctk_config)
+GtkWidget* ctk_slimm_new(CtrlTarget *ctrl_target,
+ CtkEvent *ctk_event,
+ CtkConfig *ctk_config)
{
GObject *object;
CtkSLIMM *ctk_slimm;
@@ -1308,20 +1308,17 @@ GtkWidget* ctk_slimm_new(NvCtrlAttributeHandle *handle,
int count;
Bool trust_slimm_available = FALSE;
- int vcs_target_count;
int hoverlap = 0;
int voverlap = 0;
int grid_config_id = 0;
/* now, create the object */
-
+
object = g_object_new(CTK_TYPE_SLIMM, NULL);
ctk_slimm = CTK_SLIMM(object);
- /* cache the attribute handle */
-
- ctk_slimm->handle = handle;
+ ctk_slimm->ctrl_target = ctrl_target;
ctk_slimm->ctk_config = ctk_config;
ctk_object = ctk_slimm;
@@ -1330,41 +1327,40 @@ GtkWidget* ctk_slimm_new(NvCtrlAttributeHandle *handle,
* This is used to not trust old X drivers which always reported
* it available (on NV50+).
*/
- ret = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_ATTR_NV_MAJOR_VERSION, &major);
- ret1 = NvCtrlGetAttribute(handle,
+ ret1 = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_ATTR_NV_MINOR_VERSION, &minor);
if ((ret == NvCtrlSuccess) && (ret1 == NvCtrlSuccess) &&
((major > 1) || ((major == 1) && (minor > 23)))) {
trust_slimm_available = TRUE;
}
-
- vcs_target_count = ctk_config->pCtrlHandles->targets[VCS_TARGET].n;
/* return on old X drivers if target is other than VCS. */
- if (!vcs_target_count && !trust_slimm_available) {
+ if (!ctk_config->pCtrlSystem->targets[VCS_TARGET] &&
+ !trust_slimm_available) {
return NULL;
}
/* Check if this screen supports SLI Mosaic Mode */
- ret = NvCtrlGetAttribute(ctk_object->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE, &val);
- if ((ret == NvCtrlSuccess) &&
+ if ((ret == NvCtrlSuccess) &&
(val == NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE_FALSE)) {
/* Mosaic not supported */
return NULL;
}
/* Query the maximum screen sizes */
- ret = NvCtrlGetAttribute(ctk_object->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_MAX_SCREEN_WIDTH,
&ctk_slimm->max_screen_width);
if (ret != NvCtrlSuccess) {
return NULL;
}
- ret = NvCtrlGetAttribute(ctk_object->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_MAX_SCREEN_HEIGHT,
&ctk_slimm->max_screen_height);
if (ret != NvCtrlSuccess) {
@@ -1377,7 +1373,7 @@ GtkWidget* ctk_slimm_new(NvCtrlAttributeHandle *handle,
*/
/* Load the layout structure from the X server */
- layout = layout_load_from_server(handle, &err_str);
+ layout = layout_load_from_server(ctrl_target, &err_str);
if (!err_str && layout) {
nvGpuPtr gpu;
@@ -1754,7 +1750,7 @@ GtkWidget* ctk_slimm_new(NvCtrlAttributeHandle *handle,
GTK_EXPAND | GTK_FILL, 0, 0);
/* If current SLI Mode != Mosaic, disable UI elements initially */
- ret = NvCtrlGetStringAttribute(ctk_slimm->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_SLI_MODE,
&sli_mode);
@@ -1766,9 +1762,7 @@ GtkWidget* ctk_slimm_new(NvCtrlAttributeHandle *handle,
slimm_checkbox_toggled(ctk_slimm->cbtn_slimm_enable, (gpointer) ctk_slimm);
}
- if (sli_mode) {
- XFree(sli_mode);
- }
+ free(sli_mode);
gtk_widget_show_all(GTK_WIDGET(object));
diff --git a/src/gtk+-2.x/ctkslimm.h b/src/gtk+-2.x/ctkslimm.h
index 9e21a4c..e888b88 100644
--- a/src/gtk+-2.x/ctkslimm.h
+++ b/src/gtk+-2.x/ctkslimm.h
@@ -22,7 +22,6 @@
#include <gtk/gtk.h>
-#include "NvCtrlAttributes.h"
#include "ctkevent.h"
#include "ctkdisplaylayout.h"
#include "ctkconfig.h"
@@ -56,7 +55,7 @@ struct _CtkSLIMM
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
GtkWidget *mnu_display_config;
@@ -88,7 +87,7 @@ struct _CtkSLIMMClass
};
GType ctk_slimm_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_slimm_new (NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_slimm_new (CtrlTarget *ctrl_target,
CtkEvent *ctk_event, CtkConfig *ctk_config);
GtkTextBuffer *ctk_slimm_create_help(GtkTextTagTable *, const gchar *);
diff --git a/src/gtk+-2.x/ctkthermal.c b/src/gtk+-2.x/ctkthermal.c
index cf47e4d..890f07e 100644
--- a/src/gtk+-2.x/ctkthermal.c
+++ b/src/gtk+-2.x/ctkthermal.c
@@ -37,7 +37,7 @@ static void sync_gui_sensitivity(CtkThermal *ctk_thermal);
static void sync_gui_to_modify_cooler_level(CtkThermal *ctk_thermal);
static gboolean sync_gui_to_update_cooler_event(gpointer user_data);
static void cooler_control_checkbox_toggled(GtkWidget *widget, gpointer user_data);
-static void cooler_operating_level_changed(GObject *object, gpointer arg1,
+static void cooler_operating_level_changed(GObject *object, CtrlEvent *event,
gpointer user_data);
static void apply_button_clicked(GtkWidget *widget, gpointer user_data);
static void reset_button_clicked(GtkWidget *widget, gpointer user_data);
@@ -46,7 +46,6 @@ static void adjustment_value_changed(GtkAdjustment *adjustment,
static void draw_sensor_gui(GtkWidget *vbox1, CtkThermal *ctk_thermal,
gboolean new_target_type, gint cur_sensor_idx,
- NvCtrlAttributeHandle *sensor_handle,
gint reading, gint lower, gint upper,
gint target, gint provider);
static GtkWidget *pack_gauge(GtkWidget *hbox, gint lower, gint upper,
@@ -237,7 +236,7 @@ static gboolean update_cooler_info(gpointer user_data)
GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
free(tmp_str);
- ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].handle,
+ ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target,
NV_CTRL_THERMAL_COOLER_SPEED,
&speed);
if (ret == NvCtrlSuccess) {
@@ -252,7 +251,7 @@ static gboolean update_cooler_info(gpointer user_data)
GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
free(tmp_str);
- ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].handle,
+ ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target,
NV_CTRL_THERMAL_COOLER_LEVEL,
&level);
if (ret != NvCtrlSuccess) {
@@ -266,7 +265,7 @@ static gboolean update_cooler_info(gpointer user_data)
GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
free(tmp_str);
- ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].handle,
+ ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target,
NV_CTRL_THERMAL_COOLER_CONTROL_TYPE,
&cooler_type);
if (ret != NvCtrlSuccess) {
@@ -286,7 +285,7 @@ static gboolean update_cooler_info(gpointer user_data)
GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
free(tmp_str);
- ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].handle,
+ ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target,
NV_CTRL_THERMAL_COOLER_TARGET,
&cooler_target);
if (ret != NvCtrlSuccess) {
@@ -331,17 +330,15 @@ static gboolean update_cooler_info(gpointer user_data)
static gboolean update_thermal_info(gpointer user_data)
{
gint reading, ambient;
- CtkThermal *ctk_thermal;
- NvCtrlAttributeHandle *handle;
+ CtkThermal *ctk_thermal = CTK_THERMAL(user_data);
gint ret, i, core;
gchar *s;
- ctk_thermal = CTK_THERMAL(user_data);
-
if (!ctk_thermal->thermal_sensor_target_type_supported) {
- handle = ctk_thermal->attribute_handle;
+ CtrlTarget *ctrl_target = ctk_thermal->ctrl_target;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CORE_TEMPERATURE, &core);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_CORE_TEMPERATURE,
+ &core);
if (ret != NvCtrlSuccess) {
/* thermal information no longer available */
return FALSE;
@@ -355,7 +352,8 @@ static gboolean update_thermal_info(gpointer user_data)
ctk_gauge_draw(CTK_GAUGE(ctk_thermal->core_gauge));
if (ctk_thermal->ambient_label) {
- ret = NvCtrlGetAttribute(handle, NV_CTRL_AMBIENT_TEMPERATURE,
+ ret = NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_AMBIENT_TEMPERATURE,
&ambient);
if (ret != NvCtrlSuccess) {
/* thermal information no longer available */
@@ -367,9 +365,10 @@ static gboolean update_thermal_info(gpointer user_data)
}
} else {
for (i = 0; i < ctk_thermal->sensor_count; i++) {
- handle = ctk_thermal->sensor_info[i].handle;
+ CtrlTarget *ctrl_target = ctk_thermal->sensor_info[i].ctrl_target;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_THERMAL_SENSOR_READING,
+ ret = NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_THERMAL_SENSOR_READING,
&reading);
/* querying THERMAL_SENSOR_READING failed: assume the temperature is 0 */
if (ret != NvCtrlSuccess) {
@@ -407,6 +406,7 @@ static gboolean update_thermal_info(gpointer user_data)
*/
static void cooler_control_state_update_gui(CtkThermal *ctk_thermal)
{
+ CtrlTarget *ctrl_target = ctk_thermal->ctrl_target;
ReturnStatus ret;
int value;
gboolean enabled;
@@ -417,7 +417,7 @@ static void cooler_control_state_update_gui(CtkThermal *ctk_thermal)
* because the set might have failed.
*/
- ret = NvCtrlGetAttribute(ctk_thermal->attribute_handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_GPU_COOLER_MANUAL_CONTROL,
&value);
if (ret != NvCtrlSuccess) {
@@ -451,6 +451,7 @@ static void cooler_control_state_update_gui(CtkThermal *ctk_thermal)
static void cooler_control_state_toggled(GtkWidget *widget, gpointer user_data)
{
CtkThermal *ctk_thermal = CTK_THERMAL(user_data);
+ CtrlTarget *ctrl_target = ctk_thermal->ctrl_target;
gboolean enabled;
int value;
@@ -462,8 +463,8 @@ static void cooler_control_state_toggled(GtkWidget *widget, gpointer user_data)
/* Update the server */
- NvCtrlSetAttribute(ctk_thermal->attribute_handle,
- NV_CTRL_GPU_COOLER_MANUAL_CONTROL, value);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_GPU_COOLER_MANUAL_CONTROL,
+ value);
/* Update the GUI */
@@ -480,7 +481,8 @@ static void cooler_control_state_toggled(GtkWidget *widget, gpointer user_data)
*
*/
static void cooler_control_state_received(GObject *object,
- gpointer arg1, gpointer user_data)
+ CtrlEvent *event,
+ gpointer user_data)
{
CtkThermal *ctk_thermal = CTK_THERMAL(user_data);
@@ -571,9 +573,10 @@ static void apply_button_clicked(GtkWidget *widget, gpointer user_data)
}
}
- ret = NvCtrlSetAttribute(ctk_thermal->cooler_control[i].handle,
- NV_CTRL_THERMAL_COOLER_LEVEL,
- cooler_level);
+ ret =
+ NvCtrlSetAttribute(ctk_thermal->cooler_control[i].ctrl_target,
+ NV_CTRL_THERMAL_COOLER_LEVEL,
+ cooler_level);
if ( ret != NvCtrlSuccess ) {
ctk_config_statusbar_message(ctk_thermal->ctk_config,
@@ -619,7 +622,7 @@ static void reset_button_clicked(GtkWidget *widget, gpointer user_data)
/* Set cooler related values to default */
for (i = 0; i < ctk_thermal->cooler_count; i++) {
- ret = NvCtrlSetAttribute(ctk_thermal->cooler_control[i].handle,
+ ret = NvCtrlSetAttribute(ctk_thermal->cooler_control[i].ctrl_target,
NV_CTRL_THERMAL_COOLER_LEVEL_SET_DEFAULT,
NV_CTRL_THERMAL_COOLER_LEVEL_SET_DEFAULT);
if ( ret != NvCtrlSuccess ) {
@@ -708,7 +711,7 @@ static void sync_gui_to_modify_cooler_level(CtkThermal *ctk_thermal)
for (i = 0; i < ctk_thermal->cooler_count; i++) {
/* Obtain the current value and range of the fan speed */
- ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].handle,
+ ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target,
NV_CTRL_THERMAL_COOLER_LEVEL,
&cooler_level);
if ( ret != NvCtrlSuccess ) {
@@ -721,7 +724,7 @@ static void sync_gui_to_modify_cooler_level(CtkThermal *ctk_thermal)
if ( ctk_thermal->cooler_control[i].adjustment ) {
ret = NvCtrlGetValidAttributeValues
- (ctk_thermal->cooler_control[i].handle,
+ (ctk_thermal->cooler_control[i].ctrl_target,
NV_CTRL_THERMAL_COOLER_LEVEL,
&cooler_range);
if ( ret != NvCtrlSuccess ) {
@@ -808,7 +811,8 @@ static gboolean sync_gui_to_update_cooler_event(gpointer user_data)
* Callback function when another NV_CONTROL client changed cooler level.
*
*/
-static void cooler_operating_level_changed(GObject *object, gpointer arg1,
+static void cooler_operating_level_changed(GObject *object,
+ CtrlEvent *event,
gpointer user_data)
{
/* sync_gui_to_modify_cooler_level() to be called once when all other
@@ -932,7 +936,6 @@ static GtkWidget *pack_gauge(GtkWidget *hbox, gint lower, gint upper,
*/
static void draw_sensor_gui(GtkWidget *vbox1, CtkThermal *ctk_thermal,
gboolean new_target_type, gint cur_sensor_idx,
- NvCtrlAttributeHandle *sensor_handle,
gint reading, gint lower, gint upper,
gint target, gint provider)
{
@@ -1036,13 +1039,13 @@ static void draw_sensor_gui(GtkWidget *vbox1, CtkThermal *ctk_thermal,
-GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_thermal_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
CtkEvent *ctk_event)
{
GObject *object;
CtkThermal *ctk_thermal;
- CtrlHandles *h;
+ CtrlSystem *system;
GtkAdjustment *adjustment;
GtkWidget *hbox = NULL, *hbox1, *hbox2, *table, *vbox;
GtkWidget *frame, *banner, *label;
@@ -1054,8 +1057,8 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
GtkWidget *alignment;
ReturnStatus ret;
ReturnStatus ret1;
- NvCtrlAttributeHandle *cooler_handle;
- NvCtrlAttributeHandle *sensor_handle;
+ CtrlTarget *cooler_target;
+ CtrlTarget *sensor_target;
NVCTRLAttributeValidValuesRec cooler_range;
NVCTRLAttributeValidValuesRec sensor_range;
gint trigger, core, ambient;
@@ -1077,7 +1080,8 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
/* make sure we have a handle */
- g_return_val_if_fail(handle != NULL, NULL);
+ g_return_val_if_fail((ctrl_target != NULL) &&
+ (ctrl_target->h != NULL), NULL);
/*
* Check for NV-CONTROL protocol version.
@@ -1085,9 +1089,9 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
* This used for backward compatibility between new nvidia-settings
* and older X driver
*/
- ret = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_ATTR_NV_MAJOR_VERSION, &major);
- ret1 = NvCtrlGetAttribute(handle,
+ ret1 = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_ATTR_NV_MINOR_VERSION, &minor);
if ((ret == NvCtrlSuccess) && (ret1 == NvCtrlSuccess) &&
@@ -1098,19 +1102,22 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
if (!thermal_sensor_target_type_supported) {
/* check if this screen supports thermal querying */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CORE_TEMPERATURE, &core);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_CORE_TEMPERATURE,
+ &core);
if (ret != NvCtrlSuccess) {
/* thermal information unavailable */
return NULL;
}
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_MAX_CORE_THRESHOLD, &upper);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_MAX_CORE_THRESHOLD,
+ &upper);
if (ret != NvCtrlSuccess) {
/* thermal information unavailable */
return NULL;
}
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CORE_THRESHOLD, &trigger);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_CORE_THRESHOLD,
+ &trigger);
if (ret != NvCtrlSuccess) {
/* thermal information unavailable */
return NULL;
@@ -1118,16 +1125,16 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
}
/* Query the list of sensors attached to this GPU */
- ret = NvCtrlGetBinaryAttribute(handle, 0,
+ ret = NvCtrlGetBinaryAttribute(ctrl_target, 0,
NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU,
(unsigned char **)(&pDataSensor), &len);
if ( ret == NvCtrlSuccess ) {
sensor_count = pDataSensor[0];
}
-
+
/* Query the list of coolers attached to this GPU */
- ret = NvCtrlGetBinaryAttribute(handle, 0,
+ ret = NvCtrlGetBinaryAttribute(ctrl_target, 0,
NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU,
(unsigned char **)(&pDataCooler), &len);
if ( ret == NvCtrlSuccess ) {
@@ -1137,24 +1144,24 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
/* return if sensor and Fan information not available */
if ((thermal_sensor_target_type_supported && !sensor_count) &&
!cooler_count) {
- XFree(pDataSensor);
- XFree(pDataCooler);
+ free(pDataSensor);
+ free(pDataCooler);
return NULL;
}
/* create the CtkThermal object */
object = g_object_new(CTK_TYPE_THERMAL, NULL);
-
+
ctk_thermal = CTK_THERMAL(object);
- ctk_thermal->attribute_handle = handle;
+ ctk_thermal->ctrl_target = ctrl_target;
ctk_thermal->ctk_config = ctk_config;
ctk_thermal->settings_changed = FALSE;
ctk_thermal->show_fan_control_frame = TRUE;
ctk_thermal->cooler_count = cooler_count;
ctk_thermal->sensor_count = sensor_count;
ctk_thermal->thermal_sensor_target_type_supported = thermal_sensor_target_type_supported;
-
+
/* set container properties for the CtkThermal widget */
gtk_box_set_spacing(GTK_BOX(ctk_thermal), 10);
@@ -1166,7 +1173,7 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
/* Check if we can control cooler state */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_COOLER_MANUAL_CONTROL,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_COOLER_MANUAL_CONTROL,
&value);
if ( ret != NvCtrlSuccess ) {
ctk_thermal->show_fan_control_frame = FALSE;
@@ -1178,10 +1185,10 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
can_access_cooler_level = TRUE;
ctk_thermal->cooler_control_enabled = cooler_control_enabled;
ctk_thermal->enable_reset_button = FALSE;
-
- /* Retrieve CtrlHandles from ctk_config */
- h = ctk_config->pCtrlHandles;
+ /* Retrieve CtrlSystem from ctk_config */
+
+ system = ctk_config->pCtrlSystem;
/* Thermal Information */
@@ -1208,40 +1215,42 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
for (j = 1; j <= ctk_thermal->sensor_count; j++) {
gint reading, target, provider;
- sensor_handle =
- h->targets[THERMAL_SENSOR_TARGET].t[pDataSensor[j]].h;
- if ( !sensor_handle ) {
+ sensor_target = NvCtrlGetTarget(system, THERMAL_SENSOR_TARGET,
+ pDataSensor[j]);
+ if (sensor_target == NULL) {
continue;
}
- ctk_thermal->sensor_info[cur_sensor_idx].handle = sensor_handle;
+ ctk_thermal->sensor_info[cur_sensor_idx].ctrl_target =
+ sensor_target;
/* check if this screen supports thermal querying */
- ret = NvCtrlGetAttribute(sensor_handle, NV_CTRL_THERMAL_SENSOR_READING,
+ ret = NvCtrlGetAttribute(sensor_target, NV_CTRL_THERMAL_SENSOR_READING,
&reading);
if (ret != NvCtrlSuccess) {
/* sensor information unavailable */
reading = 0;
}
- ret = NvCtrlGetValidAttributeValues(sensor_handle,
- NV_CTRL_THERMAL_SENSOR_READING,
+ ret = NvCtrlGetValidAttributeValues(sensor_target,
+ NV_CTRL_THERMAL_SENSOR_READING,
&sensor_range);
if (ret != NvCtrlSuccess) {
/* sensor information unavailable */
sensor_range.u.range.min = sensor_range.u.range.max = 0;
}
- ret = NvCtrlGetAttribute(sensor_handle, NV_CTRL_THERMAL_SENSOR_TARGET,
+ ret = NvCtrlGetAttribute(sensor_target,
+ NV_CTRL_THERMAL_SENSOR_TARGET,
&target);
if (ret != NvCtrlSuccess) {
/* sensor information unavailable */
target = 0;
}
- ret = NvCtrlGetAttribute(sensor_handle, NV_CTRL_THERMAL_SENSOR_PROVIDER,
+ ret = NvCtrlGetAttribute(sensor_target, NV_CTRL_THERMAL_SENSOR_PROVIDER,
&provider);
if (ret != NvCtrlSuccess) {
/* sensor information unavailable */
@@ -1249,7 +1258,7 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
}
/* print sensor related information */
draw_sensor_gui(vbox, ctk_thermal, thermal_sensor_target_type_supported,
- cur_sensor_idx, sensor_handle,
+ cur_sensor_idx,
reading, sensor_range.u.range.min,
sensor_range.u.range.max, target, provider);
cur_sensor_idx++;
@@ -1314,7 +1323,8 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle,
/* Ambient Temperature */
- ret = NvCtrlGetAttribute(handle, NV_CTRL_AMBIENT_TEMPERATURE, &ambient);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_AMBIENT_TEMPERATURE,
+ &ambient);
if (ret == NvCtrlSuccess) {
hbox2 = gtk_hbox_new(FALSE, 0);
@@ -1379,47 +1389,47 @@ sensor_end:
calloc(ctk_thermal->cooler_count, sizeof(CoolerControlRec));
for (j = 1; j <= ctk_thermal->cooler_count; j++) {
- cooler_handle = h->targets[COOLER_TARGET].t[pDataCooler[j]].h;
-
- if ( !cooler_handle ) {
+
+ cooler_target = NvCtrlGetTarget(system, COOLER_TARGET, pDataCooler[j]);
+ if (cooler_target == NULL) {
continue;
}
/* Get current cooler level and range */
-
- ret = NvCtrlGetAttribute(cooler_handle,
+
+ ret = NvCtrlGetAttribute(cooler_target,
NV_CTRL_THERMAL_COOLER_LEVEL,
&cooler_level);
if ( ret != NvCtrlSuccess ) {
can_access_cooler_level = FALSE;
}
- ret = NvCtrlGetValidAttributeValues(cooler_handle,
+ ret = NvCtrlGetValidAttributeValues(cooler_target,
NV_CTRL_THERMAL_COOLER_LEVEL,
&cooler_range);
if ( ret != NvCtrlSuccess ) {
can_access_cooler_level = FALSE;
}
-
+
ctk_thermal->cooler_control[cur_cooler_idx].level = cooler_level;
ctk_thermal->cooler_control[cur_cooler_idx].range = cooler_range;
- ctk_thermal->cooler_control[cur_cooler_idx].handle = cooler_handle;
-
+ ctk_thermal->cooler_control[cur_cooler_idx].ctrl_target = cooler_target;
+
/* Create the object for receiving NV-CONTROL events */
-
+
ctk_thermal->cooler_control[cur_cooler_idx].event =
- CTK_EVENT(ctk_event_new(cooler_handle));
-
+ CTK_EVENT(ctk_event_new(cooler_target));
+
if ( can_access_cooler_level && ctk_thermal->show_fan_control_frame ) {
/*
* Get NV_CTRL_THERMAL_COOLER_CONTROL_TYPE to decide cooler
* control widget should be slider or checkbox.
*/
-
- ret = NvCtrlGetAttribute(cooler_handle,
+
+ ret = NvCtrlGetAttribute(cooler_target,
NV_CTRL_THERMAL_COOLER_CONTROL_TYPE,
&cooler_control_type);
- if ((ret == NvCtrlSuccess) &&
+ if ((ret == NvCtrlSuccess) &&
(cooler_control_type ==
NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_VARIABLE)) {
@@ -1558,12 +1568,12 @@ sensor_end:
}
end:
- XFree(pDataSensor);
+ free(pDataSensor);
pDataSensor = NULL;
-
- XFree(pDataCooler);
+
+ free(pDataCooler);
pDataCooler = NULL;
-
+
/* sync GUI to current server settings */
sync_gui_to_modify_cooler_level(ctk_thermal);
@@ -1572,8 +1582,8 @@ end:
/* Register a timer callback to update the temperatures */
s = g_strdup_printf("Thermal Monitor (GPU %d)",
- NvCtrlGetTargetId(handle));
-
+ NvCtrlGetTargetId(ctrl_target));
+
ctk_config_add_timer(ctk_thermal->ctk_config,
DEFAULT_UPDATE_THERMAL_INFO_TIME_INTERVAL,
s,
diff --git a/src/gtk+-2.x/ctkthermal.h b/src/gtk+-2.x/ctkthermal.h
index 920677c..edb9bba 100644
--- a/src/gtk+-2.x/ctkthermal.h
+++ b/src/gtk+-2.x/ctkthermal.h
@@ -20,7 +20,6 @@
#ifndef __CTK_THERMAL_H__
#define __CTK_THERMAL_H__
-#include "NvCtrlAttributes.h"
#include "ctkconfig.h"
#include "ctkevent.h"
@@ -49,7 +48,7 @@ typedef struct _CtkThermalClass CtkThermalClass;
typedef struct _CoolerControl {
NVCTRLAttributeValidValuesRec range;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
int level;
Bool changed; /* Cooler level moved by user */
@@ -64,11 +63,11 @@ typedef struct {
} nvctrlFormatName;
typedef struct _SensorInfo {
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
int currentTemp;
int minTemp;
int maxTemp;
-
+
GtkWidget *target_type;
GtkWidget *provider_type;
GtkWidget *temp_label;
@@ -79,7 +78,7 @@ struct _CtkThermal
{
GtkVBox parent;
- NvCtrlAttributeHandle *attribute_handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
GtkWidget *core_label;
@@ -113,9 +112,7 @@ struct _CtkThermalClass
};
GType ctk_thermal_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_thermal_new (NvCtrlAttributeHandle *,
- CtkConfig *,
- CtkEvent *);
+GtkWidget* ctk_thermal_new (CtrlTarget *, CtkConfig *, CtkEvent *);
GtkTextBuffer* ctk_thermal_create_help (GtkTextTagTable *, CtkThermal *);
void ctk_thermal_start_timer (GtkWidget *);
diff --git a/src/gtk+-2.x/ctkui.c b/src/gtk+-2.x/ctkui.c
index 3ee395f..9ee0a1c 100644
--- a/src/gtk+-2.x/ctkui.c
+++ b/src/gtk+-2.x/ctkui.c
@@ -39,24 +39,25 @@ char *ctk_get_display(void)
void ctk_main(ParsedAttribute *p,
ConfigProperties *conf,
- CtrlHandles *h,
+ CtrlSystem *system,
const char *page)
{
- int i, has_nv_control = FALSE;
+ CtrlTargetNode *node;
+ int has_nv_control = FALSE;
GList *list = NULL;
GtkWidget *window;
list = g_list_append (list, gdk_pixbuf_from_pixdata(&nvidia_icon_pixdata, TRUE, NULL));
gtk_window_set_default_icon_list(list);
- window = ctk_window_new(p, conf, h);
+ window = ctk_window_new(p, conf, system);
- for (i = 0; i < h->targets[X_SCREEN_TARGET].n; i++) {
- if (h->targets[X_SCREEN_TARGET].t[i].h) {
+ for (node = system->targets[X_SCREEN_TARGET]; node; node = node->next) {
+ if (node->t->h) {
has_nv_control = TRUE;
break;
}
}
-
+
if (!has_nv_control) {
GtkWidget *dlg;
dlg = gtk_message_dialog_new (NULL,
diff --git a/src/gtk+-2.x/ctkui.h b/src/gtk+-2.x/ctkui.h
index 1b5bb3c..872c48c 100644
--- a/src/gtk+-2.x/ctkui.h
+++ b/src/gtk+-2.x/ctkui.h
@@ -30,7 +30,7 @@ char *ctk_get_display(void);
void ctk_main(ParsedAttribute*,
ConfigProperties*,
- CtrlHandles*,
+ CtrlSystem*,
const char *page);
diff --git a/src/gtk+-2.x/ctkutils.c b/src/gtk+-2.x/ctkutils.c
index db88640..5a819e5 100644
--- a/src/gtk+-2.x/ctkutils.c
+++ b/src/gtk+-2.x/ctkutils.c
@@ -16,7 +16,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses>.
*/
-
+
+#include <stdlib.h>
#include <gtk/gtk.h>
#include <NvCtrlAttributes.h>
#include "NVCtrlLib.h"
@@ -266,6 +267,96 @@ void ctk_combo_box_text_append_text(GtkWidget *widget, const gchar *text)
#endif
}
+void ctk_cell_renderer_set_alignment(GtkCellRenderer *renderer,
+ gfloat x, gfloat y)
+{
+#ifdef CTK_GTK3
+ /* added in 2.18 */
+ gtk_cell_renderer_set_alignment(renderer, x, y);
+#else
+ /* direct access removed in 3.0 */
+ renderer->xalign = x;
+ renderer->yalign = y;
+#endif
+}
+
+GtkWidget *ctk_file_chooser_dialog_new(const gchar *title,
+ GtkWindow *parent,
+ GtkFileChooserAction action)
+{
+#ifdef CTK_GTK3
+ /* Added in 2.4 */
+ gboolean open = (action == GTK_FILE_CHOOSER_ACTION_OPEN);
+
+ return gtk_file_chooser_dialog_new(title, parent, action,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ open ? GTK_STOCK_OPEN : GTK_STOCK_SAVE,
+ GTK_RESPONSE_ACCEPT,
+ NULL);
+#else
+ /*
+ * There is an issue on some platforms that causes the UI to hang when
+ * creating a GtkFileChooserDialog from a shared library. For now, we will
+ * continue to use the GtkFileSelection.
+ *
+ * Will return GTK_RESPONSE_OK if not cancelled
+ *
+ * Deprecated in 2.4 and removed in 3.0
+ */
+ return gtk_file_selection_new(title);
+#endif
+}
+
+void ctk_file_chooser_set_filename(GtkWidget *widget, const gchar *filename)
+{
+#ifdef CTK_GTK3
+ GtkFileChooserAction action =
+ gtk_file_chooser_get_action(GTK_FILE_CHOOSER(widget));
+ char *full_filename = tilde_expansion(filename);
+ char *basename = g_path_get_basename(full_filename);
+ char *dirname = NULL;
+
+ if (action == GTK_FILE_CHOOSER_ACTION_SAVE &&
+ (!g_file_test(full_filename, G_FILE_TEST_EXISTS) ||
+ basename[0] == '.')) {
+
+ char *dirname = g_path_get_dirname(full_filename);
+
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(widget), dirname);
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(widget), basename);
+
+ } else {
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(widget), full_filename);
+ }
+
+ free(dirname);
+ free(basename);
+ free(full_filename);
+#else
+ gtk_file_selection_set_filename(GTK_FILE_SELECTION(widget), filename);
+#endif
+}
+
+gchar *ctk_file_chooser_get_filename(GtkWidget *widget)
+{
+#ifdef CTK_GTK3
+ return gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
+#else
+ return g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(widget)));
+#endif
+}
+
+void ctk_file_chooser_set_extra_widget(GtkWidget *widget, GtkWidget *extra)
+{
+#ifdef CTK_GTK3
+ gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(widget), extra);
+#else
+ gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(widget)->main_vbox),
+ extra, FALSE, FALSE, 15);
+#endif
+}
+
/* end of GTK2/3 util functions */
@@ -287,27 +378,26 @@ gboolean ctk_check_min_gtk_version(guint required_major,
}
-gchar *get_pcie_generation_string(NvCtrlAttributeHandle *handle)
+gchar *get_pcie_generation_string(CtrlTarget *ctrl_target)
{
ReturnStatus ret;
gchar *s = NULL;
int tmp;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_PCIE_GENERATION, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_PCIE_GENERATION, &tmp);
if (ret == NvCtrlSuccess) {
s = g_strdup_printf("Gen%u", tmp);
}
return s;
}
-gchar *get_pcie_link_width_string(NvCtrlAttributeHandle *handle,
- int attribute)
+gchar *get_pcie_link_width_string(CtrlTarget *ctrl_target, int attribute)
{
ReturnStatus ret;
gint tmp;
gchar *s = NULL;
- ret = NvCtrlGetAttribute(handle, attribute, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, attribute, &tmp);
if (ret != NvCtrlSuccess) {
s = g_strdup_printf("Unknown");
} else {
@@ -317,14 +407,13 @@ gchar *get_pcie_link_width_string(NvCtrlAttributeHandle *handle,
return s;
}
-gchar *get_pcie_link_speed_string(NvCtrlAttributeHandle *handle,
- int attribute)
+gchar *get_pcie_link_speed_string(CtrlTarget *ctrl_target, int attribute)
{
ReturnStatus ret;
gint tmp;
gchar *s = NULL;
- ret = NvCtrlGetAttribute(handle, attribute, &tmp);
+ ret = NvCtrlGetAttribute(ctrl_target, attribute, &tmp);
if (ret != NvCtrlSuccess) {
s = g_strdup_printf("Unknown");
} else {
@@ -336,10 +425,31 @@ gchar *get_pcie_link_speed_string(NvCtrlAttributeHandle *handle,
+gchar *get_nvidia_driver_version(CtrlTarget *ctrl_target)
+{
+ ReturnStatus ret;
+ gchar *driver_version;
+
+ if (ctrl_target == NULL || ctrl_target->h == NULL) {
+ return NULL;
+ }
+
+ ret = NvCtrlGetStringAttribute(ctrl_target,
+ NV_CTRL_STRING_NVIDIA_DRIVER_VERSION,
+ &driver_version);
+ if (ret != NvCtrlSuccess) {
+ return NULL;
+ }
+
+ return driver_version;
+}
+
+
+
/*
* Used to check if current display enabled or disabled.
*/
-void update_display_enabled_flag(NvCtrlAttributeHandle *handle,
+void update_display_enabled_flag(CtrlTarget *ctrl_target,
gboolean *display_enabled)
{
ReturnStatus ret;
@@ -347,7 +457,7 @@ void update_display_enabled_flag(NvCtrlAttributeHandle *handle,
/* Is display enabled? */
- ret = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_DISPLAY_ENABLED,
&val);
@@ -359,22 +469,22 @@ void update_display_enabled_flag(NvCtrlAttributeHandle *handle,
-gchar* create_gpu_name_string(NvCtrlAttributeHandle *gpu_handle)
+gchar* create_gpu_name_string(CtrlTarget *ctrl_target)
{
gchar *gpu_name;
gchar *gpu_product_name;
ReturnStatus ret;
- ret = NvCtrlGetStringAttribute(gpu_handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_PRODUCT_NAME,
&gpu_product_name);
if (ret == NvCtrlSuccess && gpu_product_name) {
gpu_name = g_strdup_printf("GPU %d - (%s)",
- NvCtrlGetTargetId(gpu_handle),
+ NvCtrlGetTargetId(ctrl_target),
gpu_product_name);
} else {
gpu_name = g_strdup_printf("GPU %d - (Unknown)",
- NvCtrlGetTargetId(gpu_handle));
+ NvCtrlGetTargetId(ctrl_target));
}
g_free(gpu_product_name);
@@ -382,23 +492,20 @@ gchar* create_gpu_name_string(NvCtrlAttributeHandle *gpu_handle)
}
-gchar* create_display_name_list_string(NvCtrlAttributeHandle *handle,
+
+gchar* create_display_name_list_string(CtrlTarget *ctrl_target,
unsigned int attr)
{
gchar *displays = NULL;
- gchar *typeIdName;
- gchar *logName;
- gchar *tmp_str;
ReturnStatus ret;
int *pData;
int len;
int i;
- Bool valid;
/* List of Display Device connected on GPU */
- ret = NvCtrlGetBinaryAttribute(handle, 0,
+ ret = NvCtrlGetBinaryAttribute(ctrl_target, 0,
attr,
(unsigned char **)(&pData), &len);
if (ret != NvCtrlSuccess) {
@@ -406,34 +513,35 @@ gchar* create_display_name_list_string(NvCtrlAttributeHandle *handle,
}
for (i = 0; i < pData[0]; i++) {
+ CtrlTarget *ctrl_other;
int display_id = pData[i+1];
-
- valid =
- XNVCTRLQueryTargetStringAttribute(NvCtrlGetDisplayPtr(handle),
- NV_CTRL_TARGET_TYPE_DISPLAY,
- display_id,
- 0,
- NV_CTRL_STRING_DISPLAY_DEVICE_NAME,
- &tmp_str);
- if (!valid) {
+ gchar *logName = NULL;
+ gchar *typeIdName = NULL;
+ gchar *tmp_str;
+
+ ctrl_other = NvCtrlGetTarget(ctrl_target->system, DISPLAY_TARGET,
+ display_id);
+ if (ctrl_other) {
+ ret = NvCtrlGetStringAttribute(ctrl_other,
+ NV_CTRL_STRING_DISPLAY_DEVICE_NAME,
+ &tmp_str);
+ if (ret == NvCtrlSuccess) {
+ logName = g_strdup(tmp_str);
+ free(tmp_str);
+ }
+ ret = NvCtrlGetStringAttribute(ctrl_other,
+ NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID,
+ &tmp_str);
+ if (ret == NvCtrlSuccess) {
+ typeIdName = g_strdup(tmp_str);
+ free(tmp_str);
+ }
+ }
+ if (!logName) {
logName = g_strdup("Unknown");
- } else {
- logName = g_strdup(tmp_str);
- XFree(tmp_str);
}
-
- valid =
- XNVCTRLQueryTargetStringAttribute(NvCtrlGetDisplayPtr(handle),
- NV_CTRL_TARGET_TYPE_DISPLAY,
- display_id,
- 0,
- NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID,
- &tmp_str);
- if (!valid) {
+ if (!typeIdName) {
typeIdName = g_strdup_printf("DPY-%d", display_id);
- } else {
- typeIdName = g_strdup(tmp_str);
- XFree(tmp_str);
}
tmp_str = g_strdup_printf("%s (%s)", logName, typeIdName);
@@ -461,7 +569,6 @@ gchar* create_display_name_list_string(NvCtrlAttributeHandle *handle,
-
GtkWidget *add_table_row_with_help_text(GtkWidget *table,
CtkConfig *ctk_config,
const char *help,
@@ -634,6 +741,7 @@ void ctk_empty_container(GtkWidget *container)
} /* ctk_empty_container() */
+#ifndef CTK_GTK3
/* Updates the widget to use the text colors ('text' and 'base') for the
* foreground and background colors.
*/
@@ -670,15 +778,18 @@ static void force_text_colors_handler(GtkWidget *widget,
(G_OBJECT(widget),
G_CALLBACK(force_text_colors_handler), user_data);
}
+#endif
void ctk_force_text_colors_on_widget(GtkWidget *widget)
{
+#ifdef CTK_GTK3
+ /* The GTK CSS theme engine will handle updates */
+ GtkStyleContext *context = gtk_widget_get_style_context(widget);
+ gtk_style_context_add_class(context, "entry");
+#else
/* Set the intial state */
force_text_colors_handler(widget, NULL, NULL);
-#ifndef CTK_GTK3
- /* This behavior is not properly supported in GTK 3 */
-
/* Ensure state is updated when style changes */
g_signal_connect(G_OBJECT(widget),
"style-set", G_CALLBACK(force_text_colors_handler),
@@ -686,3 +797,34 @@ void ctk_force_text_colors_on_widget(GtkWidget *widget)
#endif
}
+
+/*
+ * Create a dialog to allow the user to specify the name of the file to load
+ * or save.
+ */
+char *ctk_get_filename_from_dialog(const gchar* title,
+ GtkWindow *parent,
+ const gchar* initial_filename)
+{
+ GtkWidget *dialog;
+ gchar *filename = NULL;
+ gint result;
+
+ dialog =
+ ctk_file_chooser_dialog_new(title, parent,
+ GTK_FILE_CHOOSER_ACTION_SAVE);
+
+ ctk_file_chooser_set_filename(dialog, initial_filename);
+
+ result = gtk_dialog_run(GTK_DIALOG(dialog));
+
+ if (result == GTK_RESPONSE_ACCEPT || result == GTK_RESPONSE_OK) {
+ filename = ctk_file_chooser_get_filename(dialog);
+ }
+
+ gtk_widget_destroy(dialog);
+
+ return filename;
+}
+
+
diff --git a/src/gtk+-2.x/ctkutils.h b/src/gtk+-2.x/ctkutils.h
index d5ae1a9..bf3949d 100644
--- a/src/gtk+-2.x/ctkutils.h
+++ b/src/gtk+-2.x/ctkutils.h
@@ -57,6 +57,14 @@ void ctk_adjustment_set_lower(GtkAdjustment *a, gdouble x);
GtkWidget *ctk_scrolled_window_get_vscrollbar(GtkScrolledWindow *sw);
GtkWidget *ctk_statusbar_get_message_area(GtkStatusbar *statusbar);
+void ctk_cell_renderer_set_alignment(GtkCellRenderer *widget,
+ gfloat x, gfloat y);
+
+GtkWidget *ctk_file_chooser_dialog_new(const gchar *title, GtkWindow *parent,
+ GtkFileChooserAction action);
+void ctk_file_chooser_set_filename(GtkWidget *widget, const gchar *filename);
+gchar *ctk_file_chooser_get_filename(GtkWidget *widget);
+void ctk_file_chooser_set_extra_widget(GtkWidget *widget, GtkWidget *extra);
GtkWidget *ctk_combo_box_text_new(void);
GtkWidget *ctk_combo_box_text_new_with_entry(void);
@@ -66,17 +74,17 @@ void ctk_g_object_ref_sink(gpointer obj);
/* end of GTK 2/3 util functions */
-gchar *get_pcie_generation_string(NvCtrlAttributeHandle *handle);
+gchar *get_pcie_generation_string(CtrlTarget *ctrl_target);
+
+gchar *get_pcie_link_width_string(CtrlTarget *ctrl_target, gint attribute);
-gchar *get_pcie_link_width_string(NvCtrlAttributeHandle *handle,
- gint attribute);
+gchar *get_pcie_link_speed_string(CtrlTarget *ctrl_target, gint attribute);
-gchar *get_pcie_link_speed_string(NvCtrlAttributeHandle *handle,
- gint attribute);
+gchar *get_nvidia_driver_version(CtrlTarget *ctrl_target);
-gchar* create_gpu_name_string(NvCtrlAttributeHandle *gpu_handle);
+gchar* create_gpu_name_string(CtrlTarget *ctrl_target);
-gchar* create_display_name_list_string(NvCtrlAttributeHandle *handle,
+gchar* create_display_name_list_string(CtrlTarget *ctrl_target,
unsigned int attr);
GtkWidget *add_table_row_with_help_text(GtkWidget *table,
@@ -105,7 +113,7 @@ void ctk_display_warning_msg(GtkWidget *parent, gchar *msg);
void ctk_empty_container(GtkWidget *);
-void update_display_enabled_flag(NvCtrlAttributeHandle *handle,
+void update_display_enabled_flag(CtrlTarget *ctrl_target,
gboolean *display_enabled);
gboolean ctk_check_min_gtk_version(guint required_major,
@@ -114,6 +122,10 @@ gboolean ctk_check_min_gtk_version(guint required_major,
void ctk_force_text_colors_on_widget(GtkWidget *widget);
+gchar *ctk_get_filename_from_dialog(const gchar* title,
+ GtkWindow *parent,
+ const gchar* initial_filename);
+
G_END_DECLS
#endif /* __CTK_UTILS_H__ */
diff --git a/src/gtk+-2.x/ctkvcs.c b/src/gtk+-2.x/ctkvcs.c
index a663887..c929675 100644
--- a/src/gtk+-2.x/ctkvcs.c
+++ b/src/gtk+-2.x/ctkvcs.c
@@ -125,17 +125,18 @@ static gboolean update_vcs_info(gpointer user_data)
char *temp_str = NULL;
char *psu_str = NULL;
CtkVcs *ctk_object = CTK_VCS(user_data);
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
ThermalEntry thermEntry;
- PSUEntry psuEntry;
+ PSUEntry psuEntry;
gboolean high_perf_mode;
/* These queries should always succeed for Canoas 2.0 and above */
- if ((NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_VCSC_HIGH_PERF_MODE,
+ if ((NvCtrlGetAttribute(ctrl_target, NV_CTRL_VCSC_HIGH_PERF_MODE,
&high_perf_mode) != NvCtrlSuccess) ||
- (NvCtrlGetStringAttribute(ctk_object->handle,
+ (NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_VCSC_TEMPERATURES,
&temp_str) != NvCtrlSuccess) ||
- (NvCtrlGetStringAttribute(ctk_object->handle,
+ (NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_VCSC_PSU_INFO,
&psu_str) != NvCtrlSuccess)) {
return FALSE;
@@ -274,12 +275,13 @@ static GtkWidget * create_error_dialog(CtkVcs *ctk_object)
static void vcs_perf_checkbox_toggled(GtkWidget *widget, gpointer user_data)
{
CtkVcs *ctk_object = CTK_VCS(user_data);
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
gint enabled;
gint ret;
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- ret = NvCtrlSetAttribute(ctk_object->handle, NV_CTRL_VCSC_HIGH_PERF_MODE, enabled);
+ ret = NvCtrlSetAttribute(ctrl_target, NV_CTRL_VCSC_HIGH_PERF_MODE, enabled);
if (ret != NvCtrlSuccess) {
if (ctk_object->error_dialog_label) {
@@ -313,6 +315,7 @@ static void vcs_perf_checkbox_toggled(GtkWidget *widget, gpointer user_data)
static gboolean update_fan_status(CtkVcs *ctk_object)
{
+ CtrlTarget *ctrl_target = ctk_object->ctrl_target;
gint ret;
char *fan_entry_str = NULL;
char *tokens;
@@ -325,7 +328,7 @@ static gboolean update_fan_status(CtkVcs *ctk_object)
if (!ctk_object->fan_status_container) {
return FALSE;
}
- ret = NvCtrlGetStringAttribute(ctk_object->handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_VCSC_FAN_STATUS,
&fan_entry_str);
if (ret != NvCtrlSuccess) {
@@ -416,7 +419,7 @@ static gboolean update_fan_status(CtkVcs *ctk_object)
}
}
gtk_widget_show_all(table);
- XFree(fan_entry_str);
+ free(fan_entry_str);
return TRUE;
}
@@ -425,8 +428,8 @@ static gboolean update_fan_status(CtkVcs *ctk_object)
* CTK VCS (Visual Computing System) widget creation
*
*/
-GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
- CtkConfig *ctk_config)
+GtkWidget* ctk_vcs_new(CtrlTarget *ctrl_target,
+ CtkConfig *ctk_config)
{
GObject *object;
CtkVcs *ctk_object;
@@ -462,7 +465,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
*/
/* Product Name */
- ret = NvCtrlGetStringAttribute(handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_VCSC_PRODUCT_NAME,
&product_name);
if (ret != NvCtrlSuccess) {
@@ -470,7 +473,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
}
/* Serial Number */
- ret = NvCtrlGetStringAttribute(handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_VCSC_SERIAL_NUMBER,
&serial_number);
if (ret != NvCtrlSuccess) {
@@ -478,7 +481,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
}
/* Build Date */
- ret = NvCtrlGetStringAttribute(handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_VCSC_BUILD_DATE,
&build_date);
if (ret != NvCtrlSuccess) {
@@ -486,7 +489,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
}
/* Product ID */
- ret = NvCtrlGetStringAttribute(handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_VCSC_PRODUCT_ID,
&product_id);
if (ret != NvCtrlSuccess) {
@@ -494,7 +497,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
}
/* Firmware Version */
- ret = NvCtrlGetStringAttribute(handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_VCSC_FIRMWARE_VERSION,
&firmware_version);
if (ret != NvCtrlSuccess) {
@@ -502,7 +505,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
}
/* Hardware Version */
- ret = NvCtrlGetStringAttribute(handle,
+ ret = NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_VCSC_HARDWARE_VERSION,
&hardware_version);
if (ret != NvCtrlSuccess) {
@@ -511,13 +514,13 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
/* now, create the object */
-
+
object = g_object_new(CTK_TYPE_VCS, NULL);
ctk_object = CTK_VCS(object);
- /* cache the attribute handle */
+ /* cache the target */
- ctk_object->handle = handle;
+ ctk_object->ctrl_target = ctrl_target;
ctk_object->ctk_config = ctk_config;
/* set container properties of the object */
@@ -540,7 +543,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
/* General purpose error dialog */
ctk_object->error_dialog = create_error_dialog(ctk_object);
- if (NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_VCSC_HIGH_PERF_MODE,
+ if (NvCtrlGetAttribute(ctrl_target, NV_CTRL_VCSC_HIGH_PERF_MODE,
&high_perf_mode) == NvCtrlSuccess) {
hbox = gtk_hbox_new(FALSE, 0);
@@ -607,9 +610,9 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
/* Query Canoas 2.0 specific details */
- if ((NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_VCSC_HIGH_PERF_MODE,
- &high_perf_mode) == NvCtrlSuccess) &&
- (NvCtrlGetStringAttribute(ctk_object->handle,
+ if ((NvCtrlGetAttribute(ctrl_target, NV_CTRL_VCSC_HIGH_PERF_MODE,
+ &high_perf_mode) == NvCtrlSuccess) &&
+ (NvCtrlGetStringAttribute(ctrl_target,
NV_CTRL_STRING_VCSC_PSU_INFO,
&psu_str) == NvCtrlSuccess)) {
GtkWidget *vbox_padding;
@@ -775,7 +778,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
/* Register a timer callback to update the dynamic information */
s = g_strdup_printf("VCS Monitor (VCS %d)",
- NvCtrlGetTargetId(ctk_object->handle));
+ NvCtrlGetTargetId(ctrl_target));
ctk_config_add_timer(ctk_object->ctk_config,
DEFAULT_UPDATE_VCS_INFO_TIME_INTERVAL,
@@ -788,7 +791,7 @@ GtkWidget* ctk_vcs_new(NvCtrlAttributeHandle *handle,
}
gtk_widget_show_all(GTK_WIDGET(object));
-
+
return GTK_WIDGET(object);
}
diff --git a/src/gtk+-2.x/ctkvcs.h b/src/gtk+-2.x/ctkvcs.h
index 9766ab9..8ffcead 100644
--- a/src/gtk+-2.x/ctkvcs.h
+++ b/src/gtk+-2.x/ctkvcs.h
@@ -73,7 +73,7 @@ typedef struct _CtkVcs
GtkVBox parent;
CtkConfig *ctk_config;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
GtkWidget *intake_temp;
GtkWidget *exhaust_temp;
@@ -96,7 +96,7 @@ typedef struct _CtkVcsClass
GType ctk_vcs_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_vcs_new (NvCtrlAttributeHandle *, CtkConfig *);
+GtkWidget* ctk_vcs_new (CtrlTarget *, CtkConfig *);
GtkTextBuffer *ctk_vcs_create_help(GtkTextTagTable *,
CtkVcs *);
diff --git a/src/gtk+-2.x/ctkvdpau.c b/src/gtk+-2.x/ctkvdpau.c
index c7f9210..a8b074c 100644
--- a/src/gtk+-2.x/ctkvdpau.c
+++ b/src/gtk+-2.x/ctkvdpau.c
@@ -1344,8 +1344,7 @@ GType ctk_vdpau_get_type(void)
-GtkWidget* ctk_vdpau_new(NvCtrlAttributeHandle *handle,
- CtkConfig *ctk_config,
+GtkWidget* ctk_vdpau_new(CtrlTarget *ctrl_target, CtkConfig *ctk_config,
CtkEvent *ctk_event)
{
GObject *object;
@@ -1366,16 +1365,13 @@ GtkWidget* ctk_vdpau_new(NvCtrlAttributeHandle *handle,
/* make sure we have a handle */
- g_return_val_if_fail(handle != NULL, NULL);
+ g_return_val_if_fail((ctrl_target != NULL) &&
+ (ctrl_target->h != NULL), NULL);
/* Create the ctk vdpau object */
object = g_object_new(CTK_TYPE_VDPAU, NULL);
ctk_vdpau = CTK_VDPAU(object);
-
- /* Cache the attribute handle */
- ctk_vdpau->handle = handle;
-
/* Set container properties of the object */
ctk_vdpau->ctk_config = ctk_config;
gtk_box_set_spacing(GTK_BOX(ctk_vdpau), 10);
@@ -1397,8 +1393,8 @@ GtkWidget* ctk_vdpau_new(NvCtrlAttributeHandle *handle,
/* get device and ProcAddress */
- ret = VDPAUDeviceCreateX11(NvCtrlGetDisplayPtr(handle),
- NvCtrlGetScreen(handle),
+ ret = VDPAUDeviceCreateX11(NvCtrlGetDisplayPtr(ctrl_target),
+ NvCtrlGetScreen(ctrl_target),
&device, &getProcAddress);
if ((ret != VDP_STATUS_OK) || !device || !getProcAddress) {
diff --git a/src/gtk+-2.x/ctkvdpau.h b/src/gtk+-2.x/ctkvdpau.h
index 38d521b..ec58d36 100644
--- a/src/gtk+-2.x/ctkvdpau.h
+++ b/src/gtk+-2.x/ctkvdpau.h
@@ -84,7 +84,6 @@ struct _CtkVDPAU
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
CtkConfig *ctk_config;
GtkWidget* notebook;
@@ -98,8 +97,7 @@ struct _CtkVDPAUClass
};
GType ctk_vdpau_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_vdpau_new (NvCtrlAttributeHandle *,
- CtkConfig *, CtkEvent *);
+GtkWidget* ctk_vdpau_new (CtrlTarget *, CtkConfig *, CtkEvent *);
GtkTextBuffer* ctk_vdpau_create_help (GtkTextTagTable *, CtkVDPAU *);
G_END_DECLS
diff --git a/src/gtk+-2.x/ctkwindow.c b/src/gtk+-2.x/ctkwindow.c
index 61e7959..8d78e68 100644
--- a/src/gtk+-2.x/ctkwindow.c
+++ b/src/gtk+-2.x/ctkwindow.c
@@ -51,7 +51,6 @@
#include "ctkmultisample.h"
#include "ctkthermal.h"
#include "ctkpowermizer.h"
-#include "ctkclocks.h"
#include "ctkvcs.h"
#include "ctk3dvisionpro.h"
@@ -88,13 +87,13 @@ enum {
typedef struct {
CtkWindow *window;
- CtkEvent *event;
- NvCtrlAttributeHandle *gpu_handle;
+ CtrlTarget *gpu_target;
GtkTextTagTable *tag_table;
GtkTreeIter parent_iter;
GtkTreeIter *display_iters;
+ CtkEvent **display_events;
int num_displays;
} UpdateDisplaysData;
@@ -124,13 +123,13 @@ static void quit_response(GtkWidget *, gint, gpointer);
static void save_settings_and_exit(CtkWindow *);
static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter,
- NvCtrlAttributeHandle *handle,
+ CtrlTarget *gpu_target,
CtkEvent *ctk_event,
GtkTextTagTable *tag_table,
UpdateDisplaysData *data,
ParsedAttribute *p);
-static void update_display_devices(GtkWidget *object, gpointer arg1,
+static void update_display_devices(GtkWidget *object, CtrlEvent *event,
gpointer user_data);
@@ -397,12 +396,13 @@ static void row_activated_event(GtkTreeView *view,
-static gboolean has_randr_gamma(NvCtrlAttributeHandle *handle)
+static gboolean has_randr_gamma(CtrlTarget *target)
{
ReturnStatus ret;
int val;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE, &val);
+ ret = NvCtrlGetAttribute(target, NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE,
+ &val);
return ((ret == NvCtrlSuccess) && (val == 1));
}
@@ -412,7 +412,7 @@ static gboolean has_randr_gamma(NvCtrlAttributeHandle *handle)
*/
GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
- CtrlHandles *h)
+ CtrlSystem *system)
{
GObject *object;
CtkWindow *ctk_window;
@@ -437,16 +437,16 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
GtkTextTagTable *tag_table;
GtkTextBuffer *help;
-
- NvCtrlAttributeHandle *server_handle = NULL;
+
+ CtrlTargetNode *node;
+ CtrlTarget *server_target = NULL;
CtkEvent *ctk_event;
CtkConfig *ctk_config;
-
- gint column_offset, i;
+
+ gint column_offset;
gboolean slimm_page_added; /* XXX Kludge to only show one SLIMM page */
- gchar *driver_version;
-
+
/* create the new object */
object = g_object_new(CTK_TYPE_WINDOW, NULL);
@@ -458,7 +458,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* create the config object */
- ctk_window->ctk_config = CTK_CONFIG(ctk_config_new(conf, h));
+ ctk_window->ctk_config = CTK_CONFIG(ctk_config_new(conf, system));
ctk_config = ctk_window->ctk_config;
/* create the quit dialog */
@@ -598,10 +598,9 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* X Server info & configuration */
- if (h->targets[X_SCREEN_TARGET].n) {
+ if (system->targets[X_SCREEN_TARGET]) {
GtkWidget *child;
- int i;
/*
* XXX For now, just use the first handle in the list
@@ -609,17 +608,12 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
* pages and the app profile page below.
*/
- for (i = 0 ; i < h->targets[X_SCREEN_TARGET].n; i++) {
- if (h->targets[X_SCREEN_TARGET].t[i].h) {
- server_handle = h->targets[X_SCREEN_TARGET].t[i].h;
- break;
- }
- }
- if (server_handle) {
+ server_target = NvCtrlGetDefaultTargetByType(system, X_SCREEN_TARGET);
+ if (server_target) {
/* X Server information */
-
- child = ctk_server_new(server_handle, ctk_config);
+
+ child = ctk_server_new(server_target, ctk_config);
add_page(child,
ctk_server_create_help(tag_table,
CTK_SERVER(child)),
@@ -628,7 +622,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* X Server Display Configuration */
- child = ctk_display_config_new(server_handle, ctk_config);
+ child = ctk_display_config_new(server_target, ctk_config);
if (child) {
add_page(child,
ctk_display_config_create_help(tag_table,
@@ -645,20 +639,22 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* add the per-screen entries into the tree model */
slimm_page_added = FALSE;
- for (i = 0; i < h->targets[X_SCREEN_TARGET].n; i++) {
+ for (node = system->targets[X_SCREEN_TARGET]; node; node = node->next) {
gchar *screen_name;
GtkWidget *child;
- NvCtrlAttributeHandle *screen_handle = h->targets[X_SCREEN_TARGET].t[i].h;
+ CtrlTarget *screen_target = node->t;
- if (!screen_handle) continue;
+ if (screen_target == NULL || screen_target->h == NULL) {
+ continue;
+ }
/* create the object for receiving NV-CONTROL events */
- ctk_event = CTK_EVENT(ctk_event_new(screen_handle));
-
+ ctk_event = CTK_EVENT(ctk_event_new(screen_target));
+
screen_name = g_strdup_printf("X Screen %d",
- NvCtrlGetTargetId(screen_handle));
+ NvCtrlGetTargetId(screen_target));
/* create the screen entry */
@@ -668,9 +664,9 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* Screen information */
- screen_name = NvCtrlGetDisplayName(screen_handle);
+ screen_name = NvCtrlGetDisplayName(screen_target);
- child = ctk_screen_new(screen_handle, ctk_event);
+ child = ctk_screen_new(screen_target, ctk_event);
g_object_ref(G_OBJECT(child));
gtk_tree_store_set(ctk_window->tree_store, &iter,
CTK_WINDOW_WIDGET_COLUMN, child, -1);
@@ -686,7 +682,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
if (!slimm_page_added) {
/* SLI Mosaic Mode information */
- child = ctk_slimm_new(screen_handle, ctk_event, ctk_config);
+ child = ctk_slimm_new(screen_target, ctk_event, ctk_config);
if (child) {
slimm_page_added = TRUE;
help = ctk_slimm_create_help(tag_table, "SLI Mosaic Mode Settings");
@@ -700,9 +696,9 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
* available
*/
- if (!has_randr_gamma(screen_handle)) {
+ if (!has_randr_gamma(screen_target)) {
- child = ctk_color_correction_page_new(screen_handle, ctk_config,
+ child = ctk_color_correction_page_new(screen_target, ctk_config,
ctk_window->attribute_list,
ctk_event);
if (child) {
@@ -714,7 +710,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* xvideo settings */
- child = ctk_xvideo_new(screen_handle, ctk_config, ctk_event);
+ child = ctk_xvideo_new(screen_target, ctk_config, ctk_event);
if (child) {
help = ctk_xvideo_create_help(tag_table, CTK_XVIDEO(child));
add_page(child, help, ctk_window, &iter, NULL,
@@ -723,7 +719,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* opengl settings */
- child = ctk_opengl_new(screen_handle, ctk_config, ctk_event);
+ child = ctk_opengl_new(screen_target, ctk_config, ctk_event);
if (child) {
help = ctk_opengl_create_help(tag_table, CTK_OPENGL(child));
add_page(child, help, ctk_window, &iter, NULL, "OpenGL Settings",
@@ -733,7 +729,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* GLX Information */
- child = ctk_glx_new(screen_handle, ctk_config, ctk_event);
+ child = ctk_glx_new(screen_target, ctk_config, ctk_event);
if (child) {
help = ctk_glx_create_help(tag_table, CTK_GLX(child));
add_page(child, help, ctk_window, &iter, NULL,
@@ -743,7 +739,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* multisample settings */
- child = ctk_multisample_new(screen_handle, ctk_config, ctk_event);
+ child = ctk_multisample_new(screen_target, ctk_config, ctk_event);
if (child) {
help = ctk_multisample_create_help(tag_table,
CTK_MULTISAMPLE(child));
@@ -753,16 +749,16 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* VDPAU Information */
- child = ctk_vdpau_new(screen_handle, ctk_config, ctk_event);
+ child = ctk_vdpau_new(screen_target, ctk_config, ctk_event);
if (child) {
help = ctk_vdpau_create_help(tag_table, CTK_VDPAU(child));
add_page(child, help, ctk_window, &iter, NULL, "VDPAU Information",
NULL, NULL, NULL);
}
-
+
/* gvo (Graphics To Video Out) */
-
- child = ctk_gvo_new(screen_handle, ctk_config, ctk_event);
+
+ child = ctk_gvo_new(screen_target, ctk_config, ctk_event);
if (child) {
GtkWidget *gvo_parent = child;
GtkTreeIter child_iter;
@@ -773,7 +769,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* GVO Sync options */
- child = ctk_gvo_sync_new(screen_handle, GTK_WIDGET(ctk_window),
+ child = ctk_gvo_sync_new(screen_target, GTK_WIDGET(ctk_window),
ctk_config, ctk_event,
CTK_GVO(gvo_parent));
if (child) {
@@ -786,7 +782,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* GVO color space conversion */
- child = ctk_gvo_csc_new(screen_handle, ctk_config, ctk_event,
+ child = ctk_gvo_csc_new(screen_target, ctk_config, ctk_event,
CTK_GVO(gvo_parent));
if (child) {
help = ctk_gvo_csc_create_help(tag_table, CTK_GVO_CSC(child));
@@ -799,33 +795,34 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* add the per-gpu entries into the tree model */
- for (i = 0; i < h->targets[GPU_TARGET].n; i++) {
-
+ for (node = system->targets[GPU_TARGET]; node; node = node->next) {
+
gchar *gpu_name;
GtkWidget *child;
- NvCtrlAttributeHandle *gpu_handle = h->targets[GPU_TARGET].t[i].h;
+ CtrlTarget *gpu_target = node->t;
UpdateDisplaysData *data;
- if (!gpu_handle) continue;
+ if (gpu_target == NULL || gpu_target->h == NULL) {
+ continue;
+ }
/* create the gpu entry name */
- gpu_name = create_gpu_name_string(gpu_handle);
+ gpu_name = create_gpu_name_string(gpu_target);
if (!gpu_name) continue;
/* create the object for receiving NV-CONTROL events */
- ctk_event = CTK_EVENT(ctk_event_new(gpu_handle));
-
+ ctk_event = CTK_EVENT(ctk_event_new(gpu_target));
+
/* create the gpu entry */
gtk_tree_store_append(ctk_window->tree_store, &iter, NULL);
gtk_tree_store_set(ctk_window->tree_store, &iter,
CTK_WINDOW_LABEL_COLUMN, gpu_name, -1);
- child = ctk_gpu_new(gpu_handle, h->targets[X_SCREEN_TARGET].t, ctk_event,
- ctk_config);
+ child = ctk_gpu_new(gpu_target, ctk_event, ctk_config);
g_object_ref(G_OBJECT(child));
gtk_tree_store_set(ctk_window->tree_store, &iter,
@@ -845,7 +842,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* thermal information */
- child = ctk_thermal_new(gpu_handle, ctk_config, ctk_event);
+ child = ctk_thermal_new(gpu_target, ctk_config, ctk_event);
if (child) {
help = ctk_thermal_create_help(tag_table, CTK_THERMAL(child));
add_page(child, help, ctk_window, &iter, NULL, "Thermal Settings",
@@ -853,34 +850,26 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
}
/* Powermizer information */
- child = ctk_powermizer_new(gpu_handle, ctk_config, ctk_event);
+ child = ctk_powermizer_new(gpu_target, ctk_config, ctk_event);
if (child) {
help = ctk_powermizer_create_help(tag_table, CTK_POWERMIZER(child));
add_page(child, help, ctk_window, &iter, NULL, "PowerMizer",
NULL, ctk_powermizer_start_timer,
ctk_powermizer_stop_timer);
}
-
- /* clocks (GPU overclocking) */
- child = ctk_clocks_new(gpu_handle, ctk_config, ctk_event);
- if (child) {
- help = ctk_clocks_create_help(tag_table, CTK_CLOCKS(child));
- add_page(child, help, ctk_window, &iter, NULL, "Clock Frequencies",
- NULL, ctk_clocks_select, NULL);
- }
/* ECC Information */
- child = ctk_ecc_new(gpu_handle, ctk_config, ctk_event);
+ child = ctk_ecc_new(gpu_target, ctk_config, ctk_event);
if (child) {
help = ctk_ecc_create_help(tag_table, CTK_ECC(child));
add_page(child, help, ctk_window, &iter, NULL, "ECC Settings",
NULL, ctk_ecc_start_timer, ctk_ecc_stop_timer);
}
+
/* display devices */
- data = calloc(1, sizeof(UpdateDisplaysData));
+ data = calloc(1, sizeof(*data));
data->window = ctk_window;
- data->event = ctk_event;
- data->gpu_handle = gpu_handle;
+ data->gpu_target = gpu_target;
data->parent_iter = iter;
data->tag_table = tag_table;
@@ -894,48 +883,50 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
G_CALLBACK(update_display_devices),
(gpointer) data);
- add_display_devices(ctk_window, &iter, gpu_handle, ctk_event, tag_table,
+ add_display_devices(ctk_window, &iter, gpu_target, ctk_event, tag_table,
data, ctk_window->attribute_list);
}
/* add the per-vcs (e.g. Quadro Plex) entries into the tree model */
- for (i = 0; i < h->targets[VCS_TARGET].n; i++) {
+ for (node = system->targets[VCS_TARGET]; node; node = node->next) {
gchar *vcs_product_name;
gchar *vcs_name;
GtkWidget *child;
ReturnStatus ret;
- NvCtrlAttributeHandle *vcs_handle = h->targets[VCS_TARGET].t[i].h;
+ CtrlTarget *vcs_target = node->t;
- if (!vcs_handle) continue;
+ if (vcs_target == NULL || vcs_target->h == NULL) {
+ continue;
+ }
/* create the vcs entry name */
- ret = NvCtrlGetStringAttribute(vcs_handle,
+ ret = NvCtrlGetStringAttribute(vcs_target,
NV_CTRL_STRING_VCSC_PRODUCT_NAME,
&vcs_product_name);
if (ret == NvCtrlSuccess && vcs_product_name) {
vcs_name = g_strdup_printf("VCS %d - (%s)",
- NvCtrlGetTargetId(vcs_handle),
+ NvCtrlGetTargetId(vcs_target),
vcs_product_name);
- XFree(vcs_product_name);
+ free(vcs_product_name);
} else {
vcs_name = g_strdup_printf("VCS %d - (Unknown)",
- NvCtrlGetTargetId(vcs_handle));
+ NvCtrlGetTargetId(vcs_target));
}
if (!vcs_name) continue;
/* create the object for receiving NV-CONTROL events */
- ctk_event = CTK_EVENT(ctk_event_new(vcs_handle));
+ ctk_event = CTK_EVENT(ctk_event_new(vcs_target));
/* create the vcs entry */
gtk_tree_store_append(ctk_window->tree_store, &iter, NULL);
gtk_tree_store_set(ctk_window->tree_store, &iter,
CTK_WINDOW_LABEL_COLUMN, vcs_name, -1);
- child = ctk_vcs_new(vcs_handle, ctk_config);
+ child = ctk_vcs_new(vcs_target, ctk_config);
g_object_ref(G_OBJECT(child));
gtk_tree_store_set(ctk_window->tree_store, &iter,
CTK_WINDOW_WIDGET_COLUMN, child, -1);
@@ -956,35 +947,37 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* add the per gvi entries into the tree model */
- for (i = 0; i < h->targets[GVI_TARGET].n; i++) {
+ for (node = system->targets[GVI_TARGET]; node; node = node->next) {
gchar *gvi_name;
GtkWidget *child;
- NvCtrlAttributeHandle *gvi_handle = h->targets[GVI_TARGET].t[i].h;
+ CtrlTarget *gvi_target = node->t;
- if (!gvi_handle) continue;
+ if (gvi_target == NULL || gvi_target->h == NULL) {
+ continue;
+ }
/* create the gvi entry name */
- if (h->targets[GVI_TARGET].n > 1) {
+ if (node->next) {
gvi_name = g_strdup_printf("Graphics to Video In %d",
- NvCtrlGetTargetId(gvi_handle));
+ NvCtrlGetTargetId(gvi_target));
} else {
gvi_name = g_strdup_printf("Graphics to Video In");
}
-
+
if (!gvi_name) continue;
/* create the object for receiving NV-CONTROL events */
- ctk_event = CTK_EVENT(ctk_event_new(gvi_handle));
+ ctk_event = CTK_EVENT(ctk_event_new(gvi_target));
/* create the gvi entry */
gtk_tree_store_append(ctk_window->tree_store, &iter, NULL);
gtk_tree_store_set(ctk_window->tree_store, &iter,
CTK_WINDOW_LABEL_COLUMN, gvi_name, -1);
- child = ctk_gvi_new(gvi_handle, ctk_config, ctk_event);
+ child = ctk_gvi_new(gvi_target, ctk_config, ctk_event);
g_object_ref(G_OBJECT(child));
gtk_tree_store_set(ctk_window->tree_store, &iter,
CTK_WINDOW_WIDGET_COLUMN, child, -1);
@@ -1007,13 +1000,15 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
* frame lock
*/
- for (i = 0; i < h->targets[X_SCREEN_TARGET].n; i++) {
+ for (node = system->targets[X_SCREEN_TARGET]; node; node = node->next) {
- NvCtrlAttributeHandle *screen_handle = h->targets[X_SCREEN_TARGET].t[i].h;
+ CtrlTarget *screen_target = node->t;
- if (!screen_handle) continue;
-
- widget = ctk_framelock_new(screen_handle, GTK_WIDGET(ctk_window),
+ if (screen_target == NULL || screen_target->h == NULL) {
+ continue;
+ }
+
+ widget = ctk_framelock_new(screen_target, GTK_WIDGET(ctk_window),
ctk_config, ctk_window->attribute_list);
if (!widget) continue;
@@ -1027,16 +1022,20 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
/* add NVIDIA 3D VisionPro dongle configuration page */
- for (i = 0; i < h->targets[NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET].n; i++) {
- NvCtrlAttributeHandle *svp_handle = h->targets[NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET].t[i].h;
+ for (node = system->targets[NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET];
+ node;
+ node = node->next) {
+ CtrlTarget *svp_target = node->t;
- if (!svp_handle) continue;
+ if (svp_target == NULL || svp_target->h == NULL) {
+ continue;
+ }
/* create the object for receiving NV-CONTROL events */
- ctk_event = CTK_EVENT(ctk_event_new(svp_handle));
+ ctk_event = CTK_EVENT(ctk_event_new(svp_target));
- widget = ctk_3d_vision_pro_new(svp_handle, ctk_config,
+ widget = ctk_3d_vision_pro_new(svp_target, ctk_config,
ctk_window->attribute_list,
ctk_event);
if (!widget) continue;
@@ -1048,28 +1047,13 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf,
}
/* app profile configuration */
- if (server_handle)
- {
- ReturnStatus ret = NvCtrlGetStringAttribute(server_handle,
- NV_CTRL_STRING_NVIDIA_DRIVER_VERSION,
- &driver_version);
- if (ret != NvCtrlSuccess) {
- driver_version = NULL;
- }
- } else {
- driver_version = NULL;
- }
-
- widget = ctk_app_profile_new(ctk_config, driver_version);
-
- if (driver_version) {
- XFree(driver_version);
+ widget = ctk_app_profile_new(server_target, ctk_config);
+ if (widget) {
+ add_page(widget, ctk_app_profile_create_help(CTK_APP_PROFILE(widget), tag_table),
+ ctk_window, NULL, NULL, "Application Profiles",
+ NULL, NULL, NULL);
}
- add_page(widget, ctk_app_profile_create_help(CTK_APP_PROFILE(widget), tag_table),
- ctk_window, NULL, NULL, "Application Profiles",
- NULL, NULL, NULL);
-
/* nvidia-settings configuration */
add_page(GTK_WIDGET(ctk_window->ctk_config),
@@ -1412,7 +1396,7 @@ void add_special_config_file_attributes(CtkWindow *ctk_window)
*/
static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter,
- NvCtrlAttributeHandle *gpu_handle,
+ CtrlTarget *gpu_target,
CtkEvent *ctk_event_gpu,
GtkTextTagTable *tag_table,
UpdateDisplaysData *data,
@@ -1420,25 +1404,35 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter,
{
GtkTextBuffer *help;
ReturnStatus ret;
- int *pData;
+ int *pData = NULL;
int len;
int i;
- NvCtrlAttributeHandle *display_handle;
/* retrieve the list of connected display devices */
- ret = NvCtrlGetBinaryAttribute(gpu_handle, 0,
+ ret = NvCtrlGetBinaryAttribute(gpu_target, 0,
NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU,
(unsigned char **)(&pData), &len);
if ((ret != NvCtrlSuccess) || (pData[0] <= 0)) {
- return;
+ goto done;
}
nvfree(data->display_iters);
+ nvfree(data->display_events);
+
data->display_iters = calloc(pData[0], sizeof(GtkTreeIter));
+ if (!data->display_iters) {
+ goto done;
+ }
+
+ data->display_events = calloc(pData[0], sizeof(CtkEvent*));
+ if (!data->display_events) {
+ nvfree(data->display_iters);
+ goto done;
+ }
+
data->num_displays = 0;
- if (!data->display_iters) return;
/*
@@ -1454,7 +1448,8 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter,
GtkWidget *widget;
gchar *title;
CtkEvent *ctk_event;
- CtrlHandles *handles = ctk_window->ctk_config->pCtrlHandles;
+ CtrlSystem *system = ctk_window->ctk_config->pCtrlSystem;
+ CtrlTarget *target;
/*
* Get the ctrl handle that was passed into ctk_main so that updated
@@ -1462,16 +1457,10 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter,
* saved to the RC file when the UI is closed.
*/
- display_handle = nv_get_target_handle(handles,
- NV_CTRL_TARGET_TYPE_DISPLAY,
- display_id);
-
- if (!display_handle) {
- display_handle =
- nv_add_target(handles, NvCtrlGetDisplayPtr(gpu_handle),
- NV_CTRL_TARGET_TYPE_DISPLAY, display_id);
-
- if (!display_handle) {
+ target = NvCtrlGetTarget(system, DISPLAY_TARGET, display_id);
+ if (!target) {
+ target = nv_add_target(system, DISPLAY_TARGET, display_id);
+ if (!target) {
continue;
}
}
@@ -1479,26 +1468,22 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter,
/*
* Rebuild Sub-systems of display handle
*/
- NvCtrlAttributeRebuildSubsystems(display_handle,
- NV_CTRL_ATTRIBUTES_ALL_SUBSYSTEMS);
-
- ctk_event = CTK_EVENT(ctk_event_new(display_handle));
+ NvCtrlRebuildSubsystems(target, NV_CTRL_ATTRIBUTES_ALL_SUBSYSTEMS);
/* Query display's names */
- ret = NvCtrlGetStringAttribute(display_handle,
+ ret = NvCtrlGetStringAttribute(target,
NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME,
&typeBaseName);
if (ret != NvCtrlSuccess) {
- NvCtrlAttributeClose(display_handle);
continue;
}
- ret = NvCtrlGetStringAttribute(display_handle,
+ ret = NvCtrlGetStringAttribute(target,
NV_CTRL_STRING_DISPLAY_DEVICE_NAME,
&logName);
if (ret != NvCtrlSuccess) {
logName = NULL;
}
- ret = NvCtrlGetStringAttribute(display_handle,
+ ret = NvCtrlGetStringAttribute(target,
NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID,
&typeIdName);
if (ret != NvCtrlSuccess) {
@@ -1510,28 +1495,35 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter,
} else {
title = g_strdup_printf("%s - (%s)", typeIdName, logName);
}
- XFree(logName);
- XFree(typeIdName);
+ free(logName);
+ free(typeIdName);
/* Create the page for the display */
- widget = ctk_display_device_new(display_handle,
+ ctk_event = CTK_EVENT(ctk_event_new(target));
+ widget = ctk_display_device_new(target,
ctk_window->ctk_config, ctk_event,
ctk_event_gpu,
title, typeBaseName, p);
- if (widget == NULL) {
- NvCtrlAttributeClose(display_handle);
- } else {
+ if (widget != NULL) {
help = ctk_display_device_create_help(tag_table,
CTK_DISPLAY_DEVICE(widget));
add_page(widget, help, ctk_window, iter,
&(data->display_iters[data->num_displays]), title,
NULL, NULL, NULL);
+ data->display_events[data->num_displays] = ctk_event;
data->num_displays++;
}
+ else {
+ ctk_event_destroy(G_OBJECT(ctk_event));
+ }
- XFree(typeBaseName);
+ free(typeBaseName);
g_free(title);
}
+
+ done:
+ free(pData);
+
} /* add_display_devices() */
@@ -1572,13 +1564,14 @@ static void select_display_page(UpdateDisplaysData *data, gchar *name)
*
*/
-static void update_display_devices(GtkWidget *object, gpointer arg1,
+static void update_display_devices(GtkWidget *object,
+ CtrlEvent *event,
gpointer user_data)
{
UpdateDisplaysData *data = (UpdateDisplaysData *) user_data;
CtkWindow *ctk_window = data->window;
- NvCtrlAttributeHandle *gpu_handle = data->gpu_handle;
+ CtrlTarget *gpu_target = data->gpu_target;
GtkTreeIter parent_iter = data->parent_iter;
GtkTextTagTable *tag_table = data->tag_table;
GtkTreePath* parent_path;
@@ -1623,6 +1616,10 @@ static void update_display_devices(GtkWidget *object, gpointer arg1,
/* unref the page so we don't leak memory */
g_object_unref(G_OBJECT(widget));
+ /* Destroy the display CtkEvent */
+ ctk_event_destroy(G_OBJECT(
+ data->display_events[data->num_displays - 1]));
+
data->num_displays--;
}
@@ -1631,7 +1628,7 @@ static void update_display_devices(GtkWidget *object, gpointer arg1,
gtk_tree_model_get(GTK_TREE_MODEL(ctk_window->tree_store), &parent_iter,
CTK_WINDOW_WIDGET_COLUMN, &widget, -1);
- add_display_devices(ctk_window, &parent_iter, gpu_handle,
+ add_display_devices(ctk_window, &parent_iter, gpu_target,
CTK_GPU(widget)->ctk_event,
tag_table, data, ctk_window->attribute_list);
diff --git a/src/gtk+-2.x/ctkwindow.h b/src/gtk+-2.x/ctkwindow.h
index b5dc248..883bece 100644
--- a/src/gtk+-2.x/ctkwindow.h
+++ b/src/gtk+-2.x/ctkwindow.h
@@ -87,7 +87,7 @@ struct _CtkWindowClass
GType ctk_window_get_type (void) G_GNUC_CONST;
GtkWidget* ctk_window_new (ParsedAttribute *, ConfigProperties *conf,
- CtrlHandles *h);
+ CtrlSystem *system);
void ctk_window_set_active_page(CtkWindow *ctk_window,
const gchar *label);
diff --git a/src/gtk+-2.x/ctkxvideo.c b/src/gtk+-2.x/ctkxvideo.c
index 878a550..6e53447 100644
--- a/src/gtk+-2.x/ctkxvideo.c
+++ b/src/gtk+-2.x/ctkxvideo.c
@@ -96,6 +96,7 @@ static void xv_sync_to_display_id_toggled(GtkWidget *widget,
gpointer user_data)
{
CtkXVideo *ctk_xvideo = CTK_XVIDEO(user_data);
+ CtrlTarget *ctrl_target = ctk_xvideo->ctrl_target;
gboolean enabled;
gint device_id;
@@ -109,8 +110,7 @@ static void xv_sync_to_display_id_toggled(GtkWidget *widget,
device_id = GPOINTER_TO_INT(user_data);
- NvCtrlSetAttribute(ctk_xvideo->handle, NV_CTRL_XV_SYNC_TO_DISPLAY_ID,
- device_id);
+ NvCtrlSetAttribute(ctrl_target, NV_CTRL_XV_SYNC_TO_DISPLAY_ID, device_id);
post_xv_sync_to_display_update(ctk_xvideo, widget);
}
@@ -156,36 +156,31 @@ static GtkWidget *xv_sync_to_display_radio_button_add(CtkXVideo *ctk_xvideo,
GtkWidget *last_button,
gint display_id)
{
- Bool valid;
- char *name;
- char *randr;
+ CtrlTarget *ctrl_target;
+ ReturnStatus ret;
+ char *name = NULL;
+ char *randr = NULL;
gchar *label;
GtkWidget *button;
GSList *slist;
+ ctrl_target = NvCtrlGetTarget(ctk_xvideo->ctrl_target->system,
+ DISPLAY_TARGET, display_id);
+ if (ctrl_target) {
+ ret = NvCtrlGetStringAttribute(ctrl_target,
+ NV_CTRL_STRING_DISPLAY_DEVICE_NAME,
+ &name);
+ if (ret != NvCtrlSuccess) {
+ name = NULL;
+ }
- valid =
- XNVCTRLQueryTargetStringAttribute(NvCtrlGetDisplayPtr(ctk_xvideo->handle),
- NV_CTRL_TARGET_TYPE_DISPLAY,
- display_id,
- 0,
- NV_CTRL_STRING_DISPLAY_DEVICE_NAME,
- &name);
- if (!valid) {
- name = NULL;
- }
-
- valid =
- XNVCTRLQueryTargetStringAttribute(NvCtrlGetDisplayPtr(ctk_xvideo->handle),
- NV_CTRL_TARGET_TYPE_DISPLAY,
- display_id,
- 0,
- NV_CTRL_STRING_DISPLAY_NAME_RANDR,
- &randr);
- if (!valid) {
- randr = NULL;
+ ret = NvCtrlGetStringAttribute(ctrl_target,
+ NV_CTRL_STRING_DISPLAY_NAME_RANDR,
+ &randr);
+ if (ret != NvCtrlSuccess) {
+ randr = NULL;
+ }
}
-
if (name && randr) {
label = g_strdup_printf("%s (%s)", name, randr);
} else {
@@ -193,8 +188,8 @@ static GtkWidget *xv_sync_to_display_radio_button_add(CtkXVideo *ctk_xvideo,
name ? name : (randr ? randr : "Unknown"));
}
- XFree(name);
- XFree(randr);
+ free(name);
+ free(randr);
if (last_button) {
slist = gtk_radio_button_get_group(GTK_RADIO_BUTTON(last_button));
@@ -237,6 +232,7 @@ static void xv_sync_to_display_rebuild_buttons(CtkXVideo *ctk_xvideo,
int i;
GtkWidget *last_button;
+ CtrlTarget *ctrl_target = ctk_xvideo->ctrl_target;
/* Remove all buttons */
@@ -246,22 +242,22 @@ static void xv_sync_to_display_rebuild_buttons(CtkXVideo *ctk_xvideo,
/* Rebuild the list based on the curren configuration */
- ret = NvCtrlGetAttribute(ctk_xvideo->handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_XV_SYNC_TO_DISPLAY_ID,
&enabled_display_id);
if (ret != NvCtrlSuccess) {
nv_warning_msg("Failed to query XV Sync display ID on X screen %d.",
- NvCtrlGetTargetId(ctk_xvideo->handle));
+ NvCtrlGetTargetId(ctrl_target));
return;
}
- ret = NvCtrlGetBinaryAttribute(ctk_xvideo->handle, 0,
+ ret = NvCtrlGetBinaryAttribute(ctrl_target, 0,
NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN,
(unsigned char **)(&pData), &len);
if (ret != NvCtrlSuccess) {
nv_warning_msg("Failed to query list of displays assigned to X screen "
" %d.",
- NvCtrlGetTargetId(ctk_xvideo->handle));
+ NvCtrlGetTargetId(ctrl_target));
return;
}
@@ -317,13 +313,16 @@ static void enabled_displays_handler(GObject *object, gpointer arg1,
* Handler for NV_CTRL_XV_SYNC_TO_DISPLAY_ID events.
*/
static void xv_sync_to_display_id_handler(GObject *object,
- gpointer arg1,
+ CtrlEvent *event,
gpointer user_data)
{
- CtkEventStruct *event_struct = (CtkEventStruct *) arg1;
CtkXVideo *ctk_xvideo = CTK_XVIDEO(user_data);
GSList *slist;
+ if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) {
+ return;
+ }
+
/* Find the right button and enable it */
slist =
@@ -333,7 +332,7 @@ static void xv_sync_to_display_id_handler(GObject *object,
GtkWidget *button = GTK_WIDGET(slist->data);
user_data = g_object_get_data(G_OBJECT(button), "display_id");
- if (GPOINTER_TO_INT(user_data) == event_struct->value) {
+ if (GPOINTER_TO_INT(user_data) == event->int_attr.value) {
xv_sync_to_display_set_enabled(ctk_xvideo, button, TRUE);
break;
}
@@ -347,7 +346,7 @@ static void xv_sync_to_display_id_handler(GObject *object,
/*
* ctk_xvideo_new() - constructor for the XVideo widget
*/
-GtkWidget* ctk_xvideo_new(NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_xvideo_new(CtrlTarget *ctrl_target,
CtkConfig *ctk_config,
CtkEvent *ctk_event)
{
@@ -366,19 +365,19 @@ GtkWidget* ctk_xvideo_new(NvCtrlAttributeHandle *handle,
* are present
*/
- ret = NvCtrlGetAttribute(handle, NV_CTRL_ATTR_EXT_XV_OVERLAY_PRESENT,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_ATTR_EXT_XV_OVERLAY_PRESENT,
&xv_overlay_present);
if (ret != NvCtrlSuccess) {
xv_overlay_present = FALSE;
}
- ret = NvCtrlGetAttribute(handle, NV_CTRL_ATTR_EXT_XV_TEXTURE_PRESENT,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_ATTR_EXT_XV_TEXTURE_PRESENT,
&xv_texture_present);
if (ret != NvCtrlSuccess) {
xv_texture_present = FALSE;
}
- ret = NvCtrlGetAttribute(handle, NV_CTRL_ATTR_EXT_XV_BLITTER_PRESENT,
+ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_ATTR_EXT_XV_BLITTER_PRESENT,
&xv_blitter_present);
if (ret != NvCtrlSuccess) {
xv_blitter_present = FALSE;
@@ -393,7 +392,7 @@ GtkWidget* ctk_xvideo_new(NvCtrlAttributeHandle *handle,
show_page = FALSE;
if (xv_texture_present || xv_blitter_present) {
int display_id;
- ret = NvCtrlGetAttribute(handle,
+ ret = NvCtrlGetAttribute(ctrl_target,
NV_CTRL_XV_SYNC_TO_DISPLAY_ID,
&display_id);
if (ret == NvCtrlSuccess) {
@@ -411,7 +410,7 @@ GtkWidget* ctk_xvideo_new(NvCtrlAttributeHandle *handle,
object = g_object_new(CTK_TYPE_XVIDEO, NULL);
ctk_xvideo = CTK_XVIDEO(object);
- ctk_xvideo->handle = handle;
+ ctk_xvideo->ctrl_target = ctrl_target;
ctk_xvideo->ctk_config = ctk_config;
ctk_xvideo->active_attributes = 0;
diff --git a/src/gtk+-2.x/ctkxvideo.h b/src/gtk+-2.x/ctkxvideo.h
index 06cad06..ca2201f 100644
--- a/src/gtk+-2.x/ctkxvideo.h
+++ b/src/gtk+-2.x/ctkxvideo.h
@@ -20,7 +20,7 @@
#ifndef __CTK_XVIDEO_H__
#define __CTK_XVIDEO_H__
-#include "NvCtrlAttributes.h"
+#include "query-assign.h"
#include "ctkconfig.h"
#include "ctkevent.h"
@@ -51,7 +51,7 @@ struct _CtkXVideo
{
GtkVBox parent;
- NvCtrlAttributeHandle *handle;
+ CtrlTarget *ctrl_target;
CtkConfig *ctk_config;
GtkWidget *xv_sync_to_display_buttons; /* first button in group */
@@ -66,7 +66,7 @@ struct _CtkXVideoClass
};
GType ctk_xvideo_get_type (void) G_GNUC_CONST;
-GtkWidget* ctk_xvideo_new (NvCtrlAttributeHandle *handle,
+GtkWidget* ctk_xvideo_new (CtrlTarget *ctrl_target,
CtkConfig *ctk_config, CtkEvent *ctk_event);
GtkTextBuffer *ctk_xvideo_create_help(GtkTextTagTable *, CtkXVideo *);
diff --git a/src/libXNVCtrl/NVCtrl.h b/src/libXNVCtrl/NVCtrl.h
index 25bcff2..415da49 100644
--- a/src/libXNVCtrl/NVCtrl.h
+++ b/src/libXNVCtrl/NVCtrl.h
@@ -141,24 +141,24 @@
* NV_CTRL_FLATPANEL_SCALING - not supported
*/
-#define NV_CTRL_FLATPANEL_SCALING 2 /* RWDG */
-#define NV_CTRL_FLATPANEL_SCALING_DEFAULT 0
-#define NV_CTRL_FLATPANEL_SCALING_NATIVE 1
-#define NV_CTRL_FLATPANEL_SCALING_SCALED 2
-#define NV_CTRL_FLATPANEL_SCALING_CENTERED 3
-#define NV_CTRL_FLATPANEL_SCALING_ASPECT_SCALED 4
+#define NV_CTRL_FLATPANEL_SCALING 2 /* not supported */
+#define NV_CTRL_FLATPANEL_SCALING_DEFAULT 0 /* not supported */
+#define NV_CTRL_FLATPANEL_SCALING_NATIVE 1 /* not supported */
+#define NV_CTRL_FLATPANEL_SCALING_SCALED 2 /* not supported */
+#define NV_CTRL_FLATPANEL_SCALING_CENTERED 3 /* not supported */
+#define NV_CTRL_FLATPANEL_SCALING_ASPECT_SCALED 4 /* not supported */
/*
- * NV_CTRL_FLATPANEL_DITHERING - deprecated
+ * NV_CTRL_FLATPANEL_DITHERING - not supported
*
* NV_CTRL_DITHERING should be used instead.
*/
-#define NV_CTRL_FLATPANEL_DITHERING 3 /* RWDG */
-#define NV_CTRL_FLATPANEL_DITHERING_DEFAULT 0 /* deprecated */
-#define NV_CTRL_FLATPANEL_DITHERING_ENABLED 1 /* deprecated */
-#define NV_CTRL_FLATPANEL_DITHERING_DISABLED 2 /* deprecated */
+#define NV_CTRL_FLATPANEL_DITHERING 3 /* not supported */
+#define NV_CTRL_FLATPANEL_DITHERING_DEFAULT 0 /* not supported */
+#define NV_CTRL_FLATPANEL_DITHERING_ENABLED 1 /* not supported */
+#define NV_CTRL_FLATPANEL_DITHERING_DISABLED 2 /* not supported */
/*
* NV_CTRL_DITHERING - the requested dithering configuration;
@@ -346,12 +346,11 @@
#define NV_CTRL_STEREO_MAX NV_CTRL_STEREO_TRIDELITY_SL
/*
- * NV_CTRL_EMULATE - controls OpenGL software emulation of future
- * NVIDIA GPUs.
+ * NV_CTRL_EMULATE - not supported
*/
-#define NV_CTRL_EMULATE 17 /* RW- */
-#define NV_CTRL_EMULATE_NONE 0
+#define NV_CTRL_EMULATE 17 /* not supported */
+#define NV_CTRL_EMULATE_NONE 0 /* not supported */
/*
@@ -371,7 +370,7 @@
* NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN should be used instead.
*/
-#define NV_CTRL_CONNECTED_DISPLAYS 19 /* R--G */
+#define NV_CTRL_CONNECTED_DISPLAYS 19 /* deprecated */
/*
@@ -418,9 +417,9 @@
* NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead.
*/
-#define NV_CTRL_FRAMELOCK_MASTER 22 /* RW-G */
-#define NV_CTRL_FRAMELOCK_MASTER_FALSE 0 /* deprecated */
-#define NV_CTRL_FRAMELOCK_MASTER_TRUE 1 /* deprecated */
+#define NV_CTRL_FRAMELOCK_MASTER 22 /* deprecated */
+#define NV_CTRL_FRAMELOCK_MASTER_FALSE 0 /* deprecated */
+#define NV_CTRL_FRAMELOCK_MASTER_TRUE 1 /* deprecated */
/*
@@ -448,7 +447,7 @@
* using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN
* target.
*
- * USAGE NODE: NV_CTRL_FRAMELOCK_SYNC_DELAY_MAX and
+ * USAGE NOTE: NV_CTRL_FRAMELOCK_SYNC_DELAY_MAX and
* NV_CTRL_FRAMELOCK_SYNC_DELAY_FACTOR are deprecated.
* The Sync Delay _MAX and _FACTOR are different for different
* Quadro Sync products and so, to be correct, the valid values for
@@ -649,14 +648,12 @@
/**************************************************************************/
/*
- * NV_CTRL_FORCE_GENERIC_CPU - deprecated
- *
- * CPU compatibility is now checked each time during initialization.
+ * NV_CTRL_FORCE_GENERIC_CPU - not supported
*/
-#define NV_CTRL_FORCE_GENERIC_CPU 37 /* RW-X */
-#define NV_CTRL_FORCE_GENERIC_CPU_DISABLE 0 /* deprecated */
-#define NV_CTRL_FORCE_GENERIC_CPU_ENABLE 1 /* deprecated */
+#define NV_CTRL_FORCE_GENERIC_CPU 37 /* not supported */
+#define NV_CTRL_FORCE_GENERIC_CPU_DISABLE 0 /* not supported */
+#define NV_CTRL_FORCE_GENERIC_CPU_ENABLE 1 /* not supported */
/*
@@ -725,21 +722,22 @@
/*
- * The NV_CTRL_CURSOR_SHADOW attributes are no longer supported; use
- * an ARGB cursor instead.
+ * The NV_CTRL_CURSOR_SHADOW - not supported
+ *
+ * use an ARGB cursor instead.
*/
-#define NV_CTRL_CURSOR_SHADOW 43 /* --- */
-#define NV_CTRL_CURSOR_SHADOW_DISABLE 0
-#define NV_CTRL_CURSOR_SHADOW_ENABLE 1
+#define NV_CTRL_CURSOR_SHADOW 43 /* not supported */
+#define NV_CTRL_CURSOR_SHADOW_DISABLE 0 /* not supported */
+#define NV_CTRL_CURSOR_SHADOW_ENABLE 1 /* not supported */
-#define NV_CTRL_CURSOR_SHADOW_ALPHA 44 /* --- */
-#define NV_CTRL_CURSOR_SHADOW_RED 45 /* --- */
-#define NV_CTRL_CURSOR_SHADOW_GREEN 46 /* --- */
-#define NV_CTRL_CURSOR_SHADOW_BLUE 47 /* --- */
+#define NV_CTRL_CURSOR_SHADOW_ALPHA 44 /* not supported */
+#define NV_CTRL_CURSOR_SHADOW_RED 45 /* not supported */
+#define NV_CTRL_CURSOR_SHADOW_GREEN 46 /* not supported */
+#define NV_CTRL_CURSOR_SHADOW_BLUE 47 /* not supported */
-#define NV_CTRL_CURSOR_SHADOW_X_OFFSET 48 /* --- */
-#define NV_CTRL_CURSOR_SHADOW_Y_OFFSET 49 /* --- */
+#define NV_CTRL_CURSOR_SHADOW_X_OFFSET 48 /* not supported */
+#define NV_CTRL_CURSOR_SHADOW_Y_OFFSET 49 /* not supported */
@@ -781,49 +779,49 @@
* NV_CTRL_TV_OVERSCAN - not supported
*/
-#define NV_CTRL_TV_OVERSCAN 53 /* RWDG */
+#define NV_CTRL_TV_OVERSCAN 53 /* not supported */
/*
* NV_CTRL_TV_FLICKER_FILTER - not supported
*/
-#define NV_CTRL_TV_FLICKER_FILTER 54 /* RWDG */
+#define NV_CTRL_TV_FLICKER_FILTER 54 /* not supported */
/*
* NV_CTRL_TV_BRIGHTNESS - not supported
*/
-#define NV_CTRL_TV_BRIGHTNESS 55 /* RWDG */
+#define NV_CTRL_TV_BRIGHTNESS 55 /* not supported */
/*
* NV_CTRL_TV_HUE - not supported
*/
-#define NV_CTRL_TV_HUE 56 /* RWDG */
+#define NV_CTRL_TV_HUE 56 /* not supported */
/*
* NV_CTRL_TV_CONTRAST - not suppoerted
*/
-#define NV_CTRL_TV_CONTRAST 57 /* RWDG */
+#define NV_CTRL_TV_CONTRAST 57 /* not supported */
/*
* NV_CTRL_TV_SATURATION - not supported
*/
-#define NV_CTRL_TV_SATURATION 58 /* RWDG */
+#define NV_CTRL_TV_SATURATION 58 /* not supported */
/*
* NV_CTRL_TV_RESET_SETTINGS - not supported
*/
-#define NV_CTRL_TV_RESET_SETTINGS 59 /* -WDG */
+#define NV_CTRL_TV_RESET_SETTINGS 59 /* not supported */
/*
@@ -1083,51 +1081,51 @@
#define NV_CTRL_GVIO_VIDEO_FORMAT_2048I_47_96_3G_LEVEL_B_SMPTE372 64
-/*
- * The following are deprecated; NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT and the
+/*
+ * The following have been renamed; NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT and the
* corresponding NV_CTRL_GVIO_* formats should be used instead.
*/
-#define NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT 70 /* RW- */
-
-#define NV_CTRL_GVO_VIDEO_FORMAT_NONE 0
-#define NV_CTRL_GVO_VIDEO_FORMAT_487I_59_94_SMPTE259_NTSC 1
-#define NV_CTRL_GVO_VIDEO_FORMAT_576I_50_00_SMPTE259_PAL 2
-#define NV_CTRL_GVO_VIDEO_FORMAT_720P_59_94_SMPTE296 3
-#define NV_CTRL_GVO_VIDEO_FORMAT_720P_60_00_SMPTE296 4
-#define NV_CTRL_GVO_VIDEO_FORMAT_1035I_59_94_SMPTE260 5
-#define NV_CTRL_GVO_VIDEO_FORMAT_1035I_60_00_SMPTE260 6
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_50_00_SMPTE295 7
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_50_00_SMPTE274 8
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_59_94_SMPTE274 9
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_60_00_SMPTE274 10
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080P_23_976_SMPTE274 11
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080P_24_00_SMPTE274 12
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080P_25_00_SMPTE274 13
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080P_29_97_SMPTE274 14
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080P_30_00_SMPTE274 15
-#define NV_CTRL_GVO_VIDEO_FORMAT_720P_50_00_SMPTE296 16
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_48_00_SMPTE274 17
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_47_96_SMPTE274 18
-#define NV_CTRL_GVO_VIDEO_FORMAT_720P_30_00_SMPTE296 19
-#define NV_CTRL_GVO_VIDEO_FORMAT_720P_29_97_SMPTE296 20
-#define NV_CTRL_GVO_VIDEO_FORMAT_720P_25_00_SMPTE296 21
-#define NV_CTRL_GVO_VIDEO_FORMAT_720P_24_00_SMPTE296 22
-#define NV_CTRL_GVO_VIDEO_FORMAT_720P_23_98_SMPTE296 23
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_25_00_SMPTE274 24
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_29_97_SMPTE274 25
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_30_00_SMPTE274 26
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_24_00_SMPTE274 27
-#define NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_23_98_SMPTE274 28
-#define NV_CTRL_GVO_VIDEO_FORMAT_2048P_30_00_SMPTE372 29
-#define NV_CTRL_GVO_VIDEO_FORMAT_2048P_29_97_SMPTE372 30
-#define NV_CTRL_GVO_VIDEO_FORMAT_2048I_60_00_SMPTE372 31
-#define NV_CTRL_GVO_VIDEO_FORMAT_2048I_59_94_SMPTE372 32
-#define NV_CTRL_GVO_VIDEO_FORMAT_2048P_25_00_SMPTE372 33
-#define NV_CTRL_GVO_VIDEO_FORMAT_2048I_50_00_SMPTE372 34
-#define NV_CTRL_GVO_VIDEO_FORMAT_2048P_24_00_SMPTE372 35
-#define NV_CTRL_GVO_VIDEO_FORMAT_2048P_23_98_SMPTE372 36
-#define NV_CTRL_GVO_VIDEO_FORMAT_2048I_48_00_SMPTE372 37
-#define NV_CTRL_GVO_VIDEO_FORMAT_2048I_47_96_SMPTE372 38
+#define NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT 70 /* renamed */
+
+#define NV_CTRL_GVO_VIDEO_FORMAT_NONE 0 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_487I_59_94_SMPTE259_NTSC 1 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_576I_50_00_SMPTE259_PAL 2 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_720P_59_94_SMPTE296 3 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_720P_60_00_SMPTE296 4 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1035I_59_94_SMPTE260 5 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1035I_60_00_SMPTE260 6 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_50_00_SMPTE295 7 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_50_00_SMPTE274 8 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_59_94_SMPTE274 9 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_60_00_SMPTE274 10 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080P_23_976_SMPTE274 11 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080P_24_00_SMPTE274 12 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080P_25_00_SMPTE274 13 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080P_29_97_SMPTE274 14 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080P_30_00_SMPTE274 15 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_720P_50_00_SMPTE296 16 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_48_00_SMPTE274 17 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080I_47_96_SMPTE274 18 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_720P_30_00_SMPTE296 19 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_720P_29_97_SMPTE296 20 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_720P_25_00_SMPTE296 21 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_720P_24_00_SMPTE296 22 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_720P_23_98_SMPTE296 23 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_25_00_SMPTE274 24 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_29_97_SMPTE274 25 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_30_00_SMPTE274 26 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_24_00_SMPTE274 27 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_23_98_SMPTE274 28 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_2048P_30_00_SMPTE372 29 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_2048P_29_97_SMPTE372 30 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_2048I_60_00_SMPTE372 31 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_2048I_59_94_SMPTE372 32 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_2048P_25_00_SMPTE372 33 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_2048I_50_00_SMPTE372 34 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_2048P_24_00_SMPTE372 35 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_2048P_23_98_SMPTE372 36 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_2048I_48_00_SMPTE372 37 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_2048I_47_96_SMPTE372 38 /* renamed */
/*
* NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT - indicates the input video format
@@ -1142,12 +1140,12 @@
#define NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT 71 /* R--I */
/*
- * NV_CTRL_GVO_INPUT_VIDEO_FORMAT - deprecated
+ * NV_CTRL_GVO_INPUT_VIDEO_FORMAT - renamed
*
* NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT should be used instead.
*/
-#define NV_CTRL_GVO_INPUT_VIDEO_FORMAT 71 /* R-- */
+#define NV_CTRL_GVO_INPUT_VIDEO_FORMAT 71 /* renamed */
/*
* NV_CTRL_GVO_DATA_FORMAT - This controls how the data in the source
@@ -1169,26 +1167,26 @@
#define NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_YCRCB422 3
#define NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_YCRCBA4224 4
#define NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_YCRCBZ4224 5
-#define NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_RGB444 6 // renamed
+#define NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_RGB444 6 /* renamed */
#define NV_CTRL_GVO_DATA_FORMAT_X8X8X8_444_PASSTHRU 6
-#define NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_RGBA4444 7 // renamed
+#define NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_RGBA4444 7 /* renamed */
#define NV_CTRL_GVO_DATA_FORMAT_X8X8X8A8_4444_PASSTHRU 7
-#define NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_RGBZ4444 8 // renamed
+#define NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_RGBZ4444 8 /* renamed */
#define NV_CTRL_GVO_DATA_FORMAT_X8X8X8Z8_4444_PASSTHRU 8
-#define NV_CTRL_GVO_DATA_FORMAT_Y10CR10CB10_TO_YCRCB444 9 // renamed
+#define NV_CTRL_GVO_DATA_FORMAT_Y10CR10CB10_TO_YCRCB444 9 /* renamed */
#define NV_CTRL_GVO_DATA_FORMAT_X10X10X10_444_PASSTHRU 9
-#define NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8_TO_YCRCB444 10 // renamed
+#define NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8_TO_YCRCB444 10 /* renamed */
#define NV_CTRL_GVO_DATA_FORMAT_X10X8X8_444_PASSTHRU 10
-#define NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8A10_TO_YCRCBA4444 11 // renamed
+#define NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8A10_TO_YCRCBA4444 11 /* renamed */
#define NV_CTRL_GVO_DATA_FORMAT_X10X8X8A10_4444_PASSTHRU 11
-#define NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8Z10_TO_YCRCBZ4444 12 // renamed
+#define NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8Z10_TO_YCRCBZ4444 12 /* renamed */
#define NV_CTRL_GVO_DATA_FORMAT_X10X8X8Z10_4444_PASSTHRU 12
#define NV_CTRL_GVO_DATA_FORMAT_DUAL_R8G8B8_TO_DUAL_YCRCB422 13
-#define NV_CTRL_GVO_DATA_FORMAT_DUAL_Y8CR8CB8_TO_DUAL_YCRCB422 14 // renamed
+#define NV_CTRL_GVO_DATA_FORMAT_DUAL_Y8CR8CB8_TO_DUAL_YCRCB422 14 /* renamed */
#define NV_CTRL_GVO_DATA_FORMAT_DUAL_X8X8X8_TO_DUAL_422_PASSTHRU 14
#define NV_CTRL_GVO_DATA_FORMAT_R10G10B10_TO_YCRCB422 15
#define NV_CTRL_GVO_DATA_FORMAT_R10G10B10_TO_YCRCB444 16
-#define NV_CTRL_GVO_DATA_FORMAT_Y12CR12CB12_TO_YCRCB444 17 // renamed
+#define NV_CTRL_GVO_DATA_FORMAT_Y12CR12CB12_TO_YCRCB444 17 /* renamed */
#define NV_CTRL_GVO_DATA_FORMAT_X12X12X12_444_PASSTHRU 17
#define NV_CTRL_GVO_DATA_FORMAT_R12G12B12_TO_YCRCB444 18
#define NV_CTRL_GVO_DATA_FORMAT_X8X8X8_422_PASSTHRU 19
@@ -1202,12 +1200,12 @@
#define NV_CTRL_GVO_DATA_FORMAT_R12G12B12_TO_YCRCB422 27
/*
- * NV_CTRL_GVO_DISPLAY_X_SCREEN - no longer supported
+ * NV_CTRL_GVO_DISPLAY_X_SCREEN - not supported
*/
-#define NV_CTRL_GVO_DISPLAY_X_SCREEN 73 /* RW- */
-#define NV_CTRL_GVO_DISPLAY_X_SCREEN_ENABLE 1
-#define NV_CTRL_GVO_DISPLAY_X_SCREEN_DISABLE 0
+#define NV_CTRL_GVO_DISPLAY_X_SCREEN 73 /* not supported */
+#define NV_CTRL_GVO_DISPLAY_X_SCREEN_ENABLE 1 /* not supported */
+#define NV_CTRL_GVO_DISPLAY_X_SCREEN_DISABLE 0 /* not supported */
/*
@@ -1255,12 +1253,12 @@
/*
- * NV_CTRL_GVO_FPGA_VERSION - deprecated
+ * NV_CTRL_GVO_FIRMWARE_VERSION - deprecated
*
* NV_CTRL_STRING_GVIO_FIRMWARE_VERSION should be used instead.
*/
-#define NV_CTRL_GVO_FIRMWARE_VERSION 78 /* R-- */
+#define NV_CTRL_GVO_FIRMWARE_VERSION 78 /* deprecated */
/*
@@ -1307,9 +1305,9 @@
* NV_CTRL_GVO_LOCK_OWNER should be used instead.
*/
-#define NV_CTRL_GVO_GLX_LOCKED 82 /* R-- */
-#define NV_CTRL_GVO_GLX_LOCKED_FALSE 0 /* deprecated */
-#define NV_CTRL_GVO_GLX_LOCKED_TRUE 1 /* deprecated */
+#define NV_CTRL_GVO_GLX_LOCKED 82 /* deprecated */
+#define NV_CTRL_GVO_GLX_LOCKED_FALSE 0 /* deprecated */
+#define NV_CTRL_GVO_GLX_LOCKED_TRUE 1 /* deprecated */
/*
@@ -1332,69 +1330,43 @@
#define NV_CTRL_GVIO_VIDEO_FORMAT_HEIGHT 84 /* R--I */
#define NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE 85 /* R--I */
-/* The following are deprecated; use the NV_CTRL_GVIO_* versions, instead */
-#define NV_CTRL_GVO_VIDEO_FORMAT_WIDTH 83 /* R-- */
-#define NV_CTRL_GVO_VIDEO_FORMAT_HEIGHT 84 /* R-- */
-#define NV_CTRL_GVO_VIDEO_FORMAT_REFRESH_RATE 85 /* R-- */
+/* The following have been renamed; use the NV_CTRL_GVIO_* versions, instead */
+#define NV_CTRL_GVO_VIDEO_FORMAT_WIDTH 83 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_HEIGHT 84 /* renamed */
+#define NV_CTRL_GVO_VIDEO_FORMAT_REFRESH_RATE 85 /* renamed */
/*
- * NV_CTRL_GVO_X_SCREEN_PAN_[XY] - no longer supported
+ * NV_CTRL_GVO_X_SCREEN_PAN_[XY] - not supported
*/
-#define NV_CTRL_GVO_X_SCREEN_PAN_X 86 /* RW- */
-#define NV_CTRL_GVO_X_SCREEN_PAN_Y 87 /* RW- */
+#define NV_CTRL_GVO_X_SCREEN_PAN_X 86 /* not supported */
+#define NV_CTRL_GVO_X_SCREEN_PAN_Y 87 /* not supported */
/*
- * NV_CTRL_GPU_OVERCLOCKING_STATE - query the current or set a new
- * overclocking state; the value of this attribute controls the
- * availability of additional overclocking attributes (see below).
- *
- * Note: this attribute is unavailable unless overclocking support
- * has been enabled in the X server (by the user).
+ * NV_CTRL_GPU_OVERCLOCKING_STATE - not supported
*/
-#define NV_CTRL_GPU_OVERCLOCKING_STATE 88 /* RW-G */
-#define NV_CTRL_GPU_OVERCLOCKING_STATE_NONE 0
-#define NV_CTRL_GPU_OVERCLOCKING_STATE_MANUAL 1
+#define NV_CTRL_GPU_OVERCLOCKING_STATE 88 /* not supported */
+#define NV_CTRL_GPU_OVERCLOCKING_STATE_NONE 0 /* not supported */
+#define NV_CTRL_GPU_OVERCLOCKING_STATE_MANUAL 1 /* not supported */
/*
- * NV_CTRL_GPU_{2,3}D_CLOCK_FREQS - query or set the GPU and memory
- * clocks of the device driving the X screen. New clock frequencies
- * are tested before being applied, and may be rejected.
- *
- * Note: if the target clocks are too aggressive, their testing may
- * render the system unresponsive.
- *
- * Note: while this attribute can always be queried, it can't be set
- * unless NV_CTRL_GPU_OVERCLOCKING_STATE is set to _MANUAL. Since
- * the target clocks may be rejected, the requester should read this
- * attribute after the set to determine success or failure.
- *
- * NV_CTRL_GPU_{2,3}D_CLOCK_FREQS are "packed" integer attributes; the
- * GPU clock is stored in the upper 16 bits of the integer, and the
- * memory clock is stored in the lower 16 bits of the integer. All
- * clock values are in MHz.
+ * NV_CTRL_GPU_{2,3}D_CLOCK_FREQS - not supported
*/
-#define NV_CTRL_GPU_2D_CLOCK_FREQS 89 /* RW-G */
-#define NV_CTRL_GPU_3D_CLOCK_FREQS 90 /* RW-G */
+#define NV_CTRL_GPU_2D_CLOCK_FREQS 89 /* not supported */
+#define NV_CTRL_GPU_3D_CLOCK_FREQS 90 /* not supported */
/*
- * NV_CTRL_GPU_DEFAULT_{2,3}D_CLOCK_FREQS - query the default memory
- * and GPU core clocks of the device driving the X screen.
- *
- * NV_CTRL_GPU_DEFAULT_{2,3}D_CLOCK_FREQS are "packed" integer
- * attributes; the GPU clock is stored in the upper 16 bits of the
- * integer, and the memory clock is stored in the lower 16 bits of the
- * integer. All clock values are in MHz.
+ * NV_CTRL_GPU_DEFAULT_{2,3}D_CLOCK_FREQS - not supported
*/
-#define NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS 91 /* R--G */
-#define NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS 92 /* R--G */
+#define NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS 91 /* not supported */
+#define NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS 92 /* not supported */
/*
@@ -1411,52 +1383,29 @@
/*
- * NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS - Holds the last calculated
- * optimal 3D clock frequencies found by the
- * NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION process. Querying this
- * attribute before having probed for the optimal clocks will return
- * NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_INVALID
- *
- * Note: unless NV_CTRL_GPU_OVERCLOCKING_STATE is set to _MANUAL, the
- * optimal clock detection process is unavailable.
+ * NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS - not supported
*/
-#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS 94 /* R--G */
-#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_INVALID 0
+#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS 94 /* not supported */
+#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_INVALID 0 /* not supported */
/*
- * NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION - set to _START to
- * initiate testing for the optimal 3D clock frequencies. Once
- * found, the optimal clock frequencies will be returned by the
- * NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS attribute asynchronously
- * (using an X event, see XNVCtrlSelectNotify).
- *
- * To cancel an ongoing test for the optimal clocks, set the
- * NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION attribute to _CANCEL
- *
- * Note: unless NV_CTRL_GPU_OVERCLOCKING_STATE is set to _MANUAL, the
- * optimal clock detection process is unavailable.
+ * NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION - not supported
*/
-#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION 95 /* -W-G */
-#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_START 0
-#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_CANCEL 1
+#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION 95 /* not supported */
+#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_START 0 /* not supported */
+#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_CANCEL 1 /* not supported */
/*
- * NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE - query this
- * variable to know if a test is currently being run to
- * determine the optimal 3D clock frequencies. _BUSY means a
- * test is currently running, _IDLE means the test is not running.
- *
- * Note: unless NV_CTRL_GPU_OVERCLOCKING_STATE is set to _MANUAL, the
- * optimal clock detection process is unavailable.
+ * NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE - not supported
*/
-#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE 96 /* R--G */
-#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_IDLE 0
-#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_BUSY 1
+#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE 96 /* not supported */
+#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_IDLE 0 /* not supported */
+#define NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_BUSY 1 /* not supported */
/*
@@ -1608,7 +1557,7 @@
* NV_CTRL_XV_SYNC_TO_DISPLAY_ID should be used instead.
*/
-#define NV_CTRL_XV_SYNC_TO_DISPLAY 226 /* RW- */
+#define NV_CTRL_XV_SYNC_TO_DISPLAY 226 /* deprecated */
/*
* NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 - this attribute is only
@@ -1620,11 +1569,11 @@
#define NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 227 /* ---GI */
/*
- * NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2 - deprecated
+ * NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2 - renamed
*
* NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 should be used instead.
*/
-#define NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2 227 /* --- */
+#define NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2 227 /* renamed */
/*
@@ -1694,7 +1643,7 @@
* NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN should be used instead.
*/
-#define NV_CTRL_ASSOCIATED_DISPLAY_DEVICES 231 /* RW- */
+#define NV_CTRL_ASSOCIATED_DISPLAY_DEVICES 231 /* deprecated */
/*
* NV_CTRL_FRAMELOCK_SLAVES - deprecated
@@ -1702,7 +1651,7 @@
* NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead.
*/
-#define NV_CTRL_FRAMELOCK_SLAVES 232 /* RW-G */
+#define NV_CTRL_FRAMELOCK_SLAVES 232 /* deprecated */
/*
* NV_CTRL_FRAMELOCK_MASTERABLE - deprecated
@@ -1710,7 +1659,7 @@
* NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead.
*/
-#define NV_CTRL_FRAMELOCK_MASTERABLE 233 /* R-DG */
+#define NV_CTRL_FRAMELOCK_MASTERABLE 233 /* deprecated */
/*
* NV_CTRL_PROBE_DISPLAYS - re-probes the hardware to detect what
@@ -1858,58 +1807,58 @@
* NV_CTRL_GPU_SCALING - not supported
*/
-#define NV_CTRL_GPU_SCALING 248 /* RWDG */
+#define NV_CTRL_GPU_SCALING 248 /* not supported */
-#define NV_CTRL_GPU_SCALING_TARGET_INVALID 0
-#define NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_BEST_FIT 1
-#define NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_NATIVE 2
+#define NV_CTRL_GPU_SCALING_TARGET_INVALID 0 /* not supported */
+#define NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_BEST_FIT 1 /* not supported */
+#define NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_NATIVE 2 /* not supported */
-#define NV_CTRL_GPU_SCALING_METHOD_INVALID 0
-#define NV_CTRL_GPU_SCALING_METHOD_STRETCHED 1
-#define NV_CTRL_GPU_SCALING_METHOD_CENTERED 2
-#define NV_CTRL_GPU_SCALING_METHOD_ASPECT_SCALED 3
+#define NV_CTRL_GPU_SCALING_METHOD_INVALID 0 /* not supported */
+#define NV_CTRL_GPU_SCALING_METHOD_STRETCHED 1 /* not supported */
+#define NV_CTRL_GPU_SCALING_METHOD_CENTERED 2 /* not supported */
+#define NV_CTRL_GPU_SCALING_METHOD_ASPECT_SCALED 3 /* not supported */
/*
* NV_CTRL_FRONTEND_RESOLUTION - not supported
*/
-#define NV_CTRL_FRONTEND_RESOLUTION 249 /* R-DG */
+#define NV_CTRL_FRONTEND_RESOLUTION 249 /* not supported */
/*
* NV_CTRL_BACKEND_RESOLUTION - not supported
*/
-#define NV_CTRL_BACKEND_RESOLUTION 250 /* R-DG */
+#define NV_CTRL_BACKEND_RESOLUTION 250 /* not supported */
/*
* NV_CTRL_FLATPANEL_NATIVE_RESOLUTION - not supported
*/
-#define NV_CTRL_FLATPANEL_NATIVE_RESOLUTION 251 /* R-DG */
+#define NV_CTRL_FLATPANEL_NATIVE_RESOLUTION 251 /* not supported */
/*
* NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION - not supported
*/
-#define NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION 252 /* R-DG */
+#define NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION 252 /* not supported */
/*
* NV_CTRL_GPU_SCALING_ACTIVE - not supported
*/
-#define NV_CTRL_GPU_SCALING_ACTIVE 253 /* R-DG */
+#define NV_CTRL_GPU_SCALING_ACTIVE 253 /* not supported */
/*
* NV_CTRL_DFP_SCALING_ACTIVE - not supported
*/
-#define NV_CTRL_DFP_SCALING_ACTIVE 254 /* R-DG */
+#define NV_CTRL_DFP_SCALING_ACTIVE 254 /* not supported */
/*
@@ -1967,7 +1916,7 @@
#define NV_CTRL_GVO_LOCK_OWNER 257 /* R-- */
#define NV_CTRL_GVO_LOCK_OWNER_NONE 0
#define NV_CTRL_GVO_LOCK_OWNER_GLX 1
-#define NV_CTRL_GVO_LOCK_OWNER_CLONE /* no longer supported */ 2
+#define NV_CTRL_GVO_LOCK_OWNER_CLONE 2 /* not supported */
#define NV_CTRL_GVO_LOCK_OWNER_X_SCREEN 3
@@ -2005,9 +1954,9 @@
* NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS - not supported
*/
-#define NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS 261 /* RW-G */
-#define NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS_OFF 0
-#define NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS_ON 1
+#define NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS 261 /* not supported */
+#define NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS_OFF 0 /* not supported */
+#define NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS_ON 1 /* not supported */
/*
@@ -2021,12 +1970,12 @@
/*
- * NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE - deprecated
+ * NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE - not supported
*/
-#define NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE 263 /* R--G */
-#define NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE_DESKTOP 0 /* deprecated */
-#define NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE_MAXPERF 1 /* deprecated */
+#define NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE 263 /* not supported */
+#define NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE_DESKTOP 0 /* not supported */
+#define NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE_MAXPERF 1 /* not supported */
/* NV_CTRL_GLYPH_CACHE - Enables RENDER Glyph Caching to VRAM */
@@ -2175,7 +2124,7 @@
* NV_CTRL_SWITCH_TO_DISPLAYS - deprecated
*/
-#define NV_CTRL_SWITCH_TO_DISPLAYS 276 /* -W- */
+#define NV_CTRL_SWITCH_TO_DISPLAYS 276 /* deprecated */
/*
@@ -2193,7 +2142,7 @@
* NV_CTRL_NOTEBOOK_INTERNAL_LCD - deprecated
*/
-#define NV_CTRL_NOTEBOOK_INTERNAL_LCD 278 /* R-- */
+#define NV_CTRL_NOTEBOOK_INTERNAL_LCD 278 /* deprecated */
/*
* NV_CTRL_DEPTH_30_ALLOWED - returns whether the NVIDIA X driver supports
@@ -2278,7 +2227,7 @@
* NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead.
*/
-#define NV_CTRL_FRAMELOCK_SLAVEABLE 295 /* R-DG */
+#define NV_CTRL_FRAMELOCK_SLAVEABLE 295 /* deprecated */
/*
* NV_CTRL_GVO_SYNC_TO_DISPLAY This attribute controls whether or not
@@ -2716,7 +2665,7 @@
/*
* NV_CTRL_OVERSCAN_COMPENSATION - not supported
*/
-#define NV_CTRL_OVERSCAN_COMPENSATION 339 /* RWDG */
+#define NV_CTRL_OVERSCAN_COMPENSATION 339 /* not supported */
/*
* NV_CTRL_GPU_PCIE_GENERATION - Reports the current PCIe generation.
@@ -2795,11 +2744,15 @@
/*
* NV_CTRL_GPU_SCALING_DEFAULT_TARGET - not supported
- *
+ */
+
+#define NV_CTRL_GPU_SCALING_DEFAULT_TARGET 350 /* not supported */
+
+/*
* NV_CTRL_GPU_SCALING_DEFAULT_METHOD - not supported
*/
-#define NV_CTRL_GPU_SCALING_DEFAULT_TARGET 350 /* R-DG */
-#define NV_CTRL_GPU_SCALING_DEFAULT_METHOD 351 /* R-DG */
+
+#define NV_CTRL_GPU_SCALING_DEFAULT_METHOD 351 /* not supported */
/*
* NV_CTRL_DITHERING_MODE - Controls the dithering mode, when
@@ -3369,7 +3322,33 @@
*/
#define NV_CTRL_VIDEO_DECODER_UTILIZATION 411 /* R--G */
-#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_VIDEO_DECODER_UTILIZATION
+/*
+ * NV_CTRL_GPU_OVER_VOLTAGE_OFFSET - This attribute controls
+ * the overvoltage offset in microvolts (uV).
+ *
+ * Note: To enable overvoltage support, set the X configuration
+ * option "Coolbits" to value "16".
+ *
+ * This offset can have any integer value between
+ * NVCTRLAttributeValidValues.u.range.min and
+ * NVCTRLAttributeValidValues.u.range.max (inclusive).
+ *
+ * This attribute is available on GeForce GTX 400 series and later
+ * Geforce GPUs.
+ */
+
+#define NV_CTRL_GPU_OVER_VOLTAGE_OFFSET 412 /* RW-G */
+
+/*
+ * NV_CTRL_GPU_CURRENT_CORE_VOLTAGE - This attribute returns the
+ * GPU's current operating voltage in microvolts (uV).
+ *
+ * This attribute is available on GPUs that support
+ * NV_CTRL_GPU_OVER_VOLTAGE_OFFSET.
+ */
+#define NV_CTRL_GPU_CURRENT_CORE_VOLTAGE 413 /* R--G */
+
+#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_GPU_CURRENT_CORE_VOLTAGE
/**************************************************************************/
@@ -3431,8 +3410,7 @@
/*
- * NV_CTRL_STRING_TV_ENCODER_NAME - name of the TV encoder used by the
- * specified display device; only valid if the display device is a TV.
+ * NV_CTRL_STRING_TV_ENCODER_NAME - not supported
*/
#define NV_CTRL_STRING_TV_ENCODER_NAME 5 /* R-DG */
@@ -3446,11 +3424,11 @@
#define NV_CTRL_STRING_GVIO_FIRMWARE_VERSION 8 /* R--I */
/*
- * NV_CTRL_STRING_GVO_FIRMWARE_VERSION - deprecated
+ * NV_CTRL_STRING_GVO_FIRMWARE_VERSION - renamed
*
* NV_CTRL_STRING_GVIO_FIRMWARE_VERSION should be used instead.
*/
-#define NV_CTRL_STRING_GVO_FIRMWARE_VERSION 8 /* R-- */
+#define NV_CTRL_STRING_GVO_FIRMWARE_VERSION 8 /* renamed */
/*
@@ -3722,9 +3700,16 @@
* or the X server ABI is greater than equal to 12.
*/
-#define NV_CTRL_STRING_XINERAMA_SCREEN_INFO 26 /* renamed */
#define NV_CTRL_STRING_SCREEN_RECTANGLE 26 /* R--- */
+/*
+ * NV_CTRL_STRING_XINERAMA_SCREEN_INFO - renamed
+ *
+ * NV_CTRL_STRING_SCREEN_RECTANGLE should be used instead.
+ */
+
+#define NV_CTRL_STRING_XINERAMA_SCREEN_INFO 26 /* renamed */
+
/*
* NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER - used to specify the
@@ -3910,11 +3895,11 @@
#define NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME 33 /* R--GI */
/*
- * NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME - deprecated
+ * NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME - renamed
*
* NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME should be used instead.
*/
-#define NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME 33 /* R--- */
+#define NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME 33 /* renamed */
/*
@@ -4680,7 +4665,6 @@
* "HorizSync"
* "VertRefresh"
* "FlatPanelProperties"
- * "TVStandard"
* "ExactModeTimingsDVI"
* "UseEdidFreqs"
*
diff --git a/src/libXNVCtrl/utils.mk b/src/libXNVCtrl/utils.mk
index cc989d0..88598d2 100644
--- a/src/libXNVCtrl/utils.mk
+++ b/src/libXNVCtrl/utils.mk
@@ -55,6 +55,7 @@ endif
INSTALL ?= install
INSTALL_BIN_ARGS ?= -m 755
+INSTALL_LIB_ARGS ?= -m 644
INSTALL_DOC_ARGS ?= -m 644
M4 ?= m4
@@ -98,6 +99,26 @@ ifndef TARGET_ARCH
TARGET_ARCH := $(subst i686,x86,$(TARGET_ARCH))
endif
+ifeq ($(TARGET_ARCH),x86)
+ CFLAGS += -DNV_X86 -DNV_ARCH_BITS=32
+endif
+
+ifeq ($(TARGET_ARCH),x86_64)
+ CFLAGS += -DNV_X86_64 -DNV_ARCH_BITS=64
+endif
+
+ifeq ($(TARGET_ARCH),armv7l)
+ CFLAGS += -DNV_ARMV7 -DNV_ARCH_BITS=32
+endif
+
+ifeq ($(TARGET_ARCH),aarch64)
+ CFLAGS += -DNV_AARCH64 -DNV_ARCH_BITS=64
+endif
+
+ifeq ($(TARGET_ARCH),ppc64le)
+ CFLAGS += -DNV_PPC64LE -DNV_ARCH_BITS=64
+endif
+
ifeq ($(TARGET_OS),Linux)
LIBDL_LIBS = -ldl
else
@@ -113,6 +134,14 @@ ifeq ($(TARGET_ARCH),armv7l)
endif
TARGET_ARCH_ABI ?=
+ifeq ($(TARGET_ARCH_ABI),gnueabi)
+ CFLAGS += -DNV_GNUEABI
+endif
+
+ifeq ($(TARGET_ARCH_ABI),gnueabihf)
+ CFLAGS += -DNV_GNUEABIHF
+endif
+
OUTPUTDIR ?= _out/$(TARGET_OS)_$(TARGET_ARCH)
OUTPUTDIR_ABSOLUTE ?= $(CURDIR)/$(OUTPUTDIR)
@@ -143,6 +172,7 @@ endif
PREFIX ?= /usr/local
BINDIR = $(DESTDIR)$(PREFIX)/bin
+LIBDIR = $(DESTDIR)$(PREFIX)/lib
MANDIR = $(DESTDIR)$(PREFIX)/share/man/man1
@@ -230,7 +260,7 @@ NV_MODULE_LOGGING_NAME ?=
ifeq ($(NV_VERBOSE),0)
quiet_cmd = @$(PRINTF) \
- " $(if $(NV_MODULE_LOGGING_NAME),[ %-17.17s ],%s) $(quiet_$(1))\n" \
+ " $(if $(NV_MODULE_LOGGING_NAME),[ %-17.17s ],%s) $(quiet_$(1))\n" \
"$(NV_MODULE_LOGGING_NAME)" && $($(1))
else
quiet_cmd = $($(1))
@@ -262,32 +292,49 @@ quiet_STRIP_CMD = $(call define_quiet_cmd,STRIP ,$@)
##############################################################################
# function to generate a list of object files from their corresponding
-# source files; example usage:
+# source files using the specified path. The _WITH_DIR variant takes an
+# output path as the second argument while the BUILD_OBJECT_LIST defaults
+# to using the value of OUTPUTDIR as the output path. example usage:
#
-# OBJS = $(call BUILD_OBJECT_LIST,$(SRC))
+# OBJS = $(call BUILD_OBJECT_LIST_WITH_DIR,$(SRC),$(DIR))
##############################################################################
+BUILD_OBJECT_LIST_WITH_DIR = \
+ $(addprefix $(2)/,$(notdir $(addsuffix .o,$(basename $(1)))))
+
BUILD_OBJECT_LIST = \
- $(addprefix $(OUTPUTDIR)/,$(notdir $(addsuffix .o,$(basename $(1)))))
+ $(call BUILD_OBJECT_LIST_WITH_DIR,$(1),$(OUTPUTDIR))
##############################################################################
# function to generate a list of dependency files from their
-# corresponding source files; example usage:
+# corresponding source files using the specified path. The _WITH_DIR
+# variant takes an output path as the second argument while the
+# BUILD_DEPENDENCY_LIST default to using the value of OUTPUTDIR as the
+# output path. example usage:
#
-# DEPS = $(call BUILD_DEPENDENCY_LIST,$(SRC))
+# DEPS = $(call BUILD_DEPENDENCY_LIST_WITH_DIR,$(SRC),$(DIR))
##############################################################################
+BUILD_DEPENDENCY_LIST_WITH_DIR = \
+ $(addprefix $(2)/,$(notdir $(addsuffix .d,$(basename $(1)))))
+
BUILD_DEPENDENCY_LIST = \
- $(addprefix $(OUTPUTDIR)/,$(notdir $(addsuffix .d,$(basename $(1)))))
+ $(call BUILD_DEPENDENCY_LIST_WITH_DIR,$(1),$(OUTPUTDIR))
##############################################################################
# functions to define a rule to build an object file; the first
-# argument whether the rule is for the target or host platform ("HOST"
-# or "TARGET"), the second argument is the source file to compile, and
-# the third argument (_WITH_OBJECT_NAME-only) is the object filename
-# to produce. Example usage:
+# argument for all functions is whether the rule is for the target or
+# host platform ("HOST" or "TARGET"), the second argument for all
+# functions is the source file to compile.
+#
+# The _WITH_OBJECT_NAME and _WITH_DIR function name suffixes describe
+# the third and possibly fourth arguments based on order. The
+# _WITH_OBJECT_NAME argument is the object filename to produce while
+# the _WITH_DIR argument is the destination path for the object file.
+#
+# Example usage:
#
# $(eval $(call DEFINE_OBJECT_RULE,TARGET,foo.c))
#
@@ -299,26 +346,35 @@ BUILD_DEPENDENCY_LIST = \
# from the source file name (this is normally what you want).
##############################################################################
-define DEFINE_OBJECT_RULE_WITH_OBJECT_NAME
+define DEFINE_OBJECT_RULE_WITH_OBJECT_NAME_WITH_DIR
$(3): $(2)
- @$(MKDIR) $(OUTPUTDIR)
+ @$(MKDIR) $(4)
$$(call quiet_cmd,$(call host_target_cc,$(1))) \
$$($(call host_target_cflags,$(1))) -c $$< -o $$@ \
$(call AUTO_DEP_CMD,$(1),$(2),$(3))
- -include $$(call BUILD_DEPENDENCY_LIST,$(3))
+ -include $$(call BUILD_DEPENDENCY_LIST_WITH_DIR,$(3),$(4))
# declare empty rule for generating dependency file; we generate the
# dependency files implicitly when compiling the source file (see
# AUTO_DEP_CMD above), so we don't want gmake to spend time searching
# for an explicit rule to generate the dependency file
- $$(call BUILD_DEPENDENCY_LIST,$(3)): ;
+ $$(call BUILD_DEPENDENCY_LIST_WITH_DIR,$(3),$(4)): ;
+
+endef
+
+define DEFINE_OBJECT_RULE_WITH_OBJECT_NAME
+ $$(eval $$(call DEFINE_OBJECT_RULE_WITH_OBJECT_NAME_WITH_DIR,$(1),$(2),\
+ $(3),$(OUTPUTDIR)))
+endef
+define DEFINE_OBJECT_RULE_WITH_DIR
+ $$(eval $$(call DEFINE_OBJECT_RULE_WITH_OBJECT_NAME_WITH_DIR,$(1),$(2),\
+ $$(call BUILD_OBJECT_LIST_WITH_DIR,$(2),$(3)),$(3)))
endef
define DEFINE_OBJECT_RULE
- $$(eval $$(call DEFINE_OBJECT_RULE_WITH_OBJECT_NAME,$(1),$(2),\
- $$(call BUILD_OBJECT_LIST,$(2))))
+ $$(eval $$(call DEFINE_OBJECT_RULE_WITH_DIR,$(1),$(2),$(OUTPUTDIR)))
endef
diff --git a/src/libXNVCtrl/version.mk b/src/libXNVCtrl/version.mk
index 66ba96f..14c4194 100644
--- a/src/libXNVCtrl/version.mk
+++ b/src/libXNVCtrl/version.mk
@@ -1 +1 @@
-NVIDIA_VERSION = 343.22
+NVIDIA_VERSION = 346.16
diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributes.c b/src/libXNVCtrlAttributes/NvCtrlAttributes.c
index b893a05..748ddc4 100644
--- a/src/libXNVCtrlAttributes/NvCtrlAttributes.c
+++ b/src/libXNVCtrlAttributes/NvCtrlAttributes.c
@@ -36,11 +36,150 @@
+
+/*
+ * This table stores the associated values for each target type. The
+ * CtrlSystem->targets[] array shadows this table where the XXX_TARGET #defines
+ * can be used to index into both arrays.
+ */
+
+const CtrlTargetTypeInfo targetTypeInfoTable[] = {
+
+ [X_SCREEN_TARGET] =
+ { "X Screen", /* name */
+ "screen", /* parsed_name */
+ NV_CTRL_TARGET_TYPE_X_SCREEN, /* nvctrl */
+ ATTRIBUTE_TYPE_X_SCREEN, /* permission_bit */
+ NV_TRUE, /* uses_display_devices */
+ 1, 6 }, /* required major,minor protocol rev */
+
+ [GPU_TARGET] =
+ { "GPU", /* name */
+ "gpu", /* parsed_name */
+ NV_CTRL_TARGET_TYPE_GPU, /* nvctrl */
+ ATTRIBUTE_TYPE_GPU, /* permission_bit */
+ NV_TRUE, /* uses_display_devices */
+ 1, 10 }, /* required major,minor protocol rev */
+
+ [FRAMELOCK_TARGET] =
+ { "Frame Lock Device", /* name */
+ "framelock", /* parsed_name */
+ NV_CTRL_TARGET_TYPE_FRAMELOCK, /* nvctrl */
+ ATTRIBUTE_TYPE_FRAMELOCK, /* permission_bit */
+ NV_FALSE, /* uses_display_devices */
+ 1, 10 }, /* required major,minor protocol rev */
+
+ [VCS_TARGET] =
+ { "VCS", /* name */
+ "vcs", /* parsed_name */
+ NV_CTRL_TARGET_TYPE_VCSC, /* nvctrl */
+ ATTRIBUTE_TYPE_VCSC, /* permission_bit */
+ NV_FALSE, /* uses_display_devices */
+ 1, 12 }, /* required major,minor protocol rev */
+
+ [GVI_TARGET] =
+ { "SDI Input Device", /* name */
+ "gvi", /* parsed_name */
+ NV_CTRL_TARGET_TYPE_GVI, /* nvctrl */
+ ATTRIBUTE_TYPE_GVI, /* permission_bit */
+ NV_FALSE, /* uses_display_devices */
+ 1, 18 }, /* required major,minor protocol rev */
+
+ [COOLER_TARGET] =
+ { "Fan", /* name */
+ "fan", /* parsed_name */
+ NV_CTRL_TARGET_TYPE_COOLER, /* nvctrl */
+ ATTRIBUTE_TYPE_COOLER, /* permission_bit */
+ NV_FALSE, /* uses_display_devices */
+ 1, 20 }, /* required major,minor protocol rev */
+
+ [THERMAL_SENSOR_TARGET] =
+ { "Thermal Sensor", /* name */
+ "thermalsensor", /* parsed_name */
+ NV_CTRL_TARGET_TYPE_THERMAL_SENSOR, /* nvctrl */
+ ATTRIBUTE_TYPE_THERMAL_SENSOR, /* permission_bit */
+ NV_FALSE, /* uses_display_devices */
+ 1, 23 }, /* required major,minor protocol rev */
+
+ [NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET] =
+ { "3D Vision Pro Transceiver", /* name */
+ "svp", /* parsed_name */
+ NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER, /* nvctrl */
+ ATTRIBUTE_TYPE_3D_VISION_PRO_TRANSCEIVER, /* permission_bit */
+ NV_FALSE, /* uses_display_devices */
+ 1, 25 }, /* required major,minor protocol rev */
+
+ [DISPLAY_TARGET] =
+ { "Display Device", /* name */
+ "dpy", /* parsed_name */
+ NV_CTRL_TARGET_TYPE_DISPLAY, /* nvctrl */
+ ATTRIBUTE_TYPE_DISPLAY, /* permission_bit */
+ NV_FALSE, /* uses_display_devices */
+ 1, 27 }, /* required major,minor protocol rev */
+};
+
+const int targetTypeInfoTableLen = ARRAY_LEN(targetTypeInfoTable);
+
+
/*
- * NvCtrlAttributeInit() - XXX not sure how to handle errors
+ * List of unique event handles to track
*/
+static NvCtrlEventPrivateHandleNode *__event_handles = NULL;
+
+
+Bool NvCtrlIsTargetTypeValid(CtrlTargetType target_type)
+{
+ switch (target_type) {
+ case X_SCREEN_TARGET:
+ case GPU_TARGET:
+ case FRAMELOCK_TARGET:
+ case VCS_TARGET:
+ case GVI_TARGET:
+ case COOLER_TARGET:
+ case THERMAL_SENSOR_TARGET:
+ case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET:
+ case DISPLAY_TARGET:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+
+const CtrlTargetTypeInfo *NvCtrlGetTargetTypeInfo(CtrlTargetType target_type)
+{
+ if (!NvCtrlIsTargetTypeValid(target_type)) {
+ return NULL;
+ }
+
+ return &(targetTypeInfoTable[target_type]);
+}
+
+
+const CtrlTargetTypeInfo *NvCtrlGetTargetTypeInfoByName(const char *name)
+{
+ int i;
-NvCtrlAttributeHandle *NvCtrlAttributeInit(Display *dpy, int target_type,
+ for (i = 0; i < targetTypeInfoTableLen; i++) {
+ if (nv_strcasecmp(targetTypeInfoTable[i].parsed_name, name)) {
+ return &targetTypeInfoTable[i];
+ }
+ }
+
+ return NULL;
+}
+
+
+
+/*
+ * Initializes the control panel backend; this includes probing for the
+ * various extensions, downloading the initial state of attributes, etc.
+ * Takes a System pointer and target info, and returns an opaque handle
+ * on success; returns NULL if the backend cannot use this handle.
+ */
+
+NvCtrlAttributeHandle *NvCtrlAttributeInit(CtrlSystem *system,
+ CtrlTargetType target_type,
int target_id,
unsigned int subsystems)
{
@@ -50,15 +189,19 @@ NvCtrlAttributeHandle *NvCtrlAttributeInit(Display *dpy, int target_type,
/* initialize the display and screen to the parameter values */
- h->dpy = dpy;
+ h->dpy = system->dpy;
h->target_type = target_type;
h->target_id = target_id;
- /* initialize the NV-CONTROL attributes; give up if this fails */
+ /* initialize the NV-CONTROL attributes */
if (subsystems & NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM) {
h->nv = NvCtrlInitNvControlAttributes(h);
- if (!h->nv) goto failed;
+
+ /* Give up if it failed and target needs NV-CONTROL */
+ if (!h->nv && TARGET_TYPE_NEEDS_NVCONTROL(target_type)) {
+ goto failed;
+ }
}
/*
@@ -66,7 +209,7 @@ NvCtrlAttributeHandle *NvCtrlAttributeInit(Display *dpy, int target_type,
* target types.
*/
- if (target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (target_type == X_SCREEN_TARGET) {
/*
* initialize the XF86VidMode attributes; it is OK if this
@@ -113,25 +256,22 @@ NvCtrlAttributeHandle *NvCtrlAttributeInit(Display *dpy, int target_type,
} /* NvCtrlAttributeInit() */
/*
- * NvCtrlAttributeRebuildSubsystems() - Rebuild specified private subsystem handles
+ * Rebuild specified private subsystem handles
*/
-void NvCtrlAttributeRebuildSubsystems(NvCtrlAttributeHandle *handle,
- unsigned int subsystem)
+void NvCtrlRebuildSubsystems(CtrlTarget *ctrl_target, unsigned int subsystem)
{
- NvCtrlAttributePrivateHandle *h;
+ NvCtrlAttributePrivateHandle *h = getPrivateHandle(ctrl_target);
- if (!handle) {
+ if (h == NULL) {
return;
}
- h = (NvCtrlAttributePrivateHandle*)handle;
-
if (subsystem & NV_CTRL_ATTRIBUTES_XRANDR_SUBSYSTEM) {
NvCtrlXrandrAttributesClose(h);
h->xrandr = NvCtrlInitXrandrAttributes(h);
}
-} /* NvCtrlAttributeRebuildSubsystems() */
+}
@@ -140,29 +280,29 @@ void NvCtrlAttributeRebuildSubsystems(NvCtrlAttributeHandle *handle,
*
* [host]:[display].[screen]
*
- * that describes the X screen associated with this
- * NvCtrlAttributeHandle. This is done by getting the string that
- * describes the display connection, and then substituting the correct
- * screen number. If no hostname is present in the display string,
- * uname.nodename is prepended. Returns NULL if any error occurs.
+ * that describes the X screen associated with this CtrlTarget. This
+ * is done by getting the string that describes the display connection,
+ * and then substituting the correct screen number. If no hostname is
+ * present in the display string, uname.nodename is prepended. Returns NULL if
+ * any error occurs.
*/
-char *NvCtrlGetDisplayName(NvCtrlAttributeHandle *handle)
+char *NvCtrlGetDisplayName(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
char *display_name;
-
- if (!handle) return NULL;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
-
+
+ if (h == NULL || h->dpy == NULL) {
+ return NULL;
+ }
+
display_name = DisplayString(h->dpy);
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (h->target_type != X_SCREEN_TARGET) {
/* Return the display name and # without a screen number */
return nv_standardize_screen_name(display_name, -2);
}
-
+
return nv_standardize_screen_name(display_name, h->target_id);
} /* NvCtrlGetDisplayName() */
@@ -173,13 +313,13 @@ char *NvCtrlGetDisplayName(NvCtrlAttributeHandle *handle)
* this NvCtrlAttributeHandle.
*/
-Display *NvCtrlGetDisplayPtr(NvCtrlAttributeHandle *handle)
+Display *NvCtrlGetDisplayPtr(CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
-
- if (!handle) return NULL;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
+ NvCtrlAttributePrivateHandle *h = getPrivateHandle(ctrl_target);
+
+ if (h == NULL) {
+ return NULL;
+ }
return h->dpy;
@@ -188,18 +328,16 @@ Display *NvCtrlGetDisplayPtr(NvCtrlAttributeHandle *handle)
/*
* NvCtrlGetScreen() - returns the screen number associated with this
- * NvCtrlAttributeHandle.
+ * CtrlTarget.
*/
-int NvCtrlGetScreen(NvCtrlAttributeHandle *handle)
+int NvCtrlGetScreen(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
-
- if (!handle) return -1;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) return -1;
+ if (h == NULL || h->target_type != X_SCREEN_TARGET) {
+ return -1;
+ }
return h->target_id;
@@ -208,16 +346,16 @@ int NvCtrlGetScreen(NvCtrlAttributeHandle *handle)
/*
* NvCtrlGetTargetType() - returns the target type associated with this
- * NvCtrlAttributeHandle.
+ * CtrlTarget.
*/
-int NvCtrlGetTargetType(NvCtrlAttributeHandle *handle)
+int NvCtrlGetTargetType(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
-
- if (!handle) return -1;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL) {
+ return -1;
+ }
return h->target_type;
@@ -226,16 +364,16 @@ int NvCtrlGetTargetType(NvCtrlAttributeHandle *handle)
/*
* NvCtrlGetTargetId() - returns the target id number associated with this
- * NvCtrlAttributeHandle.
+ * CtrlTarget.
*/
-int NvCtrlGetTargetId(NvCtrlAttributeHandle *handle)
+int NvCtrlGetTargetId(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- if (!handle) return -1;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL) {
+ return -1;
+ }
return h->target_id;
@@ -244,18 +382,16 @@ int NvCtrlGetTargetId(NvCtrlAttributeHandle *handle)
/*
* NvCtrlGetScreenWidth() - return the width of the screen associated
- * with this NvCtrlAttributeHandle.
+ * with this CtrlTarget.
*/
-int NvCtrlGetScreenWidth(NvCtrlAttributeHandle *handle)
+int NvCtrlGetScreenWidth(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- if (!handle) return -1;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
-
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) return -1;
+ if (h == NULL || h->target_type != X_SCREEN_TARGET) {
+ return -1;
+ }
return DisplayWidth(h->dpy, h->target_id);
@@ -264,67 +400,35 @@ int NvCtrlGetScreenWidth(NvCtrlAttributeHandle *handle)
/*
* NvCtrlGetScreenHeight() - return the height of the screen
- * associated with this NvCtrlAttributeHandle.
+ * associated with this CtrlTarget.
*/
-int NvCtrlGetScreenHeight(NvCtrlAttributeHandle *handle)
+int NvCtrlGetScreenHeight(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
-
- if (!handle) return -1;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) return -1;
+ if (h == NULL || h->target_type != X_SCREEN_TARGET) {
+ return -1;
+ }
return DisplayHeight(h->dpy, h->target_id);
} /* NvCtrlGetScreenHeight() */
-int NvCtrlGetEventBase(NvCtrlAttributeHandle *handle)
-{
- NvCtrlAttributePrivateHandle *h;
-
- if (!handle) return -1;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
-
- if (!h->nv) return -1;
- return (h->nv->event_base);
-
-} /* NvCtrlGetEventBase() */
-
-
-int NvCtrlGetXrandrEventBase(NvCtrlAttributeHandle *handle)
-{
- NvCtrlAttributePrivateHandle *h;
-
- if (!handle) return -1;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
-
- if (!h->xrandr) return -1;
- return (h->xrandr->event_base);
-
-} /* NvCtrlGetXrandrEventBase() */
-
-
/*
* NvCtrlGetServerVendor() - return the server vendor
- * information string associated with this
- * NvCtrlAttributeHandle.
+ * information string associated with this CtrlTarget.
*/
-char *NvCtrlGetServerVendor(NvCtrlAttributeHandle *handle)
+char *NvCtrlGetServerVendor(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- if (!handle) return NULL;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL || h->dpy == NULL) {
+ return NULL;
+ }
- if (!h->dpy) return NULL;
return ServerVendor(h->dpy);
} /* NvCtrlGetServerVendor() */
@@ -332,18 +436,17 @@ char *NvCtrlGetServerVendor(NvCtrlAttributeHandle *handle)
/*
* NvCtrlGetVendorRelease() - return the server vendor
- * release number associated with this NvCtrlAttributeHandle.
+ * release number associated with this CtrlTarget.
*/
-int NvCtrlGetVendorRelease(NvCtrlAttributeHandle *handle)
+int NvCtrlGetVendorRelease(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
-
- if (!handle) return -1;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL || h->dpy == NULL) {
+ return -1;
+ }
- if (!h->dpy) return -1;
return VendorRelease(h->dpy);
} /* NvCtrlGetVendorRelease() */
@@ -351,18 +454,17 @@ int NvCtrlGetVendorRelease(NvCtrlAttributeHandle *handle)
/*
* NvCtrlGetScreenCount() - return the number of (logical)
- * X Screens associated with this NvCtrlAttributeHandle.
+ * X Screens associated with this CtrlTarget.
*/
-int NvCtrlGetScreenCount(NvCtrlAttributeHandle *handle)
+int NvCtrlGetScreenCount(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
-
- if (!handle) return -1;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL || h->dpy == NULL) {
+ return -1;
+ }
- if (!h->dpy) return -1;
return ScreenCount(h->dpy);
} /* NvCtrlGetScreenCount() */
@@ -373,15 +475,14 @@ int NvCtrlGetScreenCount(NvCtrlAttributeHandle *handle)
* number of the X protocol (server).
*/
-int NvCtrlGetProtocolVersion(NvCtrlAttributeHandle *handle)
+int NvCtrlGetProtocolVersion(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
-
- if (!handle) return -1;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL || h->dpy == NULL) {
+ return -1;
+ }
- if (!h->dpy) return -1;
return ProtocolVersion(h->dpy);
} /* NvCtrlGetProtocolVersion() */
@@ -392,15 +493,14 @@ int NvCtrlGetProtocolVersion(NvCtrlAttributeHandle *handle)
* of the X protocol (server).
*/
-int NvCtrlGetProtocolRevision(NvCtrlAttributeHandle *handle)
+int NvCtrlGetProtocolRevision(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- if (!handle) return -1;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL || h->dpy == NULL) {
+ return -1;
+ }
- if (!h->dpy) return -1;
return ProtocolRevision(h->dpy);
} /* NvCtrlGetProtocolRevision() */
@@ -408,18 +508,16 @@ int NvCtrlGetProtocolRevision(NvCtrlAttributeHandle *handle)
/*
* NvCtrlGetScreenWidthMM() - return the width (in Millimeters) of the
- * screen associated with this NvCtrlAttributeHandle.
+ * screen associated with this CtrlTarget.
*/
-int NvCtrlGetScreenWidthMM(NvCtrlAttributeHandle *handle)
+int NvCtrlGetScreenWidthMM(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
-
- if (!handle) return -1;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
-
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) return -1;
+ if (h == NULL || h->target_type != X_SCREEN_TARGET) {
+ return -1;
+ }
return DisplayWidthMM(h->dpy, h->target_id);
@@ -428,18 +526,16 @@ int NvCtrlGetScreenWidthMM(NvCtrlAttributeHandle *handle)
/*
* NvCtrlGetScreenHeightMM() - return the height (in Millimeters) of the
- * screen associated with this NvCtrlAttributeHandle.
+ * screen associated with this CtrlTarget.
*/
-int NvCtrlGetScreenHeightMM(NvCtrlAttributeHandle *handle)
+int NvCtrlGetScreenHeightMM(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
-
- if (!handle) return -1;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
-
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) return -1;
+ if (h == NULL || h->target_type != X_SCREEN_TARGET) {
+ return -1;
+ }
return DisplayHeightMM(h->dpy, h->target_id);
@@ -448,18 +544,16 @@ int NvCtrlGetScreenHeightMM(NvCtrlAttributeHandle *handle)
/*
* NvCtrlGetScreenPlanes() - return the number of planes (the depth)
- * of the screen associated with this NvCtrlAttributeHandle.
+ * of the screen associated with this CtrlTarget.
*/
-int NvCtrlGetScreenPlanes(NvCtrlAttributeHandle *handle)
+int NvCtrlGetScreenPlanes(const CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- if (!handle) return -1;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
-
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) return -1;
+ if (h == NULL || h->target_type != X_SCREEN_TARGET) {
+ return -1;
+ }
return DisplayPlanes(h->dpy, h->target_id);
@@ -467,89 +561,195 @@ int NvCtrlGetScreenPlanes(NvCtrlAttributeHandle *handle)
-ReturnStatus NvCtrlQueryTargetCount(NvCtrlAttributeHandle *handle,
- int target_type,
+ReturnStatus NvCtrlQueryTargetCount(const CtrlTarget *ctrl_target,
+ CtrlTargetType target_type,
int *val)
{
- NvCtrlAttributePrivateHandle *h;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
+
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
- h = (NvCtrlAttributePrivateHandle *) handle;
- if (!h) return NvCtrlBadArgument;
- return NvCtrlNvControlQueryTargetCount(handle, target_type, val);
+ return NvCtrlNvControlQueryTargetCount(h, target_type, val);
} /* NvCtrlQueryTargetCount() */
-ReturnStatus NvCtrlGetAttribute(NvCtrlAttributeHandle *handle,
+ReturnStatus NvCtrlGetAttribute(const CtrlTarget *ctrl_target,
int attr, int *val)
{
- if (!handle) return NvCtrlBadArgument;
- return NvCtrlGetDisplayAttribute(handle, 0, attr, val);
+ return NvCtrlGetDisplayAttribute(ctrl_target, 0, attr, val);
} /* NvCtrlGetAttribute() */
-ReturnStatus NvCtrlSetAttribute(NvCtrlAttributeHandle *handle,
+ReturnStatus NvCtrlSetAttribute(CtrlTarget *ctrl_target,
int attr, int val)
{
- if (!handle) return NvCtrlBadArgument;
- return NvCtrlSetDisplayAttribute(handle, 0, attr, val);
+ return NvCtrlSetDisplayAttribute(ctrl_target, 0, attr, val);
} /* NvCtrlSetAttribute() */
-ReturnStatus NvCtrlGetAttribute64(NvCtrlAttributeHandle *handle,
+ReturnStatus NvCtrlGetAttribute64(const CtrlTarget *ctrl_target,
int attr, int64_t *val)
{
- if (!handle) return NvCtrlBadArgument;
- return NvCtrlGetDisplayAttribute64(handle, 0, attr, val);
+ return NvCtrlGetDisplayAttribute64(ctrl_target, 0, attr, val);
} /* NvCtrlGetAttribute64() */
-ReturnStatus NvCtrlGetVoidAttribute(NvCtrlAttributeHandle *handle,
+ReturnStatus NvCtrlGetVoidAttribute(const CtrlTarget *ctrl_target,
int attr, void **ptr)
{
- if (!handle) return NvCtrlBadArgument;
- return NvCtrlGetVoidDisplayAttribute(handle, 0, attr, ptr);
+ return NvCtrlGetVoidDisplayAttribute(ctrl_target, 0, attr, ptr);
} /* NvCtrlGetVoidAttribute() */
-ReturnStatus NvCtrlGetValidAttributeValues(NvCtrlAttributeHandle *handle,
+ReturnStatus NvCtrlGetValidAttributeValues(const CtrlTarget *ctrl_target,
int attr,
NVCTRLAttributeValidValuesRec *val)
{
- if (!handle) return NvCtrlBadArgument;
- return NvCtrlGetValidDisplayAttributeValues(handle, 0, attr, val);
+ return NvCtrlGetValidDisplayAttributeValues(ctrl_target, 0, attr, val);
} /* NvCtrlGetValidAttributeValues() */
-ReturnStatus NvCtrlGetStringAttribute(NvCtrlAttributeHandle *handle,
+
+/*
+ * Helper function for converting NV-CONTROL specific permission data into
+ * CtrlAttributePerms (API agnostic) permission data that the front-end can use.
+ */
+
+static void convert_from_nvctrl_perms(CtrlAttributePerms *dst,
+ const NVCTRLAttributePermissionsRec *src)
+{
+ memset(dst, 0, sizeof(*dst));
+
+ dst->read = (src->permissions & ATTRIBUTE_TYPE_READ) ? NV_TRUE : NV_FALSE;
+ dst->write = (src->permissions & ATTRIBUTE_TYPE_WRITE) ? NV_TRUE : NV_FALSE;
+
+ if (src->permissions & ATTRIBUTE_TYPE_X_SCREEN) {
+ dst->valid_targets |= CTRL_TARGET_PERM_BIT(X_SCREEN_TARGET);
+ }
+ if (src->permissions & ATTRIBUTE_TYPE_DISPLAY) {
+ dst->valid_targets |= CTRL_TARGET_PERM_BIT(DISPLAY_TARGET);
+ }
+ if (src->permissions & ATTRIBUTE_TYPE_GPU) {
+ dst->valid_targets |= CTRL_TARGET_PERM_BIT(GPU_TARGET);
+ }
+ if (src->permissions & ATTRIBUTE_TYPE_FRAMELOCK) {
+ dst->valid_targets |= CTRL_TARGET_PERM_BIT(FRAMELOCK_TARGET);
+ }
+ if (src->permissions & ATTRIBUTE_TYPE_VCSC) {
+ dst->valid_targets |= CTRL_TARGET_PERM_BIT(VCS_TARGET);
+ }
+ if (src->permissions & ATTRIBUTE_TYPE_GVI) {
+ dst->valid_targets |= CTRL_TARGET_PERM_BIT(GVI_TARGET);
+ }
+ if (src->permissions & ATTRIBUTE_TYPE_COOLER) {
+ dst->valid_targets |= CTRL_TARGET_PERM_BIT(COOLER_TARGET);
+ }
+ if (src->permissions & ATTRIBUTE_TYPE_THERMAL_SENSOR) {
+ dst->valid_targets |= CTRL_TARGET_PERM_BIT(THERMAL_SENSOR_TARGET);
+ }
+ if (src->permissions & ATTRIBUTE_TYPE_3D_VISION_PRO_TRANSCEIVER) {
+ dst->valid_targets |=
+ CTRL_TARGET_PERM_BIT(NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET);
+ }
+}
+
+
+
+ReturnStatus NvCtrlGetAttributePerms(const CtrlTarget *ctrl_target,
+ int attr_type,
+ int attr,
+ CtrlAttributePerms *perms)
+{
+ NVCTRLAttributePermissionsRec nvctrlPerms;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
+
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
+
+ memset(&nvctrlPerms, 0, sizeof(nvctrlPerms));
+ memset(perms, 0, sizeof(*perms));
+
+ switch (attr_type) {
+ case CTRL_ATTRIBUTE_TYPE_INTEGER:
+ XNVCTRLQueryAttributePermissions(h->dpy, attr, &nvctrlPerms);
+
+ convert_from_nvctrl_perms(perms, &nvctrlPerms);
+ break;
+
+ case CTRL_ATTRIBUTE_TYPE_STRING:
+ XNVCTRLQueryStringAttributePermissions(h->dpy, attr, &nvctrlPerms);
+ convert_from_nvctrl_perms(perms, &nvctrlPerms);
+ break;
+
+ case CTRL_ATTRIBUTE_TYPE_BINARY_DATA:
+ XNVCTRLQueryBinaryDataAttributePermissions(h->dpy, attr, &nvctrlPerms);
+ convert_from_nvctrl_perms(perms, &nvctrlPerms);
+ break;
+
+ case CTRL_ATTRIBUTE_TYPE_STRING_OPERATION:
+ XNVCTRLQueryStringOperationAttributePermissions(h->dpy, attr,
+ &nvctrlPerms);
+ convert_from_nvctrl_perms(perms, &nvctrlPerms);
+ break;
+
+ case CTRL_ATTRIBUTE_TYPE_COLOR:
+ /* Allow non NV-CONTROL attributes to be read/written on X screen
+ * targets
+ */
+ perms->read = NV_TRUE;
+ perms->write = NV_TRUE;
+ perms->valid_targets |= CTRL_TARGET_PERM_BIT(X_SCREEN_TARGET);
+ break;
+
+ case CTRL_ATTRIBUTE_TYPE_SDI_CSC:
+ /* Allow SDI CSC matrix to be read/written on X screen targets */
+ perms->read = NV_TRUE;
+ perms->write = NV_TRUE;
+ perms->valid_targets |= CTRL_TARGET_PERM_BIT(X_SCREEN_TARGET);
+ break;
+
+ default:
+ return NvCtrlBadArgument;
+ }
+
+ return NvCtrlSuccess;
+}
+
+
+
+ReturnStatus NvCtrlGetStringAttribute(const CtrlTarget *ctrl_target,
int attr, char **ptr)
{
- if (!handle) return NvCtrlBadArgument;
- return NvCtrlGetStringDisplayAttribute(handle, 0, attr, ptr);
+ return NvCtrlGetStringDisplayAttribute(ctrl_target, 0, attr, ptr);
} /* NvCtrlGetStringAttribute() */
-ReturnStatus NvCtrlSetStringAttribute(NvCtrlAttributeHandle *handle,
- int attr, const char *ptr, int *ret)
+ReturnStatus NvCtrlSetStringAttribute(CtrlTarget *ctrl_target,
+ int attr, const char *ptr)
{
- if (!handle) return NvCtrlBadArgument;
- return NvCtrlSetStringDisplayAttribute(handle, 0, attr, ptr, ret);
+ return NvCtrlSetStringDisplayAttribute(ctrl_target, 0, attr, ptr);
} /* NvCtrlSetStringAttribute() */
-ReturnStatus
-NvCtrlGetDisplayAttribute64(NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr, int64_t *val)
+ReturnStatus NvCtrlGetDisplayAttribute64(const CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, int64_t *val)
{
- NvCtrlAttributePrivateHandle *h;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
if ((attr >= NV_CTRL_ATTR_EXT_BASE) &&
(attr <= NV_CTRL_ATTR_EXT_LAST_ATTRIBUTE)) {
@@ -586,14 +786,15 @@ NvCtrlGetDisplayAttribute64(NvCtrlAttributeHandle *handle,
} /* NvCtrlGetDisplayAttribute64() */
-ReturnStatus
-NvCtrlGetDisplayAttribute(NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr, int *val)
+ReturnStatus NvCtrlGetDisplayAttribute(const CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, int *val)
{
ReturnStatus status;
int64_t value_64;
- status = NvCtrlGetDisplayAttribute64(handle, display_mask, attr, &value_64);
+ status = NvCtrlGetDisplayAttribute64(ctrl_target, display_mask, attr,
+ &value_64);
*val = value_64;
return status;
@@ -601,13 +802,15 @@ NvCtrlGetDisplayAttribute(NvCtrlAttributeHandle *handle,
} /* NvCtrlGetDisplayAttribute() */
-ReturnStatus
-NvCtrlSetDisplayAttribute(NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr, int val)
+ReturnStatus NvCtrlSetDisplayAttribute(CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, int val)
{
- NvCtrlAttributePrivateHandle *h;
+ NvCtrlAttributePrivateHandle *h = getPrivateHandle(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
if ((attr >= 0) && (attr <= NV_CTRL_LAST_ATTRIBUTE)) {
if (!h->nv) return NvCtrlMissingExtension;
@@ -618,13 +821,15 @@ NvCtrlSetDisplayAttribute(NvCtrlAttributeHandle *handle,
}
-ReturnStatus
-NvCtrlGetVoidDisplayAttribute(NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr, void **ptr)
+ReturnStatus NvCtrlGetVoidDisplayAttribute(const CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, void **ptr)
{
- NvCtrlAttributePrivateHandle *h;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
if ( attr >= NV_CTRL_ATTR_GLX_BASE &&
attr >= NV_CTRL_ATTR_GLX_LAST_ATTRIBUTE ) {
@@ -638,13 +843,15 @@ NvCtrlGetVoidDisplayAttribute(NvCtrlAttributeHandle *handle,
ReturnStatus
-NvCtrlGetValidDisplayAttributeValues(NvCtrlAttributeHandle *handle,
+NvCtrlGetValidDisplayAttributeValues(const CtrlTarget *ctrl_target,
unsigned int display_mask, int attr,
NVCTRLAttributeValidValuesRec *val)
{
- NvCtrlAttributePrivateHandle *h;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
+
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
if ((attr >= 0) && (attr <= NV_CTRL_LAST_ATTRIBUTE)) {
if (!h->nv) return NvCtrlMissingExtension;
@@ -684,12 +891,15 @@ GetValidStringDisplayAttributeValuesExtraAttr(NVCTRLAttributeValidValuesRec
*/
ReturnStatus
-NvCtrlGetValidStringDisplayAttributeValues(NvCtrlAttributeHandle *handle,
+NvCtrlGetValidStringDisplayAttributeValues(const CtrlTarget *ctrl_target,
unsigned int display_mask, int attr,
NVCTRLAttributeValidValuesRec *val)
{
- NvCtrlAttributePrivateHandle *h;
- h = (NvCtrlAttributePrivateHandle *) handle;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
+
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
if ((attr >= 0) && (attr <= NV_CTRL_STRING_LAST_ATTRIBUTE)) {
if (!h->nv) return NvCtrlMissingExtension;
@@ -703,7 +913,7 @@ NvCtrlGetValidStringDisplayAttributeValues(NvCtrlAttributeHandle *handle,
* types
*/
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (h->target_type != X_SCREEN_TARGET) {
return NvCtrlAttributeNotAvailable;
}
@@ -742,14 +952,15 @@ NvCtrlGetValidStringDisplayAttributeValues(NvCtrlAttributeHandle *handle,
} /* NvCtrlGetValidStringDisplayAttributeValues() */
-ReturnStatus
-NvCtrlGetStringDisplayAttribute(NvCtrlAttributeHandle *handle,
- unsigned int display_mask,
- int attr, char **ptr)
+ReturnStatus NvCtrlGetStringDisplayAttribute(const CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, char **ptr)
{
- NvCtrlAttributePrivateHandle *h;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
if ((attr >= 0) && (attr <= NV_CTRL_STRING_LAST_ATTRIBUTE)) {
if (!h->nv) return NvCtrlMissingExtension;
@@ -791,47 +1002,49 @@ NvCtrlGetStringDisplayAttribute(NvCtrlAttributeHandle *handle,
} /* NvCtrlGetStringDisplayAttribute() */
-ReturnStatus
-NvCtrlSetStringDisplayAttribute(NvCtrlAttributeHandle *handle,
- unsigned int display_mask,
- int attr, const char *ptr, int *ret)
+ReturnStatus NvCtrlSetStringDisplayAttribute(CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, const char *ptr)
{
- NvCtrlAttributePrivateHandle *h;
+ NvCtrlAttributePrivateHandle *h = getPrivateHandle(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
if ((attr >= 0) && (attr <= NV_CTRL_STRING_LAST_ATTRIBUTE)) {
if (!h->nv) return NvCtrlMissingExtension;
- return NvCtrlNvControlSetStringAttribute(h, display_mask, attr,
- ptr, ret);
+ return NvCtrlNvControlSetStringAttribute(h, display_mask, attr, ptr);
}
return NvCtrlNoAttribute;
}
-ReturnStatus
-NvCtrlGetBinaryAttribute(NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr,
- unsigned char **data, int *len)
+ReturnStatus NvCtrlGetBinaryAttribute(const CtrlTarget *ctrl_target,
+ unsigned int display_mask, int attr,
+ unsigned char **data, int *len)
{
- NvCtrlAttributePrivateHandle *h;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
+
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
return NvCtrlNvControlGetBinaryAttribute(h, display_mask, attr, data, len);
} /* NvCtrlGetBinaryAttribute() */
-ReturnStatus
-NvCtrlStringOperation(NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr,
- const char *ptrIn, char **ptrOut)
+ReturnStatus NvCtrlStringOperation(CtrlTarget *ctrl_target,
+ unsigned int display_mask, int attr,
+ const char *ptrIn, char **ptrOut)
{
- NvCtrlAttributePrivateHandle *h;
+ NvCtrlAttributePrivateHandle *h = getPrivateHandle(ctrl_target);
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
if ((attr >= 0) && (attr <= NV_CTRL_STRING_OPERATION_LAST_ATTRIBUTE)) {
if (!h->nv) return NvCtrlMissingExtension;
@@ -871,11 +1084,11 @@ char *NvCtrlAttributesStrError(ReturnStatus status)
void NvCtrlAttributeClose(NvCtrlAttributeHandle *handle)
{
- NvCtrlAttributePrivateHandle *h;
+ NvCtrlAttributePrivateHandle *h = (NvCtrlAttributePrivateHandle *)handle;
- if (!handle) return;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
+ if (h == NULL) {
+ return;
+ }
/*
* XXX should free any additional resources allocated by each
@@ -981,23 +1194,28 @@ const char *NvCtrlGetStereoModeName(int stereo_mode)
}
-ReturnStatus NvCtrlGetColorAttributes(NvCtrlAttributeHandle *handle,
+ReturnStatus NvCtrlGetColorAttributes(const CtrlTarget *ctrl_target,
float contrast[3],
float brightness[3],
float gamma[3])
{
- NvCtrlAttributePrivateHandle *h = (NvCtrlAttributePrivateHandle *) handle;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
+
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
- if (h->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ switch (h->target_type) {
+ case X_SCREEN_TARGET:
return NvCtrlVidModeGetColorAttributes(h, contrast, brightness, gamma);
- } else if (h->target_type == NV_CTRL_TARGET_TYPE_DISPLAY) {
+ case DISPLAY_TARGET:
return NvCtrlXrandrGetColorAttributes(h, contrast, brightness, gamma);
+ default:
+ return NvCtrlBadHandle;
}
-
- return NvCtrlBadHandle;
}
-ReturnStatus NvCtrlSetColorAttributes(NvCtrlAttributeHandle *handle,
+ReturnStatus NvCtrlSetColorAttributes(CtrlTarget *ctrl_target,
float c[3],
float b[3],
float g[3],
@@ -1006,15 +1224,21 @@ ReturnStatus NvCtrlSetColorAttributes(NvCtrlAttributeHandle *handle,
ReturnStatus status;
int val = 0;
- NvCtrlAttributePrivateHandle *h = (NvCtrlAttributePrivateHandle *) handle;
+ NvCtrlAttributePrivateHandle *h = getPrivateHandle(ctrl_target);
+
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
- status = NvCtrlGetAttribute(h, NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE, &val);
+ status = NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE,
+ &val);
if (status == NvCtrlSuccess && val) {
switch (h->target_type) {
- case NV_CTRL_TARGET_TYPE_X_SCREEN:
+ case X_SCREEN_TARGET:
return NvCtrlVidModeSetColorAttributes(h, c, b, g, bitmask);
- case NV_CTRL_TARGET_TYPE_DISPLAY:
+ case DISPLAY_TARGET:
return NvCtrlXrandrSetColorAttributes(h, c, b, g, bitmask);
default:
return NvCtrlBadHandle;
@@ -1028,34 +1252,44 @@ ReturnStatus NvCtrlSetColorAttributes(NvCtrlAttributeHandle *handle,
}
-ReturnStatus NvCtrlGetColorRamp(NvCtrlAttributeHandle *handle,
+ReturnStatus NvCtrlGetColorRamp(const CtrlTarget *ctrl_target,
unsigned int channel,
uint16_t **lut,
int *n)
{
- NvCtrlAttributePrivateHandle *h = (NvCtrlAttributePrivateHandle *) handle;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
+
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
- if (h->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ switch (h->target_type) {
+ case X_SCREEN_TARGET:
return NvCtrlVidModeGetColorRamp(h, channel, lut, n);
- } else if (h->target_type == NV_CTRL_TARGET_TYPE_DISPLAY) {
+ case DISPLAY_TARGET:
return NvCtrlXrandrGetColorRamp(h, channel, lut, n);
+ default:
+ return NvCtrlBadHandle;
}
-
- return NvCtrlBadHandle;
}
-ReturnStatus NvCtrlReloadColorRamp(NvCtrlAttributeHandle *handle)
+ReturnStatus NvCtrlReloadColorRamp(CtrlTarget *ctrl_target)
{
- NvCtrlAttributePrivateHandle *h = (NvCtrlAttributePrivateHandle *) handle;
+ NvCtrlAttributePrivateHandle *h = getPrivateHandle(ctrl_target);
- if (h->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (h == NULL) {
+ return NvCtrlBadHandle;
+ }
+
+ switch (h->target_type) {
+ case X_SCREEN_TARGET:
return NvCtrlVidModeReloadColorRamp(h);
- } else if (h->target_type == NV_CTRL_TARGET_TYPE_DISPLAY) {
+ case DISPLAY_TARGET:
return NvCtrlXrandrReloadColorRamp(h);
+ default:
+ return NvCtrlBadHandle;
}
-
- return NvCtrlBadHandle;
}
@@ -1211,3 +1445,318 @@ void NvCtrlAssignGammaInput(NvCtrlGammaInput *pGammaInput,
}
}
}
+
+
+NvCtrlEventHandle *NvCtrlGetEventHandle(const CtrlTarget *ctrl_target)
+{
+ NvCtrlEventPrivateHandle *evt_h;
+ NvCtrlEventPrivateHandleNode *evt_hnode;
+ const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target);
+
+ if (h == NULL) {
+ return NULL;
+ }
+
+ /* Look for the event handle */
+ evt_h = NULL;
+ for (evt_hnode = __event_handles;
+ evt_hnode;
+ evt_hnode = evt_hnode->next) {
+
+ if (evt_hnode->handle->dpy == h->dpy) {
+ evt_h = evt_hnode->handle;
+ break;
+ }
+ }
+
+ /* If not found, create a new one */
+ if (!evt_h) {
+ evt_h = nvalloc(sizeof(*evt_h));
+ evt_h->dpy = h->dpy;
+ evt_h->fd = ConnectionNumber(h->dpy);
+ evt_h->nvctrl_event_base = (h->nv) ? h->nv->event_base : -1;
+ evt_h->xrandr_event_base = (h->xrandr) ? h->xrandr->event_base : -1;
+
+ /* Add it to the list of event handles */
+ evt_hnode = nvalloc(sizeof(*evt_hnode));
+ evt_hnode->handle = evt_h;
+ evt_hnode->next = __event_handles;
+ __event_handles = evt_hnode;
+ }
+
+ /*
+ * This next bit of code is to make sure that the xrandr_event_base
+ * for this event handle is valid in the case where a NON X Screen
+ * target type handle is used to create the initial event handle
+ * (Resulting in xrandr_event_base being == -1), followed by an
+ * X Screen target type handle registering itself to receive
+ * XRandR events on the existing dpy/event handle.
+ */
+ if (evt_h->xrandr_event_base == -1 &&
+ h->target_type == X_SCREEN_TARGET &&
+ h->xrandr) {
+
+ evt_h->xrandr_event_base = h->xrandr->event_base;
+ }
+
+ return (NvCtrlEventHandle *)evt_h;
+}
+
+ReturnStatus
+NvCtrlCloseEventHandle(NvCtrlEventHandle *handle)
+{
+ NvCtrlEventPrivateHandleNode *evt_hnode;
+
+ if (!handle) {
+ return NvCtrlBadArgument;
+ }
+
+ /* Look for the event handle */
+ if (__event_handles) {
+ NvCtrlEventPrivateHandleNode *prev;
+
+ if (__event_handles->handle == handle) {
+ evt_hnode = __event_handles;
+ __event_handles = __event_handles->next;
+ goto free_handle;
+ }
+
+ prev = __event_handles;
+ for (evt_hnode = __event_handles->next;
+ evt_hnode;
+ evt_hnode = evt_hnode->next) {
+
+ if (evt_hnode->handle == handle) {
+ prev->next = evt_hnode->next;
+ goto free_handle;
+ }
+
+ prev = evt_hnode;
+ }
+ }
+
+ return NvCtrlBadHandle;
+
+free_handle:
+ free(handle);
+ free(evt_hnode);
+
+ return NvCtrlSuccess;
+}
+
+ReturnStatus
+NvCtrlEventHandleGetFD(NvCtrlEventHandle *handle, int *fd)
+{
+ NvCtrlEventPrivateHandle *evt_h;
+
+ if (!handle) {
+ return NvCtrlBadArgument;
+ }
+
+ evt_h = (NvCtrlEventPrivateHandle*)handle;
+
+ *fd = evt_h->fd;
+
+ return NvCtrlSuccess;
+}
+
+ReturnStatus
+NvCtrlEventHandlePending(NvCtrlEventHandle *handle, Bool *pending)
+{
+ NvCtrlEventPrivateHandle *evt_h;
+
+ if (!handle) {
+ return NvCtrlBadArgument;
+ }
+
+ evt_h = (NvCtrlEventPrivateHandle*)handle;
+
+ if (XPending(evt_h->dpy)) {
+ *pending = TRUE;
+ } else {
+ *pending = FALSE;
+ }
+
+ return NvCtrlSuccess;
+}
+
+static int get_screen_of_root(Display *dpy, Window root)
+{
+ int screen = -1;
+
+ /* Find the screen the window belongs to */
+ screen = XScreenCount(dpy);
+
+ while (screen > 0) {
+ screen--;
+ if (root == RootWindow(dpy, screen)) {
+ break;
+ }
+ }
+
+ return screen;
+}
+
+ReturnStatus
+NvCtrlEventHandleNextEvent(NvCtrlEventHandle *handle, CtrlEvent *event)
+{
+ NvCtrlEventPrivateHandle *evt_h;
+ XEvent xevent;
+
+ if (!handle) {
+ return NvCtrlBadArgument;
+ }
+
+ evt_h = (NvCtrlEventPrivateHandle*)handle;
+
+ memset(event, 0, sizeof(CtrlEvent));
+
+
+ /*
+ * if NvCtrlEventHandleNextEvent() is called, then
+ * NvCtrlEventHandlePending() returned TRUE, so we
+ * know there is an event pending
+ */
+ XNextEvent(evt_h->dpy, &xevent);
+
+
+ /*
+ * Handle NV-CONTROL events
+ */
+ if (evt_h->nvctrl_event_base != -1) {
+
+ int xevt_type = xevent.type - evt_h->nvctrl_event_base;
+
+ /*
+ * Handle the ATTRIBUTE_CHANGED_EVENT event
+ */
+ if (xevt_type == ATTRIBUTE_CHANGED_EVENT) {
+
+ XNVCtrlAttributeChangedEvent *nvctrlevent =
+ (XNVCtrlAttributeChangedEvent *) &xevent;
+
+ event->type = CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE;
+ event->target_type = X_SCREEN_TARGET;
+ event->target_id = nvctrlevent->screen;
+
+ event->int_attr.attribute = nvctrlevent->attribute;
+ event->int_attr.value = nvctrlevent->value;
+ event->int_attr.is_availability_changed = FALSE;
+
+ return NvCtrlSuccess;
+ }
+
+ /*
+ * Handle the TARGET_ATTRIBUTE_CHANGED_EVENT event
+ */
+ if (xevt_type == TARGET_ATTRIBUTE_CHANGED_EVENT) {
+
+ XNVCtrlAttributeChangedEventTarget *nvctrlevent =
+ (XNVCtrlAttributeChangedEventTarget *) &xevent;
+
+ event->type = CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE;
+ event->target_type = nvctrlevent->target_type;
+ event->target_id = nvctrlevent->target_id;
+
+ event->int_attr.attribute = nvctrlevent->attribute;
+ event->int_attr.value = nvctrlevent->value;
+ event->int_attr.is_availability_changed = FALSE;
+
+ return NvCtrlSuccess;
+ }
+
+ /*
+ * Handle the TARGET_ATTRIBUTE_AVAILABILITY_CHANGED_EVENT event
+ */
+ if (xevt_type == TARGET_ATTRIBUTE_AVAILABILITY_CHANGED_EVENT) {
+
+ XNVCtrlAttributeChangedEventTargetAvailability *nvctrlevent =
+ (XNVCtrlAttributeChangedEventTargetAvailability *) &xevent;
+
+ event->type = CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE;
+ event->target_type = nvctrlevent->target_type;
+ event->target_id = nvctrlevent->target_id;
+
+ event->int_attr.attribute = nvctrlevent->attribute;
+ event->int_attr.value = nvctrlevent->value;
+ event->int_attr.is_availability_changed = TRUE;
+ event->int_attr.availability = nvctrlevent->availability;
+
+ return NvCtrlSuccess;
+ }
+
+ /*
+ * Handle the TARGET_STRING_ATTRIBUTE_CHANGED_EVENT event
+ */
+ if (xevt_type == TARGET_STRING_ATTRIBUTE_CHANGED_EVENT) {
+
+ XNVCtrlStringAttributeChangedEventTarget *nvctrlevent =
+ (XNVCtrlStringAttributeChangedEventTarget *) &xevent;
+
+ event->type = CTRL_EVENT_TYPE_STRING_ATTRIBUTE;
+ event->target_type = nvctrlevent->target_type;
+ event->target_id = nvctrlevent->target_id;
+
+ event->str_attr.attribute = nvctrlevent->attribute;
+
+ return NvCtrlSuccess;
+ }
+
+ /*
+ * Handle the TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT event
+ */
+ if (xevt_type == TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT) {
+
+ XNVCtrlBinaryAttributeChangedEventTarget *nvctrlevent =
+ (XNVCtrlBinaryAttributeChangedEventTarget *) &event;
+
+ event->type = CTRL_EVENT_TYPE_BINARY_ATTRIBUTE;
+ event->target_type = nvctrlevent->target_type;
+ event->target_id = nvctrlevent->target_id;
+
+ event->bin_attr.attribute = nvctrlevent->attribute;
+
+ return NvCtrlSuccess;
+ }
+ }
+
+
+ /*
+ * Handle XRandR events
+ */
+ if (evt_h->xrandr_event_base != -1) {
+
+ int rrevt_type = xevent.type - evt_h->xrandr_event_base;
+
+ /*
+ * Handle the RRScreenChangeNotify event
+ */
+ if (rrevt_type == RRScreenChangeNotify) {
+
+ XRRScreenChangeNotifyEvent *xrandrevent =
+ (XRRScreenChangeNotifyEvent *)&xevent;
+
+ event->type = CTRL_EVENT_TYPE_SCREEN_CHANGE;
+ event->target_type = X_SCREEN_TARGET;
+ event->target_id = get_screen_of_root(xrandrevent->display,
+ xrandrevent->root);
+
+ event->screen_change.width = xrandrevent->width;
+ event->screen_change.height = xrandrevent->height;
+ event->screen_change.mwidth = xrandrevent->mwidth;
+ event->screen_change.mheight = xrandrevent->mheight;
+
+ return NvCtrlSuccess;
+ }
+ }
+
+
+ /*
+ * Trap events that get registered but are not handled
+ * properly.
+ */
+ nv_warning_msg("Unknown event type %d.", xevent.type);
+
+ return NvCtrlSuccess;
+}
+
diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributes.h b/src/libXNVCtrlAttributes/NvCtrlAttributes.h
index e08d749..8e458c6 100644
--- a/src/libXNVCtrlAttributes/NvCtrlAttributes.h
+++ b/src/libXNVCtrlAttributes/NvCtrlAttributes.h
@@ -23,6 +23,7 @@
#include <X11/Xlib.h>
#include "NVCtrl.h"
+#include "common-utils.h"
typedef void NvCtrlAttributeHandle;
@@ -32,6 +33,127 @@ typedef void NvCtrlAttributeHandle;
/*
+ * Indices into both targetTypeTable[] and CtrlSystem->targets[] array.
+ */
+
+typedef enum {
+ X_SCREEN_TARGET = 0,
+ GPU_TARGET,
+ FRAMELOCK_TARGET,
+ VCS_TARGET,
+ GVI_TARGET,
+ COOLER_TARGET,
+ THERMAL_SENSOR_TARGET,
+ NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET,
+ DISPLAY_TARGET,
+
+ MAX_TARGET_TYPES,
+ INVALID_TARGET = -1
+} CtrlTargetType;
+
+
+/*
+ * Defines the values associated with each target type.
+ */
+
+typedef struct {
+ char *name; /* full name for logging */
+ char *parsed_name; /* name used by parser */
+ int nvctrl; /* NV-CONTROL target type value (NV_CTRL_TARGET_TYPE) */
+
+ /* flag set in NVCTRLAttributeValidValuesRec.permissions */
+ unsigned int permission_bit;
+
+ /* whether this target type is aware of display devices */
+ int uses_display_devices;
+
+ /*
+ * the minimum NV-CONTROL Protocol version required to use this target
+ * type; note that all future target types should be able to use 1.18,
+ * since that version and later allows NV-CONTROL clients to query the
+ * count of TargetTypes not recognized by the X server
+ */
+
+ int major;
+ int minor;
+
+} CtrlTargetTypeInfo;
+
+
+enum {
+ NV_DPY_PROTO_NAME_TYPE_BASENAME = 0,
+ NV_DPY_PROTO_NAME_TYPE_ID,
+ NV_DPY_PROTO_NAME_DP_GUID,
+ NV_DPY_PROTO_NAME_EDID_HASH,
+ NV_DPY_PROTO_NAME_TARGET_INDEX,
+ NV_DPY_PROTO_NAME_RANDR,
+ NV_DPY_PROTO_NAME_MAX,
+};
+
+enum {
+ NV_GPU_PROTO_NAME_TYPE_ID = 0,
+ NV_GPU_PROTO_NAME_UUID,
+ NV_GPU_PROTO_NAME_MAX,
+};
+
+#define NV_PROTO_NAME_MAX (NV_MAX((int)NV_DPY_PROTO_NAME_MAX, (int)NV_GPU_PROTO_NAME_MAX))
+
+typedef struct _CtrlTarget CtrlTarget;
+typedef struct _CtrlTargetNode CtrlTargetNode;
+typedef struct _CtrlSystem CtrlSystem;
+typedef struct _CtrlSystemList CtrlSystemList;
+
+struct _CtrlTarget {
+ NvCtrlAttributeHandle *h; /* handle for this target */
+
+ CtrlSystem *system; /* the system this target belongs to */
+ const CtrlTargetTypeInfo *targetTypeInfo;
+
+ unsigned int d; /* display device mask for this target */
+ unsigned int c; /* Connected display device mask for target */
+ char *name; /* Name for this target */
+ char *protoNames[NV_PROTO_NAME_MAX]; /* List of valid names for this target */
+
+ struct {
+ Bool connected; /* Connection state of display device */
+ Bool enabled; /* Enabled state of display device */
+ } display;
+
+ struct _CtrlTargetNode *relations; /* List of associated targets */
+};
+
+/* Used to keep track of lists of targets */
+struct _CtrlTargetNode {
+ CtrlTargetNode *next;
+ CtrlTarget *t;
+};
+
+/* Tracks all the targets for a single system. Note that
+ * targets[X_SCREEN_TARGET] only holds API X screens targets.
+ * In order to query to physical X screens targets 'physical_screens'
+ * must be used instead. 'physical_screens' do not keep tracking of
+ * target relationships
+ */
+struct _CtrlSystem {
+ /* X system data */
+ char *display; /* string for XOpenDisplay */
+ Display *dpy; /* X display connection */
+
+ CtrlTargetNode *targets[MAX_TARGET_TYPES]; /* Shadows targetTypeTable */
+ CtrlTargetNode *physical_screens;
+ CtrlSystemList *system_list; /* pointer to the system list being tracked */
+};
+
+/* Tracks all systems referenced by command line and/or the configuration
+ * file (.nvidia-settings.).
+ */
+struct _CtrlSystemList {
+ int n; /* number of systems */
+ CtrlSystem **array; /* dynamically allocated array */
+};
+
+
+/*
* Constants for controlling values (brightness, contrast, gamma) for
* each color channel. The *INDEX constants are only meant for
* internal use. The CHANNEL and VALUE constants are meant to be used
@@ -74,6 +196,21 @@ typedef void NvCtrlAttributeHandle;
/*
+ * Attribute types used to know how to access each attribute - for example, to
+ * know which of the NvCtrlXXX() backend functions to call.
+ */
+
+typedef enum {
+ CTRL_ATTRIBUTE_TYPE_INTEGER,
+ CTRL_ATTRIBUTE_TYPE_STRING,
+ CTRL_ATTRIBUTE_TYPE_STRING_OPERATION,
+ CTRL_ATTRIBUTE_TYPE_BINARY_DATA,
+ CTRL_ATTRIBUTE_TYPE_COLOR,
+ CTRL_ATTRIBUTE_TYPE_SDI_CSC,
+} CtrlAttributeType;
+
+
+/*
* Valid integer attributes for NvCtrl[Get|Set]Attribute(); these are
* in addition to the ones in NVCtrl.h
*/
@@ -186,6 +323,72 @@ typedef struct GLXFBConfigAttrRec {
/*
+ * Used to pack CtrlAttributePerms.valid_targets
+ */
+#define CTRL_TARGET_PERM_BIT(TARGET_TYPE) (1 << ((int)(TARGET_TYPE)))
+
+typedef struct {
+
+ int read : 1;
+ int write : 1;
+
+ unsigned int valid_targets;
+
+} CtrlAttributePerms;
+
+
+/*
+ * Event handle and event structure used to provide an event mechanism to
+ * communicate different backends with the frontend
+ */
+typedef void NvCtrlEventHandle;
+
+typedef enum {
+ CTRL_EVENT_TYPE_UNKNOWN = 0,
+ CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE,
+ CTRL_EVENT_TYPE_STRING_ATTRIBUTE,
+ CTRL_EVENT_TYPE_BINARY_ATTRIBUTE,
+ CTRL_EVENT_TYPE_SCREEN_CHANGE
+} CtrlEventType;
+
+typedef struct {
+ int attribute;
+ int value;
+ Bool is_availability_changed;
+ Bool availability;
+} CtrlEventIntAttribute;
+
+typedef struct {
+ int attribute;
+} CtrlEventStrAttribute;
+
+typedef struct {
+ int attribute;
+} CtrlEventBinAttribute;
+
+typedef struct {
+ int width;
+ int height;
+ int mwidth;
+ int mheight;
+} CtrlEventScreenChange;
+
+typedef struct {
+ CtrlEventType type;
+ CtrlTargetType target_type;
+ int target_id;
+
+ union {
+ CtrlEventIntAttribute int_attr;
+ CtrlEventStrAttribute str_attr;
+ CtrlEventBinAttribute bin_attr;
+ CtrlEventScreenChange screen_change;
+ };
+
+} CtrlEvent;
+
+
+/*
* Additional NV-CONTROL string attributes for NvCtrlGetStringDisplayAttribute();
* these are in addition to the ones in NVCtrl.h
*/
@@ -257,14 +460,6 @@ typedef struct GLXFBConfigAttrRec {
#define NV_CTRL_STRING_XV_LAST_ATTRIBUTE (NV_CTRL_STRING_XV_VERSION)
-/*
- * NvCtrlAttributeInit() - initializes the control panel backend; this
- * includes probing for the various extensions, downloading the
- * initial state of attributes, etc. Takes a Display pointer and
- * screen number, and returns an opaque handle on success; returns
- * NULL if the backend cannot use this screen.
- */
-
#define NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM 0x1
#define NV_CTRL_ATTRIBUTES_XF86VIDMODE_SUBSYSTEM 0x2
@@ -280,42 +475,68 @@ typedef struct GLXFBConfigAttrRec {
+CtrlSystem *NvCtrlConnectToSystem(const char *display, CtrlSystemList *systems);
+CtrlSystem *NvCtrlGetSystem (const char *display, CtrlSystemList *systems);
+void NvCtrlFreeAllSystems (CtrlSystemList *systems);
+
+
+int NvCtrlGetTargetTypeCount (const CtrlSystem *system,
+ CtrlTargetType target_type);
+CtrlTarget *NvCtrlGetTarget (const CtrlSystem *system,
+ CtrlTargetType target_type,
+ int target_id);
+CtrlTarget *NvCtrlGetDefaultTarget (const CtrlSystem *system);
+CtrlTarget *NvCtrlGetDefaultTargetByType(const CtrlSystem *system,
+ CtrlTargetType target_type);
+
+Bool NvCtrlIsTargetTypeValid (CtrlTargetType target_type);
+const CtrlTargetTypeInfo *NvCtrlGetTargetTypeInfo (CtrlTargetType target_type);
+const CtrlTargetTypeInfo *NvCtrlGetTargetTypeInfoByName(const char *name);
+
+void NvCtrlTargetListAdd (CtrlTargetNode **head,
+ CtrlTarget *target,
+ Bool enabled_display_check);
+void NvCtrlTargetListFree(CtrlTargetNode *head);
+
+/*
+ * XXX Changes to the system topology should not be allowed directly from the
+ * front-end
+ */
+CtrlTarget *nv_add_target(CtrlSystem *system, CtrlTargetType target_type, int target_id);
+
+const char *NvCtrlGetDisplayConfigName(const CtrlSystem *system, int target_id);
+
+void NvCtrlRebuildSubsystems(CtrlTarget *ctrl_target, unsigned int subsystem);
+
+Display *NvCtrlGetDisplayPtr (CtrlTarget *ctrl_target);
+char *NvCtrlGetDisplayName(const CtrlTarget *ctrl_target);
+
+int NvCtrlGetTargetType(const CtrlTarget *ctrl_target);
+int NvCtrlGetTargetId (const CtrlTarget *ctrl_target);
+
+char *NvCtrlGetServerVendor (const CtrlTarget *ctrl_target);
+int NvCtrlGetVendorRelease (const CtrlTarget *ctrl_target);
+int NvCtrlGetProtocolVersion (const CtrlTarget *ctrl_target);
+int NvCtrlGetProtocolRevision(const CtrlTarget *ctrl_target);
+
+int NvCtrlGetScreen (const CtrlTarget *ctrl_target);
+int NvCtrlGetScreenWidth (const CtrlTarget *ctrl_target);
+int NvCtrlGetScreenHeight (const CtrlTarget *ctrl_target);
+int NvCtrlGetScreenCount (const CtrlTarget *ctrl_target);
+int NvCtrlGetScreenWidthMM (const CtrlTarget *ctrl_target);
+int NvCtrlGetScreenHeightMM(const CtrlTarget *ctrl_target);
+int NvCtrlGetScreenPlanes (const CtrlTarget *ctrl_target);
+
+ReturnStatus NvCtrlGetColorAttributes(const CtrlTarget *ctrl_target,
+ float contrast[3],
+ float brightness[3],
+ float gamma[3]);
-NvCtrlAttributeHandle *NvCtrlAttributeInit(Display *dpy, int target_type,
- int target_id,
- unsigned int subsystems);
-
-void NvCtrlAttributeRebuildSubsystems(NvCtrlAttributeHandle *handle,
- unsigned int subsystem);
-
-char *NvCtrlGetDisplayName(NvCtrlAttributeHandle *handle);
-Display *NvCtrlGetDisplayPtr(NvCtrlAttributeHandle *handle);
-int NvCtrlGetScreen(NvCtrlAttributeHandle *handle);
-int NvCtrlGetTargetType(NvCtrlAttributeHandle *handle);
-int NvCtrlGetTargetId(NvCtrlAttributeHandle *handle);
-int NvCtrlGetScreenWidth(NvCtrlAttributeHandle *handle);
-int NvCtrlGetScreenHeight(NvCtrlAttributeHandle *handle);
-int NvCtrlGetEventBase(NvCtrlAttributeHandle *handle);
-int NvCtrlGetXrandrEventBase(NvCtrlAttributeHandle *handle);
-char *NvCtrlGetServerVendor(NvCtrlAttributeHandle *handle);
-int NvCtrlGetVendorRelease(NvCtrlAttributeHandle *handle);
-int NvCtrlGetProtocolVersion(NvCtrlAttributeHandle *handle);
-int NvCtrlGetProtocolRevision(NvCtrlAttributeHandle *handle);
-int NvCtrlGetScreenCount(NvCtrlAttributeHandle *handle);
-int NvCtrlGetScreenWidthMM(NvCtrlAttributeHandle *handle);
-int NvCtrlGetScreenHeightMM(NvCtrlAttributeHandle *handle);
-int NvCtrlGetScreenPlanes(NvCtrlAttributeHandle *handle);
-
-ReturnStatus NvCtrlGetColorAttributes (NvCtrlAttributeHandle *handle,
- float contrast[3],
- float brightness[3],
- float gamma[3]);
-
-ReturnStatus NvCtrlSetColorAttributes (NvCtrlAttributeHandle *handle,
- float contrast[3],
- float brightness[3],
- float gamma[3],
- unsigned int flags);
+ReturnStatus NvCtrlSetColorAttributes(CtrlTarget *ctrl_target,
+ float contrast[3],
+ float brightness[3],
+ float gamma[3],
+ unsigned int flags);
/*
* NvCtrlGetColorRamp() - get a pointer to the current color ramp for
@@ -324,25 +545,25 @@ ReturnStatus NvCtrlSetColorAttributes (NvCtrlAttributeHandle *handle,
* will be the number of entries in the color ramp.
*/
-ReturnStatus NvCtrlGetColorRamp (NvCtrlAttributeHandle *handle,
- unsigned int channel,
- unsigned short **lut,
- int *n);
+ReturnStatus NvCtrlGetColorRamp(const CtrlTarget *ctrl_target,
+ unsigned int channel,
+ unsigned short **lut,
+ int *n);
/*
* NvCtrlReloadColorRamp() - Reloads the current color ramp for all
- * channels for the given handle.
+ * channels for the given target.
*/
-ReturnStatus NvCtrlReloadColorRamp (NvCtrlAttributeHandle *handle);
+ReturnStatus NvCtrlReloadColorRamp(CtrlTarget *ctrl_target);
/*
* NvCtrlQueryTargetCount() - query the number of targets available
* on the server of the given target type. This is used, for example
* to return the number of GPUs the server knows about.
*/
-ReturnStatus NvCtrlQueryTargetCount(NvCtrlAttributeHandle *handle,
- int target_type,
+ReturnStatus NvCtrlQueryTargetCount(const CtrlTarget *ctrl_target,
+ CtrlTargetType target_type,
int *val);
/*
@@ -355,14 +576,13 @@ ReturnStatus NvCtrlQueryTargetCount(NvCtrlAttributeHandle *handle,
* but supports 64-bit integer attributes.
*/
-ReturnStatus NvCtrlGetAttribute (NvCtrlAttributeHandle *handle,
- int attr, int *val);
+ReturnStatus NvCtrlGetAttribute(const CtrlTarget *ctrl_target,
+ int attr, int *val);
-ReturnStatus NvCtrlSetAttribute (NvCtrlAttributeHandle *handle,
- int attr, int val);
+ReturnStatus NvCtrlSetAttribute(CtrlTarget *ctrl_target, int attr, int val);
-ReturnStatus NvCtrlGetAttribute64 (NvCtrlAttributeHandle *handle,
- int attr, int64_t *val);
+ReturnStatus NvCtrlGetAttribute64(const CtrlTarget *ctrl_target,
+ int attr, int64_t *val);
/*
@@ -372,8 +592,8 @@ ReturnStatus NvCtrlGetAttribute64 (NvCtrlAttributeHandle *handle,
* are requesting.
*/
-ReturnStatus NvCtrlGetVoidAttribute (NvCtrlAttributeHandle *handle,
- int attr, void **ptr);
+ReturnStatus NvCtrlGetVoidAttribute(const CtrlTarget *ctrl_target,
+ int attr, void **ptr);
/*
@@ -382,8 +602,19 @@ ReturnStatus NvCtrlGetVoidAttribute (NvCtrlAttributeHandle *handle,
* NVCTRLAttributeValidValuesRec in NVCtrl.h.
*/
-ReturnStatus NvCtrlGetValidAttributeValues (NvCtrlAttributeHandle *handle,
- int attr, NVCTRLAttributeValidValuesRec *val);
+ReturnStatus NvCtrlGetValidAttributeValues(const CtrlTarget *ctrl_target,
+ int attr,
+ NVCTRLAttributeValidValuesRec *val);
+
+
+/*
+ * NvCtrlGetAttributePerms() - get the attribute permissions.
+ */
+
+ReturnStatus NvCtrlGetAttributePerms(const CtrlTarget *ctrl_target,
+ int attr_type,
+ int attr,
+ CtrlAttributePerms *perms);
/*
@@ -392,63 +623,58 @@ ReturnStatus NvCtrlGetValidAttributeValues (NvCtrlAttributeHandle *handle,
* #defines in NVCtrl.h.
*/
-ReturnStatus NvCtrlGetStringAttribute (NvCtrlAttributeHandle *handle,
- int attr, char **ptr);
+ReturnStatus NvCtrlGetStringAttribute(const CtrlTarget *ctrl_target,
+ int attr, char **ptr);
/*
* NvCtrlSetStringAttribute() - Set the string associated with the
* specified attribute, where valid values are the NV_CTRL_STRING_
- * #defines in NVCtrl.h that have the 'W' (Write) flag set. If 'ret'
- * is specified, (integer) result information is returned.
+ * #defines in NVCtrl.h that have the 'W' (Write) flag set.
*/
-ReturnStatus NvCtrlSetStringAttribute (NvCtrlAttributeHandle *handle,
- int attr, const char *ptr, int *ret);
+ReturnStatus NvCtrlSetStringAttribute(CtrlTarget *ctrl_target,
+ int attr, const char *ptr);
/*
* The following four functions are identical to the above five,
* except that they specify a particular display mask.
*/
-ReturnStatus
-NvCtrlGetDisplayAttribute (NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr, int *val);
-ReturnStatus
-NvCtrlSetDisplayAttribute (NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr, int val);
+ReturnStatus NvCtrlGetDisplayAttribute(const CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, int *val);
+ReturnStatus NvCtrlSetDisplayAttribute(CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, int val);
-ReturnStatus
-NvCtrlGetDisplayAttribute64 (NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr, int64_t *val);
+ReturnStatus NvCtrlGetDisplayAttribute64(const CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, int64_t *val);
-ReturnStatus
-NvCtrlGetVoidDisplayAttribute (NvCtrlAttributeHandle *handle,
- unsigned int display_mask,
- int attr, void **val);
+ReturnStatus NvCtrlGetVoidDisplayAttribute(const CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, void **val);
ReturnStatus
-NvCtrlGetValidDisplayAttributeValues (NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr,
- NVCTRLAttributeValidValuesRec *val);
+NvCtrlGetValidDisplayAttributeValues(const CtrlTarget *ctrl_target,
+ unsigned int display_mask, int attr,
+ NVCTRLAttributeValidValuesRec *val);
ReturnStatus
-NvCtrlGetValidStringDisplayAttributeValues (NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr,
- NVCTRLAttributeValidValuesRec *val);
+NvCtrlGetValidStringDisplayAttributeValues(const CtrlTarget *ctrl_target,
+ unsigned int display_mask, int attr,
+ NVCTRLAttributeValidValuesRec *val);
-ReturnStatus
-NvCtrlGetStringDisplayAttribute (NvCtrlAttributeHandle *handle,
- unsigned int display_mask,
- int attr, char **ptr);
+ReturnStatus NvCtrlGetStringDisplayAttribute(const CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, char **ptr);
-ReturnStatus
-NvCtrlSetStringDisplayAttribute (NvCtrlAttributeHandle *handle,
- unsigned int display_mask,
- int attr, const char *ptr, int *ret);
+ReturnStatus NvCtrlSetStringDisplayAttribute(CtrlTarget *ctrl_target,
+ unsigned int display_mask,
+ int attr, const char *ptr);
-ReturnStatus
-NvCtrlGetBinaryAttribute(NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr,
- unsigned char **data, int *len);
+ReturnStatus NvCtrlGetBinaryAttribute(const CtrlTarget *ctrl_target,
+ unsigned int display_mask, int attr,
+ unsigned char **data, int *len);
/*
* NvCtrlStringOperation() - Performs the string operation associated
@@ -457,10 +683,9 @@ NvCtrlGetBinaryAttribute(NvCtrlAttributeHandle *handle,
* is specified, (string) result information is returned.
*/
-ReturnStatus
-NvCtrlStringOperation(NvCtrlAttributeHandle *handle,
- unsigned int display_mask, int attr,
- const char *ptrIn, char **ptrOut);
+ReturnStatus NvCtrlStringOperation(CtrlTarget *ctrl_target,
+ unsigned int display_mask, int attr,
+ const char *ptrIn, char **ptrOut);
/*
* NvCtrl[SG]etGvoColorConversion() - get and set the color conversion
@@ -469,17 +694,15 @@ NvCtrlStringOperation(NvCtrlAttributeHandle *handle,
* attribute is TRUE.
*/
-ReturnStatus
-NvCtrlSetGvoColorConversion(NvCtrlAttributeHandle *handle,
- float colorMatrix[3][3],
- float colorOffset[3],
- float colorScale[3]);
+ReturnStatus NvCtrlSetGvoColorConversion(CtrlTarget *ctrl_target,
+ float colorMatrix[3][3],
+ float colorOffset[3],
+ float colorScale[3]);
-ReturnStatus
-NvCtrlGetGvoColorConversion(NvCtrlAttributeHandle *handle,
- float colorMatrix[3][3],
- float colorOffset[3],
- float colorScale[3]);
+ReturnStatus NvCtrlGetGvoColorConversion(const CtrlTarget *ctrl_target,
+ float colorMatrix[3][3],
+ float colorOffset[3],
+ float colorScale[3]);
const char *NvCtrlGetStereoModeNameIfExists(int stereo_mode);
const char *NvCtrlGetStereoModeName(int stereo_mode);
@@ -490,4 +713,41 @@ char *NvCtrlAttributesStrError (ReturnStatus status);
void NvCtrlAttributeClose(NvCtrlAttributeHandle *handle);
+
+/*
+ * NvCtrlGetEventHandle() - Returns the unique event handle associated with the
+ * specified control target. If it does not exist, creates a new one.
+ */
+NvCtrlEventHandle *NvCtrlGetEventHandle(const CtrlTarget *ctrl_target);
+
+/*
+ * NvCtrlCloseEventHandle() - Closes and frees the previously allocated
+ * resources of the specified event handle.
+ */
+ReturnStatus
+NvCtrlCloseEventHandle(NvCtrlEventHandle *handle);
+
+/*
+ * NvCtrlEventHandleGetFD() - Get the file descriptor associated with the
+ * specified event handle.
+ */
+ReturnStatus
+NvCtrlEventHandleGetFD(NvCtrlEventHandle *handle, int *fd);
+
+/*
+ * NvCtrlEventHandlePending() - Check whether there are pending events or not in
+ * the specified event handle.
+ */
+ReturnStatus
+NvCtrlEventHandlePending(NvCtrlEventHandle *handle, Bool *pending);
+
+/*
+ * NvCtrlEventHandleNextEvent() - Get the next event data in the specified event
+ * handle.
+ */
+ReturnStatus
+NvCtrlEventHandleNextEvent(NvCtrlEventHandle *handle, CtrlEvent *event);
+
+
+
#endif /* __NVCTRL_ATTRIBUTES__ */
diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c b/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c
index 717bd43..aae68bc 100644
--- a/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c
+++ b/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c
@@ -272,7 +272,7 @@ NvCtrlInitGlxAttributes (NvCtrlAttributePrivateHandle *h)
/* Check parameters */
- if ( !h || !h->dpy || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN ) {
+ if ( !h || !h->dpy || h->target_type != X_SCREEN_TARGET ) {
return False;
}
@@ -338,7 +338,7 @@ NvCtrlGlxAttributesClose (NvCtrlAttributePrivateHandle *h)
#ifdef GLX_VERSION_1_3
static GLXFBConfigAttr *
-get_fbconfig_attribs(NvCtrlAttributePrivateHandle *h)
+get_fbconfig_attribs(const NvCtrlAttributePrivateHandle *h)
{
XVisualInfo * visinfo;
@@ -351,7 +351,7 @@ get_fbconfig_attribs(NvCtrlAttributePrivateHandle *h)
- assert(h->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN);
+ assert(h->target_type == X_SCREEN_TARGET);
/* Get all fbconfigs for the display/screen */
@@ -563,16 +563,15 @@ get_fbconfig_attribs(NvCtrlAttributePrivateHandle *h)
*
****/
-ReturnStatus
-NvCtrlGlxGetVoidAttribute (NvCtrlAttributePrivateHandle *h,
- unsigned int display_mask,
- int attr, void **ptr)
+ReturnStatus NvCtrlGlxGetVoidAttribute(const NvCtrlAttributePrivateHandle *h,
+ unsigned int display_mask,
+ int attr, void **ptr)
{
GLXFBConfigAttr * fbconfig_attribs = NULL;
/* Validate */
- if ( !h || !h->dpy || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN ) {
+ if ( !h || !h->dpy || h->target_type != X_SCREEN_TARGET ) {
return NvCtrlBadHandle;
}
if ( !h->glx || !__libGL ) {
@@ -635,7 +634,7 @@ NvCtrlGlxGetVoidAttribute (NvCtrlAttributePrivateHandle *h,
* GLX context and return "Yes" or "No". Otherwise, create a context and query
* the GLX implementation for the string specified in prop.
*/
-static const char *getString(NvCtrlAttributePrivateHandle *h,
+static const char *getString(const NvCtrlAttributePrivateHandle *h,
Bool getDirect, GLenum prop)
{
const char *str = NULL;
@@ -695,15 +694,14 @@ static const char *getString(NvCtrlAttributePrivateHandle *h,
return str;
}
-ReturnStatus
-NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *h,
- unsigned int display_mask,
- int attr, char **ptr)
+ReturnStatus NvCtrlGlxGetStringAttribute(const NvCtrlAttributePrivateHandle *h,
+ unsigned int display_mask,
+ int attr, char **ptr)
{
const char *str = NULL;
/* Validate */
- if ( !h || !h->dpy || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN ) {
+ if ( !h || !h->dpy || h->target_type != X_SCREEN_TARGET ) {
return NvCtrlBadHandle;
}
if ( !h->glx || !__libGL ) {
diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c b/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c
index 1e1a89d..6a22ff0 100644
--- a/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c
+++ b/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c
@@ -40,6 +40,7 @@ NvCtrlInitNvControlAttributes (NvCtrlAttributePrivateHandle *h)
{
NvCtrlNvControlAttributes *nv;
int ret, major, minor, event, error;
+ const CtrlTargetTypeInfo *targetTypeInfo;
ret = XNVCTRLQueryExtension (h->dpy, &event, &error);
if (ret != True) {
@@ -60,7 +61,7 @@ NvCtrlInitNvControlAttributes (NvCtrlAttributePrivateHandle *h)
return NULL;
}
- if (h->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (h->target_type == X_SCREEN_TARGET) {
ret = XNVCTRLIsNvScreen (h->dpy, h->target_id);
if (ret != True) {
nv_warning_msg("NV-CONTROL extension not present on screen %d "
@@ -71,8 +72,17 @@ NvCtrlInitNvControlAttributes (NvCtrlAttributePrivateHandle *h)
nv = nvalloc(sizeof(NvCtrlNvControlAttributes));
- ret = XNVCtrlSelectTargetNotify(h->dpy, h->target_type, h->target_id,
- TARGET_ATTRIBUTE_CHANGED_EVENT, True);
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(h->target_type);
+ if (targetTypeInfo == NULL) {
+ nv_error_msg("Invalid or unknown target type");
+ return NULL;
+ }
+
+ ret = XNVCtrlSelectTargetNotify(h->dpy,
+ targetTypeInfo->nvctrl,
+ h->target_id,
+ TARGET_ATTRIBUTE_CHANGED_EVENT,
+ True);
if (ret != True) {
nv_warning_msg("Unable to select attribute changed NV-CONTROL "
"events.");
@@ -84,7 +94,9 @@ NvCtrlInitNvControlAttributes (NvCtrlAttributePrivateHandle *h)
*/
if (NV_VERSION2(major, minor) >= NV_VERSION2(1, 15)) {
- ret = XNVCtrlSelectTargetNotify(h->dpy, h->target_type, h->target_id,
+ ret = XNVCtrlSelectTargetNotify(h->dpy,
+ targetTypeInfo->nvctrl,
+ h->target_id,
TARGET_ATTRIBUTE_AVAILABILITY_CHANGED_EVENT,
True);
if (ret != True) {
@@ -99,7 +111,9 @@ NvCtrlInitNvControlAttributes (NvCtrlAttributePrivateHandle *h)
*/
if (NV_VERSION2(major, minor) >= NV_VERSION2(1, 16)) {
- ret = XNVCtrlSelectTargetNotify(h->dpy, h->target_type, h->target_id,
+ ret = XNVCtrlSelectTargetNotify(h->dpy,
+ targetTypeInfo->nvctrl,
+ h->target_id,
TARGET_STRING_ATTRIBUTE_CHANGED_EVENT,
True);
if (ret != True) {
@@ -113,7 +127,9 @@ NvCtrlInitNvControlAttributes (NvCtrlAttributePrivateHandle *h)
* 1.17
*/
if (NV_VERSION2(major, minor) >= NV_VERSION2(1, 17)) {
- ret = XNVCtrlSelectTargetNotify(h->dpy, h->target_type, h->target_id,
+ ret = XNVCtrlSelectTargetNotify(h->dpy,
+ targetTypeInfo->nvctrl,
+ h->target_id,
TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT,
True);
if (ret != True) {
@@ -132,20 +148,27 @@ NvCtrlInitNvControlAttributes (NvCtrlAttributePrivateHandle *h)
} /* NvCtrlInitNvControlAttributes() */
-ReturnStatus NvCtrlNvControlQueryTargetCount(NvCtrlAttributePrivateHandle *h,
- int target_type, int *val)
+ReturnStatus
+NvCtrlNvControlQueryTargetCount(const NvCtrlAttributePrivateHandle *h,
+ CtrlTargetType target_type, int *val)
{
int ret;
+ const CtrlTargetTypeInfo *targetTypeInfo;
+
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(target_type);
+ if (targetTypeInfo == NULL) {
+ return NvCtrlBadArgument;
+ }
- ret = XNVCTRLQueryTargetCount(h->dpy, target_type, val);
+ ret = XNVCTRLQueryTargetCount(h->dpy, targetTypeInfo->nvctrl, val);
return (ret) ? NvCtrlSuccess : NvCtrlError;
} /* NvCtrlNvControlQueryTargetCount() */
-ReturnStatus NvCtrlNvControlGetAttribute (NvCtrlAttributePrivateHandle *h,
- unsigned int display_mask,
- int attr, int64_t *val)
+ReturnStatus NvCtrlNvControlGetAttribute(const NvCtrlAttributePrivateHandle *h,
+ unsigned int display_mask,
+ int attr, int64_t *val)
{
ReturnStatus status;
int value_32;
@@ -155,13 +178,21 @@ ReturnStatus NvCtrlNvControlGetAttribute (NvCtrlAttributePrivateHandle *h,
minor = h->nv->minor_version;
if (attr <= NV_CTRL_LAST_ATTRIBUTE) {
+ const CtrlTargetTypeInfo *targetTypeInfo;
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(h->target_type);
+ if (targetTypeInfo == NULL) {
+ return NvCtrlBadHandle;
+ }
+
if (NV_VERSION2(major, minor) > NV_VERSION2(1, 20)) {
- status = XNVCTRLQueryTargetAttribute64(h->dpy, h->target_type,
+ status = XNVCTRLQueryTargetAttribute64(h->dpy,
+ targetTypeInfo->nvctrl,
h->target_id,
display_mask, attr,
val);
} else {
- status = XNVCTRLQueryTargetAttribute(h->dpy, h->target_type,
+ status = XNVCTRLQueryTargetAttribute(h->dpy,
+ targetTypeInfo->nvctrl,
h->target_id,
display_mask, attr,
&value_32);
@@ -198,12 +229,19 @@ ReturnStatus NvCtrlNvControlSetAttribute (NvCtrlAttributePrivateHandle *h,
unsigned int display_mask,
int attr, int val)
{
- Bool bRet;
-
if (attr <= NV_CTRL_LAST_ATTRIBUTE) {
- bRet = XNVCTRLSetTargetAttributeAndGetStatus (h->dpy, h->target_type,
- h->target_id,
- display_mask, attr, val);
+ Bool bRet;
+ const CtrlTargetTypeInfo *targetTypeInfo;
+
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(h->target_type);
+ if (targetTypeInfo == NULL) {
+ return NvCtrlBadHandle;
+ }
+
+ bRet = XNVCTRLSetTargetAttributeAndGetStatus(h->dpy,
+ targetTypeInfo->nvctrl,
+ h->target_id,
+ display_mask, attr, val);
if (!bRet) {
return NvCtrlError;
}
@@ -214,15 +252,23 @@ ReturnStatus NvCtrlNvControlSetAttribute (NvCtrlAttributePrivateHandle *h,
}
-ReturnStatus NvCtrlNvControlGetValidAttributeValues
- (NvCtrlAttributePrivateHandle *h,
- unsigned int display_mask,
- int attr, NVCTRLAttributeValidValuesRec *val)
+ReturnStatus
+NvCtrlNvControlGetValidAttributeValues(const NvCtrlAttributePrivateHandle *h,
+ unsigned int display_mask,
+ int attr,
+ NVCTRLAttributeValidValuesRec *val)
{
if (attr <= NV_CTRL_LAST_ATTRIBUTE) {
- if (XNVCTRLQueryValidTargetAttributeValues (h->dpy, h->target_type,
- h->target_id, display_mask,
- attr, val)) {
+ const CtrlTargetTypeInfo *targetTypeInfo;
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(h->target_type);
+ if (targetTypeInfo == NULL) {
+ return NvCtrlBadHandle;
+ }
+
+ if (XNVCTRLQueryValidTargetAttributeValues(h->dpy,
+ targetTypeInfo->nvctrl,
+ h->target_id, display_mask,
+ attr, val)) {
return NvCtrlSuccess;
} else {
return NvCtrlAttributeNotAvailable;
@@ -236,18 +282,26 @@ ReturnStatus NvCtrlNvControlGetValidAttributeValues
ReturnStatus
NvCtrlNvControlGetValidStringDisplayAttributeValues
- (NvCtrlAttributePrivateHandle *h,
+ (const NvCtrlAttributePrivateHandle *h,
unsigned int display_mask,
- int attr, NVCTRLAttributeValidValuesRec *val)
+ int attr,
+ NVCTRLAttributeValidValuesRec *val)
{
if (attr <= NV_CTRL_STRING_LAST_ATTRIBUTE) {
if (NV_VERSION2(h->nv->major_version, h->nv->minor_version)
>= NV_VERSION2(1, 22)) {
- if (XNVCTRLQueryValidTargetStringAttributeValues (h->dpy,
- h->target_type,
- h->target_id,
- display_mask,
- attr, val)) {
+
+ const CtrlTargetTypeInfo *targetTypeInfo;
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(h->target_type);
+ if (targetTypeInfo == NULL) {
+ return NvCtrlBadHandle;
+ }
+
+ if (XNVCTRLQueryValidTargetStringAttributeValues(h->dpy,
+ targetTypeInfo->nvctrl,
+ h->target_id,
+ display_mask,
+ attr, val)) {
return NvCtrlSuccess;
} else {
return NvCtrlAttributeNotAvailable;
@@ -270,18 +324,18 @@ NvCtrlNvControlGetValidStringDisplayAttributeValues
ReturnStatus
-NvCtrlNvControlGetStringAttribute (NvCtrlAttributePrivateHandle *h,
- unsigned int display_mask,
- int attr, char **ptr)
+NvCtrlNvControlGetStringAttribute(const NvCtrlAttributePrivateHandle *h,
+ unsigned int display_mask,
+ int attr, char **ptr)
{
/* Validate */
if (!h || !h->dpy) {
return NvCtrlBadHandle;
}
-
+
if (attr == NV_CTRL_STRING_NV_CONTROL_VERSION) {
char str[16];
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (h->target_type != X_SCREEN_TARGET) {
return NvCtrlBadHandle;
}
sprintf(str, "%d.%d", h->nv->major_version, h->nv->minor_version);
@@ -290,9 +344,24 @@ NvCtrlNvControlGetStringAttribute (NvCtrlAttributePrivateHandle *h,
}
if (attr <= NV_CTRL_STRING_LAST_ATTRIBUTE) {
- if (XNVCTRLQueryTargetStringAttribute (h->dpy, h->target_type,
- h->target_id, display_mask,
- attr, ptr)) {
+ char *tmp;
+ const CtrlTargetTypeInfo *targetTypeInfo;
+
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(h->target_type);
+ if (targetTypeInfo == NULL) {
+ return NvCtrlBadHandle;
+ }
+
+ if (XNVCTRLQueryTargetStringAttribute(h->dpy,
+ targetTypeInfo->nvctrl,
+ h->target_id, display_mask,
+ attr, &tmp)) {
+ if (tmp) {
+ *ptr = strdup(tmp);
+ XFree(tmp);
+ } else {
+ *ptr = NULL;
+ }
return NvCtrlSuccess;
} else {
return NvCtrlAttributeNotAvailable;
@@ -307,34 +376,37 @@ NvCtrlNvControlGetStringAttribute (NvCtrlAttributePrivateHandle *h,
ReturnStatus
NvCtrlNvControlSetStringAttribute (NvCtrlAttributePrivateHandle *h,
unsigned int display_mask,
- int attr, const char *ptr, int *ret)
+ int attr, const char *ptr)
{
- int tmp_int; /* Temp storage if ret is not specified */
-
if (attr <= NV_CTRL_LAST_ATTRIBUTE) {
- if ( !ret ) {
- ret = &tmp_int;
- }
+ Bool ret;
/* NV-CONTROL 1.19 and above has support for setting string attributes
* on targets other than X screens.
*/
if (NV_VERSION2(h->nv->major_version, h->nv->minor_version) >=
NV_VERSION2(1, 19)) {
- *ret =
- XNVCTRLSetTargetStringAttribute(h->dpy, h->target_type,
- h->target_id, display_mask,
- attr, ptr);
+
+ const CtrlTargetTypeInfo *targetTypeInfo;
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(h->target_type);
+ if (targetTypeInfo == NULL) {
+ return NvCtrlBadHandle;
+ }
+
+ ret = XNVCTRLSetTargetStringAttribute(h->dpy,
+ targetTypeInfo->nvctrl,
+ h->target_id, display_mask,
+ attr, ptr);
} else {
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (h->target_type != X_SCREEN_TARGET) {
return NvCtrlBadHandle;
}
- *ret =
+ ret =
XNVCTRLSetStringAttribute(h->dpy, h->target_id, display_mask,
attr, ptr);
}
- if ( *ret ) {
+ if ( ret ) {
return NvCtrlSuccess;
} else {
return NvCtrlAttributeNotAvailable;
@@ -347,30 +419,58 @@ NvCtrlNvControlSetStringAttribute (NvCtrlAttributePrivateHandle *h,
ReturnStatus
-NvCtrlNvControlGetBinaryAttribute(NvCtrlAttributePrivateHandle *h,
+NvCtrlNvControlGetBinaryAttribute(const NvCtrlAttributePrivateHandle *h,
unsigned int display_mask, int attr,
unsigned char **data, int *len)
{
- Bool bret;
-
+ unsigned char *tmp;
+ Bool ret;
+ int localLen;
+ const CtrlTargetTypeInfo *targetTypeInfo;
+
if (!h->nv) return NvCtrlMissingExtension;
-
+
/* the X_nvCtrlQueryBinaryData opcode was added in 1.7 */
if (NV_VERSION2(h->nv->major_version, h->nv->minor_version) <
NV_VERSION2(1, 7)) {
return NvCtrlNoAttribute;
}
-
- bret = XNVCTRLQueryTargetBinaryData (h->dpy, h->target_type, h->target_id,
- display_mask, attr, data, len);
- if (!bret) {
+
+ if (len == NULL) {
+ len = &localLen;
+ }
+
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(h->target_type);
+ if (targetTypeInfo == NULL) {
+ return NvCtrlBadHandle;
+ }
+
+ ret = XNVCTRLQueryTargetBinaryData(h->dpy,
+ targetTypeInfo->nvctrl,
+ h->target_id,
+ display_mask, attr, &tmp, len);
+ if (!ret) {
return NvCtrlError;
- } else {
+ }
+
+ if (tmp == NULL) {
+ *data = NULL;
return NvCtrlSuccess;
}
-
-} /* NvCtrlNvControlGetBinaryAttribute() */
+
+ *data = malloc(*len);
+ if (*data == NULL) {
+ *len = 0;
+ XFree(tmp);
+ return NvCtrlError;
+ }
+
+ memcpy(*data, tmp, *len);
+ XFree(tmp);
+
+ return NvCtrlSuccess;
+}
ReturnStatus
@@ -378,10 +478,23 @@ NvCtrlNvControlStringOperation(NvCtrlAttributePrivateHandle *h,
unsigned int display_mask, int attr,
const char *ptrIn, char **ptrOut)
{
+ char *tmp;
if (attr <= NV_CTRL_STRING_OPERATION_LAST_ATTRIBUTE) {
- if (XNVCTRLStringOperation (h->dpy, h->target_type,
- h->target_id, display_mask,
- attr, ptrIn, ptrOut)) {
+ const CtrlTargetTypeInfo *targetTypeInfo;
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(h->target_type);
+ if (targetTypeInfo == NULL) {
+ return NvCtrlBadHandle;
+ }
+
+ if (XNVCTRLStringOperation(h->dpy, targetTypeInfo->nvctrl,
+ h->target_id, display_mask,
+ attr, ptrIn, &tmp)) {
+ if (tmp) {
+ *ptrOut = strdup(tmp);
+ XFree(tmp);
+ } else {
+ *ptrOut = NULL;
+ }
return NvCtrlSuccess;
} else {
return NvCtrlAttributeNotAvailable;
@@ -393,21 +506,24 @@ NvCtrlNvControlStringOperation(NvCtrlAttributePrivateHandle *h,
} /* NvCtrlNvControlStringOperation() */
-ReturnStatus
-NvCtrlSetGvoColorConversion(NvCtrlAttributeHandle *handle,
- float colorMatrix[3][3],
- float colorOffset[3],
- float colorScale[3])
+ReturnStatus NvCtrlSetGvoColorConversion(CtrlTarget *ctrl_target,
+ float colorMatrix[3][3],
+ float colorOffset[3],
+ float colorScale[3])
{
NvCtrlAttributePrivateHandle *h;
+
+ if (ctrl_target == NULL || ctrl_target->h == NULL) {
+ return NvCtrlBadHandle;
+ }
- if (!handle) return NvCtrlBadHandle;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
+ h = (NvCtrlAttributePrivateHandle *)(ctrl_target->h);
if (!h->nv) return NvCtrlMissingExtension;
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) return NvCtrlBadHandle;
+ if (h->target_type != X_SCREEN_TARGET) {
+ return NvCtrlBadHandle;
+ }
XNVCTRLSetGvoColorConversion(h->dpy,
h->target_id,
@@ -420,22 +536,25 @@ NvCtrlSetGvoColorConversion(NvCtrlAttributeHandle *handle,
} /* NvCtrlNvControlSetGvoColorConversion() */
-ReturnStatus
-NvCtrlGetGvoColorConversion(NvCtrlAttributeHandle *handle,
- float colorMatrix[3][3],
- float colorOffset[3],
- float colorScale[3])
+ReturnStatus NvCtrlGetGvoColorConversion(const CtrlTarget *ctrl_target,
+ float colorMatrix[3][3],
+ float colorOffset[3],
+ float colorScale[3])
{
- NvCtrlAttributePrivateHandle *h;
+ const NvCtrlAttributePrivateHandle *h;
Bool bRet;
+
+ if (ctrl_target == NULL || ctrl_target->h == NULL) {
+ return NvCtrlBadHandle;
+ }
- if (!handle) return NvCtrlBadHandle;
-
- h = (NvCtrlAttributePrivateHandle *) handle;
+ h = (const NvCtrlAttributePrivateHandle *)(ctrl_target->h);
if (!h->nv) return NvCtrlMissingExtension;
- if (h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) return NvCtrlBadHandle;
+ if (h->target_type != X_SCREEN_TARGET) {
+ return NvCtrlBadHandle;
+ }
bRet = XNVCTRLQueryGvoColorConversion(h->dpy,
h->target_id,
diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c b/src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c
new file mode 100644
index 0000000..77aaf79
--- /dev/null
+++ b/src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c
@@ -0,0 +1,191 @@
+/*
+ * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
+ * and Linux systems.
+ *
+ * Copyright (C) 2014 NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses>.
+ */
+
+/*
+ * NVML backend
+ */
+
+#include <stdlib.h> /* 64 bit malloc */
+#include <string.h>
+
+#include "NvCtrlAttributes.h"
+#include "NvCtrlAttributesPrivate.h"
+
+#include "msg.h"
+#include "parse.h"
+
+#ifdef NVML_AVAILABLE
+
+#include <nvml.h>
+
+
+#define MAX_NVML_STR_LEN 64
+
+
+static Bool __isNvmlLoaded = FALSE;
+static unsigned int __nvmlUsers = 0;
+
+
+static void printNvmlError(nvmlReturn_t error)
+{
+ switch (error) {
+ case NVML_SUCCESS:
+ break;
+
+ case NVML_ERROR_UNINITIALIZED:
+ nv_error_msg("NVML was not first initialized with nvmlInit()");
+ break;
+
+ case NVML_ERROR_INVALID_ARGUMENT:
+ nv_error_msg("A supplied argument is invalid");
+ break;
+
+ case NVML_ERROR_NOT_SUPPORTED:
+ nv_error_msg("The requested operation is not available on target "
+ "device");
+ break;
+
+ case NVML_ERROR_NO_PERMISSION:
+ nv_error_msg("The current user does not have permission for "
+ "operation");
+ break;
+
+ case NVML_ERROR_ALREADY_INITIALIZED:
+ nv_error_msg("Deprecated: Multiple initializations are now allowed "
+ "through ref counting");
+ break;
+
+ case NVML_ERROR_NOT_FOUND:
+ nv_error_msg("A query to find an object was unsuccessful");
+ break;
+
+ case NVML_ERROR_INSUFFICIENT_SIZE:
+ nv_error_msg("An input argument is not large enough");
+ break;
+
+ case NVML_ERROR_INSUFFICIENT_POWER:
+ nv_error_msg("A device's external power cables are not properly "
+ "attached");
+ break;
+
+ case NVML_ERROR_DRIVER_NOT_LOADED:
+ nv_error_msg("NVIDIA driver is not loaded");
+ break;
+
+ case NVML_ERROR_TIMEOUT:
+ nv_error_msg("User provided timeout passed");
+ break;
+
+ case NVML_ERROR_IRQ_ISSUE:
+ nv_error_msg("NVIDIA Kernel detected an interrupt issue with a "
+ "GPU");
+ break;
+
+ case NVML_ERROR_LIBRARY_NOT_FOUND:
+ nv_error_msg("NVML Shared Library couldn't be found or loaded");
+ break;
+
+ case NVML_ERROR_FUNCTION_NOT_FOUND:
+ nv_error_msg("Local version of NVML doesn't implement this "
+ "function");
+ break;
+
+ case NVML_ERROR_CORRUPTED_INFOROM:
+ nv_error_msg("infoROM is corrupted");
+ break;
+
+ case NVML_ERROR_GPU_IS_LOST:
+ nv_error_msg("The GPU has fallen off the bus or has otherwise "
+ "become inaccessible");
+ break;
+
+ case NVML_ERROR_RESET_REQUIRED:
+ nv_error_msg("The GPU requires a reset before it can be used "
+ "again");
+ break;
+
+ case NVML_ERROR_OPERATING_SYSTEM:
+ nv_error_msg("The GPU control device has been blocked by the "
+ "operating system/cgroups");
+ break;
+
+ case NVML_ERROR_UNKNOWN:
+ nv_error_msg("An internal driver error occurred");
+ break;
+ }
+}
+
+#endif // NVML_AVAILABLE
+
+
+/*
+ * Loads and initializes the NVML library
+ */
+
+ReturnStatus NvCtrlInitNvml(void)
+{
+#ifdef NVML_AVAILABLE
+
+ if (!__isNvmlLoaded) {
+ nvmlReturn_t ret = nvmlInit();
+ if (ret != NVML_SUCCESS) {
+ printNvmlError(ret);
+ return NvCtrlMissingExtension;
+ }
+
+ __isNvmlLoaded = TRUE;
+ }
+
+ __nvmlUsers++;
+
+ return NvCtrlSuccess;
+
+#else
+ return NvCtrlMissingExtension;
+#endif
+}
+
+
+
+/*
+ * Unloads the NVML library if it was successfully loaded.
+ */
+
+ReturnStatus NvCtrlDestroyNvml(void)
+{
+#ifdef NVML_AVAILABLE
+
+ if (__isNvmlLoaded) {
+ __nvmlUsers--;
+ if (__nvmlUsers == 0) {
+ nvmlReturn_t ret = nvmlShutdown();
+ if (ret != NVML_SUCCESS) {
+ printNvmlError(ret);
+ return NvCtrlError;
+ }
+ __isNvmlLoaded = FALSE;
+ }
+ }
+ return NvCtrlSuccess;
+
+#else
+ return NvCtrlMissingExtension;
+#endif
+}
+
diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h b/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h
index 55264bc..08bdcae 100644
--- a/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h
+++ b/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h
@@ -77,6 +77,10 @@
#define NV_DLSYM(handle, symbol) ({ dlerror(); dlsym(handle, symbol); })
+/* XXX Modify to be TRUE only for target types which actually need NV-CONTROL */
+#define TARGET_TYPE_NEEDS_NVCONTROL(_TARGET_TYPE_) (TRUE)
+
+
typedef struct __NvCtrlAttributes NvCtrlAttributes;
typedef struct __NvCtrlVidModeAttributes NvCtrlVidModeAttributes;
typedef struct __NvCtrlAttributePrivateHandle NvCtrlAttributePrivateHandle;
@@ -87,6 +91,8 @@ typedef struct __NvCtrlXvTextureAttributes NvCtrlXvTextureAttributes;
typedef struct __NvCtrlXvBlitterAttributes NvCtrlXvBlitterAttributes;
typedef struct __NvCtrlXvAttribute NvCtrlXvAttribute;
typedef struct __NvCtrlXrandrAttributes NvCtrlXrandrAttributes;
+typedef struct __NvCtrlEventPrivateHandle NvCtrlEventPrivateHandle;
+typedef struct __NvCtrlEventPrivateHandleNode NvCtrlEventPrivateHandleNode;
typedef struct {
float brightness[3];
@@ -130,7 +136,7 @@ struct __NvCtrlXrandrAttributes {
struct __NvCtrlAttributePrivateHandle {
Display *dpy; /* display connection */
- int target_type; /* Type of target this handle controls */
+ CtrlTargetType target_type; /* Type of target this handle controls */
int target_id; /* screen num, gpu num (etc) of target */
/* Common attributes */
@@ -143,6 +149,47 @@ struct __NvCtrlAttributePrivateHandle {
NvCtrlXrandrAttributes *xrandr; /* XRandR extension info */
};
+struct __NvCtrlEventPrivateHandle {
+ Display *dpy; /* display connection */
+ int fd; /* file descriptor to poll for new events */
+ int nvctrl_event_base; /* NV-CONTROL base for indexing & identifying evts */
+ int xrandr_event_base; /* RandR base for indexing & identifying evts */
+};
+
+struct __NvCtrlEventPrivateHandleNode {
+ NvCtrlEventPrivateHandle *handle;
+ NvCtrlEventPrivateHandleNode *next;
+};
+
+
+/* Useful inline functions to deal with control targets */
+
+static inline Bool isTargetValid(const CtrlTarget *ctrl_target)
+{
+ return ((ctrl_target != NULL) && (ctrl_target->h != NULL));
+}
+
+static inline NvCtrlAttributePrivateHandle
+*getPrivateHandle(CtrlTarget *ctrl_target)
+{
+ if (!isTargetValid(ctrl_target)) {
+ return NULL;
+ }
+
+ return (NvCtrlAttributePrivateHandle *)(ctrl_target->h);
+}
+
+static inline const NvCtrlAttributePrivateHandle
+*getPrivateHandleConst(const CtrlTarget *ctrl_target)
+{
+ if (!isTargetValid(ctrl_target)) {
+ return NULL;
+ }
+
+ return (const NvCtrlAttributePrivateHandle *)(ctrl_target->h);
+}
+
+
NvCtrlNvControlAttributes *
NvCtrlInitNvControlAttributes (NvCtrlAttributePrivateHandle *);
@@ -161,9 +208,8 @@ NvCtrlInitXvAttributes (NvCtrlAttributePrivateHandle *);
void
NvCtrlXvAttributesClose (NvCtrlAttributePrivateHandle *);
-ReturnStatus
-NvCtrlXvGetStringAttribute (NvCtrlAttributePrivateHandle *,
- unsigned int, int, char **);
+ReturnStatus NvCtrlXvGetStringAttribute(const NvCtrlAttributePrivateHandle *,
+ unsigned int, int, char **);
/* GLX extension attribute functions */
@@ -173,13 +219,11 @@ NvCtrlInitGlxAttributes (NvCtrlAttributePrivateHandle *);
void
NvCtrlGlxAttributesClose (NvCtrlAttributePrivateHandle *);
-ReturnStatus
-NvCtrlGlxGetVoidAttribute (NvCtrlAttributePrivateHandle *, unsigned int,
- int, void **);
+ReturnStatus NvCtrlGlxGetVoidAttribute(const NvCtrlAttributePrivateHandle *,
+ unsigned int, int, void **);
-ReturnStatus
-NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *, unsigned int,
- int, char **);
+ReturnStatus NvCtrlGlxGetStringAttribute(const NvCtrlAttributePrivateHandle *,
+ unsigned int, int, char **);
/* XRandR extension attribute functions */
@@ -191,11 +235,11 @@ void
NvCtrlXrandrAttributesClose (NvCtrlAttributePrivateHandle *);
ReturnStatus
-NvCtrlXrandrGetStringAttribute (NvCtrlAttributePrivateHandle *,
- unsigned int, int, char **);
+NvCtrlXrandrGetStringAttribute(const NvCtrlAttributePrivateHandle *,
+ unsigned int, int, char **);
-ReturnStatus NvCtrlXrandrGetColorAttributes(NvCtrlAttributePrivateHandle *h,
+ReturnStatus NvCtrlXrandrGetColorAttributes(const NvCtrlAttributePrivateHandle *h,
float contrast[3],
float brightness[3],
float gamma[3]);
@@ -206,7 +250,7 @@ ReturnStatus NvCtrlXrandrSetColorAttributes(NvCtrlAttributePrivateHandle *h,
float g[3],
unsigned int bitmask);
-ReturnStatus NvCtrlXrandrGetColorRamp(NvCtrlAttributePrivateHandle *h,
+ReturnStatus NvCtrlXrandrGetColorRamp(const NvCtrlAttributePrivateHandle *h,
unsigned int channel,
uint16_t **lut,
int *n);
@@ -215,7 +259,7 @@ ReturnStatus NvCtrlXrandrReloadColorRamp(NvCtrlAttributePrivateHandle *h);
/* XF86 Video Mode extension attribute functions */
-ReturnStatus NvCtrlVidModeGetColorAttributes(NvCtrlAttributePrivateHandle *h,
+ReturnStatus NvCtrlVidModeGetColorAttributes(const NvCtrlAttributePrivateHandle *h,
float contrast[3],
float brightness[3],
float gamma[3]);
@@ -226,7 +270,7 @@ ReturnStatus NvCtrlVidModeSetColorAttributes(NvCtrlAttributePrivateHandle *h,
float g[3],
unsigned int bitmask);
-ReturnStatus NvCtrlVidModeGetColorRamp(NvCtrlAttributePrivateHandle *h,
+ReturnStatus NvCtrlVidModeGetColorRamp(const NvCtrlAttributePrivateHandle *h,
unsigned int channel,
uint16_t **lut,
int *n);
@@ -234,21 +278,26 @@ ReturnStatus NvCtrlVidModeGetColorRamp(NvCtrlAttributePrivateHandle *h,
ReturnStatus NvCtrlVidModeReloadColorRamp(NvCtrlAttributePrivateHandle *h);
ReturnStatus
-NvCtrlVidModeGetStringAttribute (NvCtrlAttributePrivateHandle *,
- unsigned int, int, char **);
+NvCtrlVidModeGetStringAttribute(const NvCtrlAttributePrivateHandle *,
+ unsigned int, int, char **);
ReturnStatus
-NvCtrlXrandrGetAttribute(NvCtrlAttributePrivateHandle *h,
+NvCtrlXrandrGetAttribute(const NvCtrlAttributePrivateHandle *h,
unsigned int display_mask, int attr, int64_t *val);
/* Generic attribute functions */
-ReturnStatus
-NvCtrlNvControlQueryTargetCount(NvCtrlAttributePrivateHandle *, int, int *);
+NvCtrlAttributeHandle *NvCtrlAttributeInit(CtrlSystem *system,
+ CtrlTargetType target_type,
+ int target_id,
+ unsigned int subsystems);
ReturnStatus
-NvCtrlNvControlGetAttribute (NvCtrlAttributePrivateHandle *, unsigned int,
- int, int64_t *);
+NvCtrlNvControlQueryTargetCount(const NvCtrlAttributePrivateHandle *, int,
+ int *);
+
+ReturnStatus NvCtrlNvControlGetAttribute(const NvCtrlAttributePrivateHandle *,
+ unsigned int, int, int64_t *);
ReturnStatus
NvCtrlNvControlSetAttribute (NvCtrlAttributePrivateHandle *, unsigned int,
@@ -259,26 +308,26 @@ NvCtrlNvControlSetAttributeWithReply (NvCtrlAttributePrivateHandle *,
unsigned int, int, int);
ReturnStatus
-NvCtrlNvControlGetValidAttributeValues (NvCtrlAttributePrivateHandle *,
- unsigned int, int,
- NVCTRLAttributeValidValuesRec *);
+NvCtrlNvControlGetValidAttributeValues(const NvCtrlAttributePrivateHandle *,
+ unsigned int, int,
+ NVCTRLAttributeValidValuesRec *);
ReturnStatus
NvCtrlNvControlGetValidStringDisplayAttributeValues
- (NvCtrlAttributePrivateHandle *,
+ (const NvCtrlAttributePrivateHandle *,
unsigned int, int,
NVCTRLAttributeValidValuesRec *);
ReturnStatus
-NvCtrlNvControlGetStringAttribute (NvCtrlAttributePrivateHandle *,
- unsigned int, int, char **);
+NvCtrlNvControlGetStringAttribute(const NvCtrlAttributePrivateHandle *,
+ unsigned int, int, char **);
ReturnStatus
NvCtrlNvControlSetStringAttribute (NvCtrlAttributePrivateHandle *,
- unsigned int, int, const char *, int *);
+ unsigned int, int, const char *);
ReturnStatus
-NvCtrlNvControlGetBinaryAttribute(NvCtrlAttributePrivateHandle *h,
+NvCtrlNvControlGetBinaryAttribute(const NvCtrlAttributePrivateHandle *h,
unsigned int display_mask, int attr,
unsigned char **data, int *len);
@@ -302,4 +351,8 @@ void NvCtrlAssignGammaInput(NvCtrlGammaInput *pGammaInput,
const float inGamma[3],
const unsigned int bitmask);
+/* NVML backend functions */
+ReturnStatus NvCtrlInitNvml(void);
+ReturnStatus NvCtrlDestroyNvml(void);
+
#endif /* __NVCTRL_ATTRIBUTES_PRIVATE__ */
diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c b/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c
new file mode 100644
index 0000000..f08fe08
--- /dev/null
+++ b/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c
@@ -0,0 +1,1097 @@
+/*
+ * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
+ * and Linux systems.
+ *
+ * Copyright (C) 2004 NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses>.
+ */
+
+/*
+ * query-assign.c - this source file contains functions for querying
+ * and assigning attributes, as specified on the command line. Some
+ * of this functionality is also shared with the config file
+ * reader/writer.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <X11/Xlib.h>
+
+#include "parse.h"
+#include "msg.h"
+#include "NvCtrlAttributes.h"
+#include "NvCtrlAttributesPrivate.h"
+
+
+
+/*!
+ * Queries the NV-CONTROL string attribute and returns the string as a simple
+ * char *. This is useful to avoid having to track how strings are allocated
+ * so we can cleanup all strings via nvfree().
+ *
+ * \param[in] t The CtrlTarget to query the string on.
+ * \param[in] attr The NV-CONTROL string to query.
+ *
+ * \return Return a nvalloc()'ed copy of the NV-CONTROL string; else, returns
+ * NULL.
+ */
+
+static char *query_x_name(const CtrlTarget *t, int attr)
+{
+ ReturnStatus status;
+ char *str = NULL;
+
+ status = NvCtrlGetStringAttribute(t, attr, &str);
+ if (status != NvCtrlSuccess) {
+ return NULL;
+ }
+
+ return str;
+}
+
+
+
+static void nv_free_ctrl_target(CtrlTarget *target)
+{
+ int i;
+
+ if (!target) {
+ return;
+ }
+
+ NvCtrlAttributeClose(target->h);
+ target->h = NULL;
+
+ free(target->name);
+ target->name = NULL;
+
+ for (i = 0; i < NV_PROTO_NAME_MAX; i++) {
+ free(target->protoNames[i]);
+ target->protoNames[i] = NULL;
+ }
+
+ NvCtrlTargetListFree(target->relations);
+ target->relations = NULL;
+
+ nvfree(target);
+}
+
+
+
+static void nv_free_ctrl_system(CtrlSystem *system)
+{
+ int target_type;
+
+ if (!system) {
+ return;
+ }
+
+ /* close the X connection */
+
+ if (system->dpy) {
+ /*
+ * XXX It is unfortunate that the display connection needs
+ * to be closed before the backends have had a chance to
+ * tear down their state. If future backends need to send
+ * protocol in this case or perform similar tasks, we'll
+ * have to add e.g. NvCtrlAttributeTearDown(), which would
+ * need to be called before XCloseDisplay().
+ */
+ XCloseDisplay(system->dpy);
+ system->dpy = NULL;
+ }
+
+ /* cleanup targets */
+
+ for (target_type = 0;
+ target_type < MAX_TARGET_TYPES;
+ target_type++) {
+ while (system->targets[target_type]) {
+ CtrlTargetNode *node = system->targets[target_type];
+
+ system->targets[target_type] = node->next;
+
+ nv_free_ctrl_target(node->t);
+ nvfree(node);
+ }
+ }
+
+ /* cleanup physical screens */
+
+ while (system->physical_screens) {
+ CtrlTargetNode *node = system->physical_screens;
+
+ system->physical_screens = node->next;
+
+ nv_free_ctrl_target(node->t);
+ nvfree(node);
+ }
+
+ /* cleanup everything else */
+
+ free(system->display);
+ system->display = NULL;
+
+ free(system);
+
+ NvCtrlDestroyNvml();
+}
+
+
+
+void NvCtrlFreeAllSystems(CtrlSystemList *systems)
+{
+ int i;
+
+ if (!systems) {
+ return;
+ }
+
+ for (i = 0; i < systems->n; i++) {
+ nv_free_ctrl_system(systems->array[i]);
+ }
+
+ free(systems->array);
+ systems->array = NULL;
+ systems->n = 0;
+}
+
+
+
+/*!
+ * Retrieves and adds all the display device names for the given target.
+ *
+ * \param[in/out] t The CtrlTarget to load names for.
+ */
+
+static void load_display_target_proto_names(CtrlTarget *t)
+{
+ t->protoNames[NV_DPY_PROTO_NAME_TYPE_BASENAME] =
+ query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME);
+
+ t->protoNames[NV_DPY_PROTO_NAME_TYPE_ID] =
+ query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID);
+
+ t->protoNames[NV_DPY_PROTO_NAME_DP_GUID] =
+ query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_DP_GUID);
+
+ t->protoNames[NV_DPY_PROTO_NAME_EDID_HASH] =
+ query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_EDID_HASH);
+
+ t->protoNames[NV_DPY_PROTO_NAME_TARGET_INDEX] =
+ query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_TARGET_INDEX);
+
+ t->protoNames[NV_DPY_PROTO_NAME_RANDR] =
+ query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_RANDR);
+}
+
+
+
+/*!
+ * Adds the default name for the given target to the list of protocol names at
+ * the given proto name index.
+ *
+ * \param[in/out] t The CtrlTarget to load names for.
+ * \param[in] proto_idx The name index where to add the name.
+ */
+
+static void load_default_target_proto_name(CtrlTarget *t,
+ const int proto_idx)
+{
+ if (proto_idx >= NV_PROTO_NAME_MAX) {
+ return;
+ }
+
+ t->protoNames[proto_idx] = nvasprintf("%s-%d",
+ t->targetTypeInfo->parsed_name,
+ NvCtrlGetTargetId(t));
+ nvstrtoupper(t->protoNames[proto_idx]);
+}
+
+
+
+/*!
+ * Adds the GPU names to the given target to the list of protocol names.
+ *
+ * \param[in/out] t The CtrlTarget to load names for.
+ */
+
+static void load_gpu_target_proto_names(CtrlTarget *t)
+{
+ load_default_target_proto_name(t, NV_GPU_PROTO_NAME_TYPE_ID);
+
+ t->protoNames[NV_GPU_PROTO_NAME_UUID] =
+ query_x_name(t, NV_CTRL_STRING_GPU_UUID);
+}
+
+
+
+/*!
+ * Adds the all the appropriate names for the given target to the list of
+ * protocol names.
+ *
+ * \param[in/out] t The CtrlTarget to load names for.
+ */
+
+static void load_target_proto_names(CtrlTarget *t)
+{
+ switch (NvCtrlGetTargetType(t)) {
+ case DISPLAY_TARGET:
+ load_display_target_proto_names(t);
+ break;
+
+ case GPU_TARGET:
+ load_gpu_target_proto_names(t);
+ break;
+
+ default:
+ load_default_target_proto_name(t, 0);
+ break;
+ }
+}
+
+
+
+int NvCtrlGetTargetTypeCount(const CtrlSystem *system, CtrlTargetType target_type)
+{
+ int count = 0;
+ CtrlTargetNode *node;
+
+ if (!system || !NvCtrlIsTargetTypeValid(target_type)) {
+ return 0;
+ }
+
+ for (node = system->targets[target_type]; node; node = node->next) {
+ count++;
+ }
+
+ return count;
+}
+
+
+
+/*!
+ * Returns the CtrlTarget from a CtrlSystem with the given target type/
+ * target id.
+ *
+ * \param[in] system Container for all the CtrlTargets to search.
+ * \param[in] target_type The target type of the CtrlTarget to search.
+ * \param[in] target_id The target id of the CtrlTarget to search.
+ *
+ * \return Returns the matching CtrlTarget from CtrlSystem on success;
+ * else, returns NULL.
+ */
+
+CtrlTarget *NvCtrlGetTarget(const CtrlSystem *system,
+ CtrlTargetType target_type,
+ int target_id)
+{
+ CtrlTargetNode *node;
+
+ if (!system || !NvCtrlIsTargetTypeValid(target_type)) {
+ return NULL;
+ }
+
+ for (node = system->targets[target_type];
+ node;
+ node = node->next) {
+ CtrlTarget *target = node->t;
+ if (NvCtrlGetTargetId(target) == target_id) {
+ return target;
+ }
+ }
+
+ return NULL;
+}
+
+
+/*!
+ * Returns the RandR name of the matching display target from the given
+ * target ID and the list of target handles.
+ *
+ * \param[in] system Container for all the CtrlTargets to search.
+ * \param[in] target_id The target id of the display CtrlTarget to search.
+ *
+ * \return Returns the NV_DPY_PROTO_NAME_RANDR name string from the matching
+ * (display) CtrlTarget from CtrlSystem on success; else, returns NULL.
+ */
+const char *NvCtrlGetDisplayConfigName(const CtrlSystem *system, int target_id)
+{
+ CtrlTarget *target;
+
+ target = NvCtrlGetTarget(system, DISPLAY_TARGET, target_id);
+ if (!target) {
+ return NULL;
+ }
+
+ return target->protoNames[NV_DPY_PROTO_NAME_RANDR];
+}
+
+
+/*!
+ * Returns any CtrlTarget of the specified target type from the CtrlSystem that
+ * can be used to communicate with the system.
+ */
+
+CtrlTarget *NvCtrlGetDefaultTargetByType(const CtrlSystem *system,
+ CtrlTargetType target_type)
+{
+ CtrlTargetNode *node;
+
+ if (!system || !NvCtrlIsTargetTypeValid(target_type)) {
+ return NULL;
+ }
+
+ for (node = system->targets[target_type]; node; node = node->next) {
+ CtrlTarget *target = node->t;
+
+ if (target->h) {
+ return target;
+ }
+ }
+
+ return NULL;
+}
+
+
+/*!
+ * Returns any CtrlTarget from the CtrlSystem that can be used
+ * to communicate with the system.
+ */
+
+CtrlTarget *NvCtrlGetDefaultTarget(const CtrlSystem *system)
+{
+ int i;
+
+ if (!system) {
+ return NULL;
+ }
+
+ for (i = 0; i < MAX_TARGET_TYPES; i++) {
+ CtrlTarget *target = NvCtrlGetDefaultTargetByType(system, i);
+
+ if (target) {
+ return target;
+ }
+ }
+
+ return NULL;
+}
+
+
+
+/*!
+ * Appends the given CtrlTarget to the end of the CtrlTarget list 'head' if
+ * it is not already in the list.
+ *
+ * \param[in/out] head The first node in the CtrlTarget list, to which
+ * target should be inserted.
+ * \param[in] target The CtrlTarget to add to the list.
+ * \param[in] enabled_display_check Whether or not to check that, if the
+ * target is a display target, it is also
+ * enabled.
+ */
+
+void NvCtrlTargetListAdd(CtrlTargetNode **head, CtrlTarget *target,
+ Bool enabled_display_check)
+{
+ CtrlTargetNode *new_t;
+ CtrlTargetNode *t;
+
+ /* Do not add disabled displays to the list */
+ if (enabled_display_check) {
+ if ((NvCtrlGetTargetType(target) == DISPLAY_TARGET) &&
+ !target->display.enabled) {
+ return;
+ }
+ }
+
+ new_t = nvalloc(sizeof(*new_t));
+ new_t->t = target;
+
+ t = *head;
+
+ /* List is empty */
+ if (!t) {
+ *head = new_t;
+ return;
+ }
+
+ while (1) {
+ if (t->t == target) {
+ nvfree(new_t);
+ return;
+ }
+ if (!t->next) {
+ t->next = new_t;
+ return;
+ }
+ t = t->next;
+ }
+}
+
+
+
+/*!
+ * Frees the memory used for tracking a list of CtrlTargets.
+ *
+ * \param[in\out] head The first node in the CtrlTarget list that is to be
+ * freed.
+ */
+
+void NvCtrlTargetListFree(CtrlTargetNode *head)
+{
+ CtrlTargetNode *n;
+
+ while (head) {
+ n = head->next;
+ free(head);
+ head = n;
+ }
+}
+
+
+
+/*!
+ * Adds all the targets of target type relating to 'target_type' that are
+ * known to be associated to 'target' by querying the list of associated targets
+ * for the given attribute association 'attr'. If implicit_reciprocal is set,
+ * the relatiopship is added to the relating target(s).
+ *
+ * \param[in\out] target The target to which association(s) are
+ * being made.
+ * \param[in] target_type The target type of the associated
+ * targets being considered (queried.)
+ * \param[in] attr The NV-CONTROL binary attribute that
+ * should be queried to retrieve the list
+ * of 'targetType' targets that are
+ * associated to the (CtrlTarget) target
+ * 't'.
+ * \param[in] implicit_reciprocal Whether or not to reciprocally add the
+ * reverse relationship to the matching
+ * targets.
+ */
+
+static void add_target_relationships(CtrlTarget *target,
+ CtrlTargetType target_type, int attr,
+ int implicit_reciprocal)
+{
+ ReturnStatus status;
+ int *pData;
+ int len;
+ int i;
+
+ status = NvCtrlGetBinaryAttribute(target, 0, attr,
+ (unsigned char **)(&pData), &len);
+ if ((status != NvCtrlSuccess) || !pData) {
+ nv_error_msg("Error querying target relations");
+ return;
+ }
+
+ for (i = 0; i < pData[0]; i++) {
+ int target_id = pData[i+1];
+ CtrlTarget *other;
+
+ other = NvCtrlGetTarget(target->system, target_type, target_id);
+ if (other) {
+ NvCtrlTargetListAdd(&(target->relations), other, FALSE);
+
+ /* Track connection state of display devices */
+ if (attr == NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU) {
+ other->display.connected = NV_TRUE;
+ }
+
+ if (implicit_reciprocal == NV_TRUE) {
+ NvCtrlTargetListAdd(&(other->relations), target, FALSE);
+ }
+ }
+ }
+
+ free(pData);
+}
+
+
+
+/*!
+ * Adds all associations to/from an X screen target.
+ *
+ * \param[in\out] target The X screen target to which association(s) are
+ * being made.
+ */
+
+static void load_screen_target_relationships(CtrlTarget *target)
+{
+ add_target_relationships(target, GPU_TARGET,
+ NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN,
+ NV_TRUE);
+ add_target_relationships(target, DISPLAY_TARGET,
+ NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN,
+ NV_TRUE);
+}
+
+
+
+/*!
+ * Adds all associations to/from a GPU target.
+ *
+ * \param[in\out] target The GPU target to which association(s) are being
+ * made.
+ */
+
+static void load_gpu_target_relationships(CtrlTarget *target)
+{
+ add_target_relationships(target, FRAMELOCK_TARGET,
+ NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU,
+ NV_FALSE);
+ add_target_relationships(target, VCS_TARGET,
+ NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU,
+ NV_FALSE);
+ add_target_relationships(target, COOLER_TARGET,
+ NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU,
+ NV_TRUE);
+ add_target_relationships(target, THERMAL_SENSOR_TARGET,
+ NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU,
+ NV_TRUE);
+ add_target_relationships(target, DISPLAY_TARGET,
+ NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU,
+ NV_TRUE);
+ add_target_relationships(target, DISPLAY_TARGET,
+ NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU,
+ NV_TRUE);
+}
+
+
+
+/*!
+ * Adds all associations to/from a FrameLock target.
+ *
+ * \param[in\out] target The FrameLock target to which association(s) are
+ * being made.
+ */
+
+static void load_framelock_target_relationships(CtrlTarget *target)
+{
+ add_target_relationships(target, GPU_TARGET,
+ NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK,
+ NV_FALSE);
+}
+
+
+
+/*!
+ * Adds all associations to/from a VCS target.
+ *
+ * \param[in\out] target The VCS target to which association(s) are being
+ * made.
+ */
+
+static void load_vcs_target_relationships(CtrlTarget *target)
+{
+ add_target_relationships(target, GPU_TARGET,
+ NV_CTRL_BINARY_DATA_GPUS_USING_VCSC,
+ NV_FALSE);
+}
+
+
+
+/*!
+ * Adds all associations to/from a target.
+ *
+ * \param[in\out] target The target to which association(s) are being made.
+ */
+
+static void load_target_relationships(CtrlTarget *target)
+{
+ switch (NvCtrlGetTargetType(target)) {
+ case X_SCREEN_TARGET:
+ load_screen_target_relationships(target);
+ break;
+
+ case GPU_TARGET:
+ load_gpu_target_relationships(target);
+ break;
+
+ case FRAMELOCK_TARGET:
+ load_framelock_target_relationships(target);
+ break;
+
+ case VCS_TARGET:
+ load_vcs_target_relationships(target);
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+
+/*
+ * nv_alloc_ctrl_target() - Given the Display pointer, create an attribute
+ * handle and initialize the handle target.
+ */
+
+static CtrlTarget *nv_alloc_ctrl_target(CtrlSystem *system,
+ CtrlTargetType target_type,
+ int targetId,
+ int subsystem)
+{
+ CtrlTarget *t;
+ NvCtrlAttributeHandle *handle;
+ ReturnStatus status;
+ char *tmp;
+ int len, d, c;
+ const CtrlTargetTypeInfo *targetTypeInfo;
+
+
+ if (!system || !NvCtrlIsTargetTypeValid(target_type)) {
+ return NULL;
+ }
+
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(target_type);
+
+ /* allocate the handle */
+
+ handle = NvCtrlAttributeInit(system, target_type, targetId, subsystem);
+
+ /*
+ * silently fail: this might happen if not all X screens
+ * are NVIDIA X screens
+ */
+
+ if (!handle) {
+ return NULL;
+ }
+
+ t = nvalloc(sizeof(*t));
+ t->h = handle;
+ t->system = system;
+ t->targetTypeInfo = targetTypeInfo;
+
+ /*
+ * get a name for this target; in the case of
+ * X_SCREEN_TARGET targets, just use the string returned
+ * from NvCtrlGetDisplayName(); for other target types,
+ * append a target specification.
+ */
+
+ tmp = NvCtrlGetDisplayName(t);
+
+ if (target_type == X_SCREEN_TARGET) {
+ t->name = tmp;
+ } else {
+ if (tmp == NULL) {
+ tmp = strdup("");
+ }
+
+ len = strlen(tmp) + strlen(targetTypeInfo->parsed_name)
+ + 16;
+ t->name = nvalloc(len);
+
+ if (t->name) {
+ snprintf(t->name, len, "%s[%s:%d]",
+ tmp, targetTypeInfo->parsed_name, targetId);
+ free(tmp);
+ } else {
+ t->name = tmp;
+ }
+ }
+
+ load_target_proto_names(t);
+ t->relations = NULL;
+
+ if (target_type == DISPLAY_TARGET) {
+ status = NvCtrlGetAttribute(t, NV_CTRL_DISPLAY_ENABLED, &d);
+ if (status != NvCtrlSuccess) {
+ nv_error_msg("Error querying enabled state of display %s %d (%s).",
+ targetTypeInfo->name, targetId,
+ NvCtrlAttributesStrError(status));
+ d = NV_CTRL_DISPLAY_ENABLED_FALSE;
+ }
+ t->display.enabled = (d == NV_CTRL_DISPLAY_ENABLED_TRUE) ? 1 : 0;
+ }
+
+
+ /*
+ * get the enabled display device mask; for X screens and
+ * GPUs we query NV-CONTROL; for anything else
+ * (framelock), we just assign this to 0.
+ */
+
+ if (targetTypeInfo->uses_display_devices) {
+
+ status = NvCtrlGetAttribute(t,
+ NV_CTRL_ENABLED_DISPLAYS, &d);
+
+ if (status != NvCtrlSuccess) {
+ nv_error_msg("Error querying enabled displays on "
+ "%s %d (%s).", targetTypeInfo->name,
+ targetId,
+ NvCtrlAttributesStrError(status));
+ d = 0;
+ }
+
+ status = NvCtrlGetAttribute(t,
+ NV_CTRL_CONNECTED_DISPLAYS, &c);
+
+ if (status != NvCtrlSuccess) {
+ nv_error_msg("Error querying connected displays on "
+ "%s %d (%s).", targetTypeInfo->name,
+ targetId,
+ NvCtrlAttributesStrError(status));
+ c = 0;
+ }
+ } else {
+ d = 0;
+ c = 0;
+ }
+
+ t->d = d;
+ t->c = c;
+
+ return t;
+}
+
+
+/*
+ * nv_add_target() - add a CtrlTarget of the given target type to the list of
+ * Targets for the given CtrlSystem.
+ */
+
+CtrlTarget *nv_add_target(CtrlSystem *system, CtrlTargetType target_type,
+ int target_id)
+{
+ CtrlTarget *target;
+ target = nv_alloc_ctrl_target(system, target_type, target_id,
+ NV_CTRL_ATTRIBUTES_ALL_SUBSYSTEMS);
+ if (!target) {
+ return NULL;
+ }
+
+ NvCtrlTargetListAdd(&(system->targets[target_type]), target, FALSE);
+
+ return target;
+}
+
+
+/*
+ * Returns whether the NV-CONTROL protocol version is equal or greater than
+ * 'major'.'minor'
+ */
+
+static Bool is_nvcontrol_protocol_valid(const CtrlTarget *ctrl_target,
+ int major, int minor)
+{
+ ReturnStatus ret1, ret2;
+ int nv_major, nv_minor;
+
+ ret1 = NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_ATTR_NV_MAJOR_VERSION,
+ &nv_major);
+ ret2 = NvCtrlGetAttribute(ctrl_target,
+ NV_CTRL_ATTR_NV_MINOR_VERSION,
+ &nv_minor);
+
+ if ((ret1 == NvCtrlSuccess) && (ret2 == NvCtrlSuccess) &&
+ ((nv_major > major) || ((nv_major == major) && (nv_minor >= minor)))) {
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+static Bool load_system_info(CtrlSystem *system, const char *display)
+{
+ ReturnStatus status;
+ CtrlTarget *xscreenQueryTarget = NULL;
+ int i, target_type, val, len, target_count;
+ int *pData = NULL;
+ const CtrlTargetTypeInfo *targetTypeInfo;
+ Bool nvml_found;
+
+ if (!system) {
+ return FALSE;
+ }
+
+ if (display) {
+ system->display = strdup(display);
+ } else {
+ system->display = NULL;
+ }
+
+ /* Try to open the X display connection */
+ system->dpy = XOpenDisplay(system->display);
+
+ /* Try to initialize the NVML library */
+ nvml_found = (NvCtrlInitNvml() == NvCtrlSuccess);
+
+ if (system->dpy == NULL && !nvml_found) {
+ nv_error_msg("Unable to load info from any available system");
+ return FALSE;
+ }
+
+ /*
+ * loop over each target type and setup the appropriate
+ * information
+ */
+
+ for (target_type = 0;
+ target_type < MAX_TARGET_TYPES;
+ target_type++) {
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(target_type);
+ target_count = 0;
+
+ /*
+ * get the number of targets of this type; if this is an X
+ * screen target, just use Xlib's ScreenCount() (note: to
+ * support Xinerama: we'll want to use
+ * NvCtrlQueryTargetCount() rather than ScreenCount()); for
+ * other target types, use NvCtrlQueryTargetCount().
+ */
+
+ if (target_type == X_SCREEN_TARGET) {
+ if (system->dpy != NULL) {
+ target_count = ScreenCount(system->dpy);
+ }
+ }
+ else {
+
+ /*
+ * note: xscreenQueryTarget should be assigned below by a
+ * previous iteration of this loop; depends on X screen
+ * targets getting handled first
+ */
+
+ if (xscreenQueryTarget) {
+
+ /*
+ * check that the NV-CONTROL protocol is new enough to
+ * recognize this target type
+ */
+
+ if (is_nvcontrol_protocol_valid(xscreenQueryTarget,
+ targetTypeInfo->major,
+ targetTypeInfo->minor)) {
+
+ if (target_type != DISPLAY_TARGET) {
+ status = NvCtrlQueryTargetCount(xscreenQueryTarget,
+ target_type,
+ &val);
+ } else {
+ /* For targets that aren't simply enumerated,
+ * query the list of valid IDs in pData which
+ * will be used below
+ */
+ status =
+ NvCtrlGetBinaryAttribute(xscreenQueryTarget, 0,
+ NV_CTRL_BINARY_DATA_DISPLAY_TARGETS,
+ (unsigned char **)(&pData), &len);
+ if (status == NvCtrlSuccess) {
+ val = pData[0];
+ }
+ }
+ } else {
+ status = NvCtrlMissingExtension;
+ }
+ } else {
+ status = NvCtrlMissingExtension;
+ }
+
+ if (status != NvCtrlSuccess) {
+ nv_warning_msg("Unable to determine number of NVIDIA "
+ "%ss on '%s'.",
+ targetTypeInfo->name,
+ XDisplayName(system->display));
+ val = 0;
+ }
+
+ target_count = val;
+ }
+
+ /* Add all the targets of this type to the CtrlSystem */
+
+ for (i = 0; i < target_count; i++) {
+ int targetId;
+ CtrlTarget *target;
+
+ switch (target_type) {
+ case DISPLAY_TARGET:
+ /* Grab the target Id from the pData list */
+ targetId = pData[i+1];
+ break;
+ case X_SCREEN_TARGET:
+ case GPU_TARGET:
+ case FRAMELOCK_TARGET:
+ case VCS_TARGET:
+ case GVI_TARGET:
+ case COOLER_TARGET:
+ case THERMAL_SENSOR_TARGET:
+ case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET:
+ default:
+ targetId = i;
+ }
+
+ target = nv_add_target(system, target_type, targetId);
+
+ /*
+ * store this handle, if it exists, so that we can use it to
+ * query other target counts later
+ */
+
+ if (!xscreenQueryTarget && (target_type == X_SCREEN_TARGET) &&
+ target && target->h) {
+
+ xscreenQueryTarget = target;
+ }
+ }
+
+ free(pData);
+ pData = NULL;
+ }
+
+ /*
+ * setup the appropriate information for physical screens
+ */
+
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(X_SCREEN_TARGET);
+
+ if (xscreenQueryTarget) {
+
+ /*
+ * check that the NV-CONTROL protocol is new enough to
+ * recognize this target type
+ */
+
+ if (is_nvcontrol_protocol_valid(xscreenQueryTarget,
+ targetTypeInfo->major,
+ targetTypeInfo->minor)) {
+
+ status = NvCtrlQueryTargetCount(xscreenQueryTarget,
+ X_SCREEN_TARGET,
+ &val);
+ } else {
+ status = NvCtrlMissingExtension;
+ }
+ } else {
+ status = NvCtrlMissingExtension;
+ }
+
+ if (status != NvCtrlSuccess) {
+ nv_warning_msg("Unable to determine number of NVIDIA %ss on '%s'.",
+ targetTypeInfo->name, XDisplayName(system->display));
+ val = 0;
+ }
+
+ target_count = val;
+
+ for (i = 0; i < target_count; i++) {
+ CtrlTarget *target;
+ target = nv_alloc_ctrl_target(system, X_SCREEN_TARGET, i,
+ NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM);
+ if (!target) {
+ continue;
+ }
+
+ NvCtrlTargetListAdd(&(system->physical_screens), target, FALSE);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * nv_alloc_ctrl_system() - allocate a new CtrlSystem structure, connect to the
+ * system (via X server identified by display), and discover/allocate/
+ * initialize all the targets (GPUs, screens, Frame Lock devices, etc) found.
+ */
+
+static CtrlSystem *nv_alloc_ctrl_system(const char *display)
+{
+ CtrlSystem *system;
+ Bool ret;
+ int i;
+
+ system = nvalloc(sizeof(*system));
+
+ /* Connect to the system and load target information */
+
+ ret = load_system_info(system, display);
+
+ if (!ret) {
+ nv_free_ctrl_system(system);
+ return NULL;
+ }
+
+ /* Discover target relationships */
+
+ for (i = 0; i < MAX_TARGET_TYPES; i++) {
+ CtrlTargetNode *node;
+ for (node = system->targets[i]; node; node = node->next) {
+ load_target_relationships(node->t);
+ }
+ }
+
+ return system;
+
+} /* nv_alloc_ctrl_system() */
+
+
+
+/*
+ * Connect to (and track) a system, returning its control handles (for
+ * configuration). If a connection was already made, return that connection's
+ * handles.
+ */
+
+CtrlSystem *NvCtrlConnectToSystem(const char *display, CtrlSystemList *systems)
+{
+ CtrlSystem *system = NvCtrlGetSystem(display, systems);
+
+ if (system == NULL) {
+ system = nv_alloc_ctrl_system(display);
+
+ if (system) {
+ system->system_list = systems;
+ systems->array = nvrealloc(systems->array,
+ sizeof(*(systems->array))
+ * (systems->n + 1));
+ systems->array[systems->n] = system;
+ systems->n++;
+ }
+ }
+
+ return system;
+}
+
+
+/*
+ * Return the CtrlSystem matching the given string.
+ */
+CtrlSystem *NvCtrlGetSystem(const char *display, CtrlSystemList *systems)
+{
+ int i;
+
+ for (i=0; i < systems->n; i++) {
+ CtrlSystem *system = systems->array[i];
+
+ if (nv_strcasecmp(display, system->display)) {
+ return system;
+ }
+ }
+
+ return NULL;
+}
diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesVidMode.c b/src/libXNVCtrlAttributes/NvCtrlAttributesVidMode.c
index 127d83f..c2225c2 100644
--- a/src/libXNVCtrlAttributes/NvCtrlAttributesVidMode.c
+++ b/src/libXNVCtrlAttributes/NvCtrlAttributesVidMode.c
@@ -37,7 +37,7 @@ NvCtrlInitVidModeAttributes(NvCtrlAttributePrivateHandle *h)
Bool ret;
/* Check parameters */
- if (!h || !h->dpy || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (!h || !h->dpy || h->target_type != X_SCREEN_TARGET) {
goto failed;
}
@@ -118,7 +118,7 @@ ReturnStatus NvCtrlFreeVidModeAttributes(NvCtrlAttributePrivateHandle *h)
}
-ReturnStatus NvCtrlVidModeGetColorAttributes(NvCtrlAttributePrivateHandle *h,
+ReturnStatus NvCtrlVidModeGetColorAttributes(const NvCtrlAttributePrivateHandle *h,
float contrast[3],
float brightness[3],
float gamma[3])
@@ -135,15 +135,15 @@ ReturnStatus NvCtrlVidModeGetColorAttributes(NvCtrlAttributePrivateHandle *h,
return NvCtrlSuccess;
-} /* NvCtrlGetColorAttributes() */
+}
/*
- * NvCtrlSetColorAttributes() - update the color attributes specified
- * by bitmask, recompute the LUT, and send the LUT to the X server.
+ * Update the color attributes specified by bitmask, recompute the LUT,
+ * and send the LUT to the X server.
*
* The bitmask parameter is a bitmask of which channels (RED_CHANNEL,
* GREEN_CHANNEL, and BLUE_CHANNEL) and which values (CONTRAST_VALUE,
@@ -165,7 +165,7 @@ ReturnStatus NvCtrlVidModeSetColorAttributes(NvCtrlAttributePrivateHandle *h,
{
Bool ret;
- if (!h || !h->dpy || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (!h || !h->dpy || h->target_type != X_SCREEN_TARGET) {
return NvCtrlBadHandle;
}
@@ -189,12 +189,12 @@ ReturnStatus NvCtrlVidModeSetColorAttributes(NvCtrlAttributePrivateHandle *h,
}
-ReturnStatus NvCtrlVidModeGetColorRamp(NvCtrlAttributePrivateHandle *h,
+ReturnStatus NvCtrlVidModeGetColorRamp(const NvCtrlAttributePrivateHandle *h,
unsigned int channel,
unsigned short **lut,
int *n)
{
- if (!h || !h->dpy || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (!h || !h->dpy || h->target_type != X_SCREEN_TARGET) {
return NvCtrlBadHandle;
}
if (!h->vm) {
@@ -227,12 +227,12 @@ ReturnStatus NvCtrlVidModeReloadColorRamp(NvCtrlAttributePrivateHandle *h)
*/
ReturnStatus
-NvCtrlVidModeGetStringAttribute (NvCtrlAttributePrivateHandle *h,
- unsigned int display_mask,
- int attr, char **ptr)
+NvCtrlVidModeGetStringAttribute(const NvCtrlAttributePrivateHandle *h,
+ unsigned int display_mask,
+ int attr, char **ptr)
{
/* Validate */
- if ( !h || !h->dpy || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN ) {
+ if ( !h || !h->dpy || h->target_type != X_SCREEN_TARGET ) {
return NvCtrlBadHandle;
}
diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c b/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c
index 8ab0315..f28d759 100644
--- a/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c
+++ b/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c
@@ -191,6 +191,7 @@ static void close_libxrandr(void)
static RROutput GetRandRCrtcForGamma(NvCtrlAttributePrivateHandle *h,
NvCtrlXrandrAttributes *xrandr)
{
+ int64_t output_64;
int output;
RRCrtc crtc;
ReturnStatus status;
@@ -199,7 +200,7 @@ static RROutput GetRandRCrtcForGamma(NvCtrlAttributePrivateHandle *h,
/* finding the RandR output only makes sense for display targets */
- if (h->target_type != NV_CTRL_TARGET_TYPE_DISPLAY) {
+ if (h->target_type != DISPLAY_TARGET) {
return None;
}
@@ -219,12 +220,15 @@ static RROutput GetRandRCrtcForGamma(NvCtrlAttributePrivateHandle *h,
return None;
}
- status = NvCtrlGetAttribute(h, NV_CTRL_DISPLAY_RANDR_OUTPUT_ID, &output);
+ status = NvCtrlNvControlGetAttribute(h, 0, NV_CTRL_DISPLAY_RANDR_OUTPUT_ID,
+ &output_64);
if (status != NvCtrlSuccess) {
return None;
}
+ output = (int)output_64;
+
if (output == 0) {
return None;
}
@@ -279,8 +283,8 @@ NvCtrlInitXrandrAttributes (NvCtrlAttributePrivateHandle *h)
}
/* allow RandR on X_SCREEN and DISPLAY target types */
- if ((h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN) &&
- (h->target_type != NV_CTRL_TARGET_TYPE_DISPLAY)) {
+ if ((h->target_type != X_SCREEN_TARGET) &&
+ (h->target_type != DISPLAY_TARGET)) {
goto fail;
}
@@ -312,7 +316,7 @@ NvCtrlInitXrandrAttributes (NvCtrlAttributePrivateHandle *h)
}
/* Register to receive XRandR events if this is an X screen */
- if (h->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (h->target_type == X_SCREEN_TARGET) {
__libXrandr->XRRSelectInput(h->dpy, RootWindow(h->dpy, h->target_id),
RRScreenChangeNotifyMask);
}
@@ -362,7 +366,7 @@ void
NvCtrlXrandrAttributesClose (NvCtrlAttributePrivateHandle *h)
{
/* Check parameters */
- if ( !h || !h->xrandr || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN ) {
+ if ( !h || !h->xrandr || h->target_type != X_SCREEN_TARGET ) {
return;
}
@@ -385,12 +389,12 @@ NvCtrlXrandrAttributesClose (NvCtrlAttributePrivateHandle *h)
*/
ReturnStatus
-NvCtrlXrandrGetStringAttribute (NvCtrlAttributePrivateHandle *h,
- unsigned int display_mask,
- int attr, char **ptr)
+NvCtrlXrandrGetStringAttribute(const NvCtrlAttributePrivateHandle *h,
+ unsigned int display_mask,
+ int attr, char **ptr)
{
/* Validate */
- if ( !h || !h->dpy || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN ) {
+ if ( !h || !h->dpy || h->target_type != X_SCREEN_TARGET ) {
return NvCtrlBadHandle;
}
@@ -412,7 +416,7 @@ NvCtrlXrandrGetStringAttribute (NvCtrlAttributePrivateHandle *h,
ReturnStatus
-NvCtrlXrandrGetAttribute(NvCtrlAttributePrivateHandle *h,
+NvCtrlXrandrGetAttribute(const NvCtrlAttributePrivateHandle *h,
unsigned int display_mask, int attr, int64_t *val)
{
if (!h || !h->xrandr) {
@@ -423,7 +427,7 @@ NvCtrlXrandrGetAttribute(NvCtrlAttributePrivateHandle *h,
return NvCtrlNoAttribute;
}
- if (h->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) {
+ if (h->target_type == X_SCREEN_TARGET) {
*val = h->xrandr->gammaAvailable;
} else {
*val = (h->xrandr->pGammaRamp != NULL);
@@ -432,7 +436,7 @@ NvCtrlXrandrGetAttribute(NvCtrlAttributePrivateHandle *h,
return NvCtrlSuccess;
}
-ReturnStatus NvCtrlXrandrGetColorAttributes(NvCtrlAttributePrivateHandle *h,
+ReturnStatus NvCtrlXrandrGetColorAttributes(const NvCtrlAttributePrivateHandle *h,
float contrast[3],
float brightness[3],
float gamma[3])
@@ -494,7 +498,7 @@ ReturnStatus NvCtrlXrandrSetColorAttributes(NvCtrlAttributePrivateHandle *h,
return NvCtrlSuccess;
}
-ReturnStatus NvCtrlXrandrGetColorRamp(NvCtrlAttributePrivateHandle *h,
+ReturnStatus NvCtrlXrandrGetColorRamp(const NvCtrlAttributePrivateHandle *h,
unsigned int channel,
uint16_t **lut,
int *n)
diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesXv.c b/src/libXNVCtrlAttributes/NvCtrlAttributesXv.c
index ee56907..09ae46c 100644
--- a/src/libXNVCtrlAttributes/NvCtrlAttributesXv.c
+++ b/src/libXNVCtrlAttributes/NvCtrlAttributesXv.c
@@ -153,7 +153,7 @@ NvCtrlXvAttributes * NvCtrlInitXvAttributes(NvCtrlAttributePrivateHandle *h)
/* Check parameters */
- if ( !h || !h->dpy || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN ) {
+ if ( !h || !h->dpy || h->target_type != X_SCREEN_TARGET ) {
goto fail;
}
@@ -221,13 +221,12 @@ NvCtrlXvAttributes * NvCtrlInitXvAttributes(NvCtrlAttributePrivateHandle *h)
* Get Xv String Attribute values
*/
-ReturnStatus
-NvCtrlXvGetStringAttribute(NvCtrlAttributePrivateHandle *h,
- unsigned int display_mask,
- int attr, char **ptr)
+ReturnStatus NvCtrlXvGetStringAttribute(const NvCtrlAttributePrivateHandle *h,
+ unsigned int display_mask,
+ int attr, char **ptr)
{
/* Validate */
- if ( !h || !h->dpy || h->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN ) {
+ if ( !h || !h->dpy || h->target_type != X_SCREEN_TARGET ) {
return NvCtrlBadHandle;
}
if ( !h->xv || !__libXv ) {
diff --git a/src/nvidia-settings.c b/src/nvidia-settings.c
index 5f2438b..417fc36 100644
--- a/src/nvidia-settings.c
+++ b/src/nvidia-settings.c
@@ -23,48 +23,269 @@
#include "config-file.h"
#include "query-assign.h"
#include "msg.h"
+#include "version.h"
-#include "ctkui.h"
-
+#include <dlfcn.h>
+#include <sys/stat.h>
+#include <getopt.h>
+#include <string.h>
#include <stdlib.h>
+static const char* library_names[] = {
+ "libnvidia-gtk3.so." NVIDIA_VERSION,
+ "libnvidia-gtk3.so",
+ "libnvidia-gtk2.so." NVIDIA_VERSION,
+ "libnvidia-gtk2.so",
+};
+
+typedef struct {
+ void *gui_lib_handle;
+ char *error_msg;
+
+ int (*fn_ctk_init_check)(int *, char **[]);
+ char *(*fn_ctk_get_display)(void);
+ void (*fn_ctk_main)(ParsedAttribute *, ConfigProperties *,
+ CtrlSystem *, const char *);
+} GtkLibraryData;
+
+
+/*
+ * get_full_library_name() - build the library name to use by selecting the
+ * library name based on the index along with a possible path prefix.
+ */
+
+static char *get_full_library_name(const char *prefix, int index)
+{
+ int length = strlen(prefix);
+ return nvstrcat(prefix,
+ (length > 0 && prefix[length-1] != '/') ? "/" : "",
+ library_names[index],
+ NULL);
+}
+
+
+/*
+ * check_and_save_dlerror() - If an error occurs related to our dynamic loading,
+ * save the error message. Since we can check for more than one library and will
+ * fallback to another library name if the first is not found, we don't want to
+ * print an error message unless we abort execution because of it.
+ */
+
+static int check_and_save_dlerror(char **error_msg)
+{
+ const char *e;
+ char *new_error_msg;
+
+ e = dlerror();
+ if (e) {
+ if (*error_msg) {
+ new_error_msg = nvstrcat(*error_msg, "\n", e, NULL);
+ free(*error_msg);
+ *error_msg = new_error_msg;
+ } else {
+ *error_msg = nvstrdup(e);
+ }
+ return 1;
+ }
+
+ return 0;
+}
+
+
+/*
+ * load_and_resolve_libdata() - Load the given shared object name and check that
+ * it loads and all function pointers are resolved. If any error is detected,
+ * close the object handle and save the resulting error messages.
+ */
+
+static void load_and_resolve_libdata(const char *gui_lib_name,
+ GtkLibraryData *libdata)
+{
+ int symbol_error = 0;
+
+ libdata->gui_lib_handle = dlopen(gui_lib_name, RTLD_NOW);
+
+ if (libdata->gui_lib_handle) {
+ dlerror(); // clear error msg
+
+ libdata->fn_ctk_init_check = dlsym(libdata->gui_lib_handle,
+ "ctk_init_check");
+ symbol_error += check_and_save_dlerror(&libdata->error_msg);
+
+ libdata->fn_ctk_get_display = dlsym(libdata->gui_lib_handle,
+ "ctk_get_display");
+ symbol_error += check_and_save_dlerror(&libdata->error_msg);
+
+ libdata->fn_ctk_main = dlsym(libdata->gui_lib_handle, "ctk_main");
+ symbol_error += check_and_save_dlerror(&libdata->error_msg);
+
+ if (symbol_error > 0 ||
+ libdata->fn_ctk_init_check == NULL ||
+ libdata->fn_ctk_get_display == NULL ||
+ libdata->fn_ctk_main == NULL) {
+
+ dlclose(libdata->gui_lib_handle);
+ libdata->gui_lib_handle = NULL;
+ }
+ } else {
+ check_and_save_dlerror(&libdata->error_msg);
+ }
+}
+
+
+/*
+ * remove_flag_from_command_line() - Remove the "--" option and reindexes argv
+ * and reindex the command line options so that gtk_init_check() can process its
+ * options. If that flag is not found, no change to argv or argc is made.
+ */
+
+static void remove_flag_from_command_line(int *argc, char ***argv)
+{
+ int i, j;
+
+ for (i=0, j=0; i<(*argc); i++) {
+ if (i > j) {
+ (*argv)[j] = (*argv)[i];
+ j++;
+ } else if (strcmp("--", (*argv)[i]) != 0) {
+ j++;
+ }
+ }
+
+ (*argc) = j;
+ (*argv)[(*argc)] = NULL;
+}
+
+
+/*
+ * load_ui_library() - Decide whether we need to build a library name or use one
+ * already specified. If we build the name, iterate over our possible name
+ * options and either open the library or return a NULL pointer on failure.
+ */
+
+static void *load_ui_library(GtkLibraryData *libdata, Options *op)
+{
+ struct stat buf;
+ char *gui_lib_name;
+ int index = 0;
+ int max_index = ARRAY_LEN(library_names);
+
+ /*
+ * If the user did not specify a path or the path specified is a directory,
+ * we must attempt to open our default library names.
+ */
+
+ if (op->gtk_lib_path != NULL &&
+ (stat(op->gtk_lib_path, &buf) == 0 && !S_ISDIR(buf.st_mode))) {
+
+ /* user specified a non-directory file, try to dlopen it and return */
+
+ gui_lib_name = op->gtk_lib_path;
+
+ load_and_resolve_libdata(gui_lib_name, libdata);
+
+ } else {
+
+ while (!libdata->gui_lib_handle && index < max_index) {
+
+ /*
+ * If we fail to open the default library, work down the list of
+ * known library names and versions.
+ */
+
+ gui_lib_name =
+ get_full_library_name(op->gtk_lib_path ?
+ op->gtk_lib_path : "", index);
+
+ index++;
+
+ if (op->use_gtk2 && strstr(gui_lib_name, "gtk2") == NULL) {
+ continue;
+ }
+
+ load_and_resolve_libdata(gui_lib_name, libdata);
+ nvfree(gui_lib_name);
+ }
+ }
+
+ return libdata->gui_lib_handle;
+
+}
+
+
+
+/*
+ * main() - nvidia-settings application start
+ */
int main(int argc, char **argv)
{
ConfigProperties conf;
ParsedAttribute *p;
- CtrlHandles *h;
- CtrlHandlesArray handles_array;
+ CtrlSystem *system;
+ CtrlSystemList systems;
Options *op;
int ret;
- char *dpy = NULL;
int gui = 0;
- handles_array.n = 0;
- handles_array.array = NULL;
+ GtkLibraryData libdata;
+
+ libdata.gui_lib_handle = NULL;
+ libdata.error_msg = NULL;
+
+ systems.n = 0;
+ systems.array = NULL;
nv_set_verbosity(NV_VERBOSITY_DEPRECATED);
+ /* parse the commandline */
+
+ op = parse_command_line(argc, argv, &systems);
+
/*
- * initialize the ui
- *
- * XXX it would be nice if we didn't do this up front, since we
- * may not even use the gui, but we want the toolkit to have a
- * chance to parse the commandline before we do...
- *
- * gui flag used to decide if ctk should be used or not, as
- * the user might just use control the display from a remote console
- * but for some reason cannot initialize the gtk gui. - TY 2005-05-27
+ * Using the default library names, along with a possible path or name
+ * specified by the user, attempt to dlopen the appropriate user interface
+ * shared object.
*/
- if (ctk_init_check(&argc, &argv)) {
- dpy = ctk_get_display();
- gui = 1;
+ load_ui_library(&libdata, op);
+
+ if (libdata.gui_lib_handle) {
+ /*
+ * initialize the ui
+ *
+ * gui flag used to decide if ctk should be used or not, as
+ * the user might just use control the display from a remote console
+ * but for some reason cannot initialize the gtk gui. - TY 2005-05-27
+ *
+ * All options intented for gtk must come after the "--" option flag.
+ * Since gtk will also stop parsing options when encountering this
+ * flag, we must remove it from argv before calling ctk_init_check.
+ */
+
+ remove_flag_from_command_line(&argc, &argv);
+
+ if (libdata.fn_ctk_init_check(&argc, &argv)) {
+ if (!op->ctrl_display) {
+ op->ctrl_display = libdata.fn_ctk_get_display();
+ }
+ gui = 1;
+ }
+ }
+
+ /*
+ * Quit here if the dynamic load above fails.
+ */
+
+ if (!libdata.gui_lib_handle) {
+ nv_error_msg("%s", libdata.error_msg);
+ nv_error_msg("A problem occured when loading the GUI library. Please "
+ "check your installation and library path. You may need "
+ "to specify this library when calling nvidia-settings. "
+ "Please run `%s --help` for usage information.\n",
+ argv[0]);
+ return 1;
}
-
- /* parse the commandline */
-
- op = parse_command_line(argc, argv, dpy, &handles_array);
/* quit here if we don't have a ctrl_display - TY 2005-05-27 */
@@ -76,13 +297,13 @@ int main(int argc, char **argv)
/* Allocate handle for ctrl_display */
- nv_alloc_ctrl_handles_and_add_to_array(op->ctrl_display, &handles_array);
+ NvCtrlConnectToSystem(op->ctrl_display, &systems);
/* process any query or assignment commandline options */
if (op->num_assignments || op->num_queries) {
- ret = nv_process_assignments_and_queries(op, &handles_array);
- nv_free_ctrl_handles_array(&handles_array);
+ ret = nv_process_assignments_and_queries(op, &systems);
+ NvCtrlFreeAllSystems(&systems);
return ret ? 0 : 1;
}
@@ -101,10 +322,12 @@ int main(int argc, char **argv)
if (op->rewrite) {
nv_parsed_attribute_clean(p);
- h = nv_get_ctrl_handles(op->ctrl_display, &handles_array);
- if(!h || !h->dpy) return 1;
- ret = nv_write_config_file(op->config, h, p, &conf);
- nv_free_ctrl_handles_array(&handles_array);
+ system = NvCtrlGetSystem(op->ctrl_display, &systems);
+ if (!system || !system->dpy) {
+ return 1;
+ }
+ ret = nv_write_config_file(op->config, system, p, &conf);
+ NvCtrlFreeAllSystems(&systems);
nv_parsed_attribute_free(p);
free(op);
op = NULL;
@@ -114,8 +337,8 @@ int main(int argc, char **argv)
/* upload the data from the config file */
if (!op->no_load) {
- ret = nv_read_config_file(op, op->config, op->ctrl_display,
- p, &conf, &handles_array);
+ ret = nv_read_config_file(op, op->config, op->ctrl_display,
+ p, &conf, &systems);
} else {
ret = 1;
}
@@ -140,29 +363,30 @@ int main(int argc, char **argv)
return 1;
}
- /* Get the CtrlHandles for this X screen */
+ /* Get the CtrlSystem for this X screen */
- h = nv_get_ctrl_handles(op->ctrl_display, &handles_array);
-
- if (!h || !h->dpy) {
+ system = NvCtrlGetSystem(op->ctrl_display, &systems);
+
+ if (!system || !system->dpy) {
return 1;
}
/* pass control to the gui */
- ctk_main(p, &conf, h, op->page);
-
+ libdata.fn_ctk_main(p, &conf, system, op->page);
+
/* write the configuration file */
if (op->write_config) {
- nv_write_config_file(op->config, h, p, &conf);
+ nv_write_config_file(op->config, system, p, &conf);
}
/* cleanup */
- nv_free_ctrl_handles_array(&handles_array);
+ NvCtrlFreeAllSystems(&systems);
nv_parsed_attribute_free(p);
+ dlclose(libdata.gui_lib_handle);
return 0;
-
+
} /* main() */
diff --git a/src/option-table.h b/src/option-table.h
index 528e28c..e7fd236 100644
--- a/src/option-table.h
+++ b/src/option-table.h
@@ -51,6 +51,12 @@ static const NVGetoptOption __options[] = {
"if that is not given, then the &$DISPLAY& environment "
"variable is used." },
+ /*
+ * This is a silent, hidden option for the GTK argument that we treat
+ * identically to the above "ctrl-display" option.
+ */
+ { "display", DISPLAY_OPTION, NVGETOPT_STRING_ARGUMENT, NULL, NULL },
+
{ "load-config-only", 'l', NVGETOPT_HELP_ALWAYS, NULL,
"Load the configuration file, send the values specified therein to "
"the X server, and exit. This mode of operation is useful to place "
@@ -187,6 +193,19 @@ static const NVGetoptOption __options[] = {
{ "write-config", 'w', NVGETOPT_IS_BOOLEAN | NVGETOPT_HELP_ALWAYS, NULL,
"Save the configuration file on exit (enabled by default)." },
+ { "use-gtk2", 'i', NVGETOPT_HELP_ALWAYS, NULL, "Force nvidia-settings to "
+ "use the GTK+ 2 library for the graphical user interface if a user "
+ "interface is required. This option is only available on systems where "
+ "nvidia-settings supports both the GTK+ 2 and GTK+ 3 user "
+ "interfaces.\n" },
+
+ { "gtk-library", 'I', NVGETOPT_STRING_ARGUMENT | NVGETOPT_HELP_ALWAYS, NULL,
+ "Specify the graphical user interface library to use if a "
+ "nvidia-settings user interface is required. This value may be the exact "
+ "location of the library or it may be the directory containing the "
+ "appropriately named library. If this is the exact location, the "
+ "'use-gtk2' option is ignored.\n" },
+
{ NULL, 0, 0, NULL, NULL},
};
diff --git a/src/parse.c b/src/parse.c
index 30aab3c..9ded501 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -47,11 +47,11 @@ static uint32 display_device_name_to_display_device_mask(const char *str);
* attribute.
*/
-#define INT_ATTR NV_PARSER_ATTRIBUTE_TYPE_INTEGER
-#define STR_ATTR NV_PARSER_ATTRIBUTE_TYPE_STRING
-#define COL_ATTR NV_PARSER_ATTRIBUTE_TYPE_COLOR
-#define CSC_ATTR NV_PARSER_ATTRIBUTE_TYPE_SDI_CSC
-#define SOP_ATTR NV_PARSER_ATTRIBUTE_TYPE_STRING_OPERATION
+#define INT_ATTR CTRL_ATTRIBUTE_TYPE_INTEGER
+#define STR_ATTR CTRL_ATTRIBUTE_TYPE_STRING
+#define COL_ATTR CTRL_ATTRIBUTE_TYPE_COLOR
+#define CSC_ATTR CTRL_ATTRIBUTE_TYPE_SDI_CSC
+#define SOP_ATTR CTRL_ATTRIBUTE_TYPE_STRING_OPERATION
const AttributeTableEntry attributeTable[] = {
@@ -109,7 +109,7 @@ const AttributeTableEntry attributeTable[] = {
{ "LogAniso", NV_CTRL_LOG_ANISO, INT_ATTR, {0,0,0,0,0,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Enables anisotropic filtering for OpenGL clients; on some NVIDIA hardware, this can only be enabled or disabled; on other hardware different levels of anisotropic filtering can be specified. This setting only takes effect on OpenGL clients started after it is set." },
{ "FSAA", NV_CTRL_FSAA_MODE, INT_ATTR, {0,0,0,0,0,0}, { .int_flags = {0,0,0,0,0,0,0} }, "The full screen antialiasing setting for OpenGL clients. This setting only takes effect on OpenGL clients started after it is set. Enabling antialiasing will disable FXAA." },
{ "TextureSharpen", NV_CTRL_TEXTURE_SHARPEN, INT_ATTR, {0,0,0,0,0,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Enables texture sharpening for OpenGL clients. This setting only takes effect on OpenGL clients started after it is set." },
- { "ForceGenericCpu", NV_CTRL_FORCE_GENERIC_CPU, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "DEPRECATED." },
+ { "ForceGenericCpu", NV_CTRL_FORCE_GENERIC_CPU, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "NOT SUPPORTED." },
{ "GammaCorrectedAALines", NV_CTRL_OPENGL_AA_LINE_GAMMA, INT_ATTR, {0,0,0,0,0,0}, { .int_flags = {0,0,0,0,0,0,0} }, "For OpenGL clients, allow gamma-corrected antialiased lines to consider variances in the color display capabilities of output devices when rendering smooth lines. Only available on recent Quadro GPUs. This setting only takes effect on OpenGL clients started after it is set." },
{ "TextureClamping", NV_CTRL_TEXTURE_CLAMPING, INT_ATTR, {0,0,0,0,0,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Define the behavior of OpenGL texture clamping for unbordered textures. If enabled (1), the conformant behavior is used. If disabled (0), GL_CLAMP is remapped to GL_CLAMP_TO_EDGE to avoid seams in applications that rely on this behavior, which was the only option in some very old hardware." },
{ "FXAA", NV_CTRL_FXAA, INT_ATTR, {0,0,0,0,0,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Enables or disables the use of FXAA, Fast Approximate Anti-Aliasing. Enabling FXAA will disable regular antialiasing modes." },
@@ -146,11 +146,13 @@ const AttributeTableEntry attributeTable[] = {
{ "GPUAmbientTemp", NV_CTRL_AMBIENT_TEMPERATURE, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Reports the current temperature in Celsius of the immediate neighborhood of the GPU driving the X screen." },
{ "GPUGraphicsClockOffset", NV_CTRL_GPU_NVCLOCK_OFFSET, INT_ATTR, {0,0,0,1,1,1}, { .int_flags = {0,0,0,0,0,0,0} }, "This is the offset amount, in MHz, to over- or under-clock the Graphics Clock. Specify the performance level in square brackets after the attribute name. E.g., 'GPUGraphicsClockOffset[2]'." },
{ "GPUMemoryTransferRateOffset", NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET, INT_ATTR, {0,0,0,1,1,1}, { .int_flags = {0,0,0,0,0,0,0} }, "This is the offset amount, in MHz, to over- or under-clock the Memory Transfer Rate. Specify the performance level in square brackets after the attribute name. E.g., 'GPUMemoryTransferRateOffset[2]'." },
- { "GPUOverclockingState", NV_CTRL_GPU_OVERCLOCKING_STATE, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "The current overclocking state; the value of this attribute controls the availability of additional overclocking attributes. Note that this attribute is unavailable unless overclocking support has been enabled by the system administrator." },
- { "GPU2DClockFreqs", NV_CTRL_GPU_2D_CLOCK_FREQS, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "The GPU and memory clock frequencies when operating in 2D mode. New clock frequencies are tested before being applied, and may be rejected. Note that if the target clocks are too aggressive, their testing may render the system unresponsive. Also note that while this attribute may always be queried, it cannot be set unless GPUOverclockingState is set to MANUAL. Since the target clocks may be rejected, the requester should read this attribute after the set to determine success or failure." },
- { "GPU3DClockFreqs", NV_CTRL_GPU_3D_CLOCK_FREQS, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "The GPU and memory clock frequencies when operating in 3D mode. New clock frequencies are tested before being applied, and may be rejected. Note that if the target clocks are too aggressive, their testing may render the system unresponsive. Also note that while this attribute may always be queried, it cannot be set unless GPUOverclockingState is set to MANUAL. Since the target clocks may be rejected, the requester should read this attribute after the set to determine success or failure." },
- { "GPUDefault2DClockFreqs", NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "Returns the default memory and GPU core clocks when operating in 2D mode." },
- { "GPUDefault3DClockFreqs", NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "Returns the default memory and GPU core clocks when operating in 3D mode." },
+ { "GPUCurrentCoreVoltage", NV_CTRL_GPU_CURRENT_CORE_VOLTAGE, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "This attribute returns the GPU's current operating voltage, in microvolts (uV)."},
+ { "GPUOverVoltageOffset", NV_CTRL_GPU_OVER_VOLTAGE_OFFSET, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "This is the offset, in microvolts (uV), to apply to the GPU's operating voltage."},
+ { "GPUOverclockingState", NV_CTRL_GPU_OVERCLOCKING_STATE, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "NOT SUPPORTED." },
+ { "GPU2DClockFreqs", NV_CTRL_GPU_2D_CLOCK_FREQS, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "NOT SUPPORTED." },
+ { "GPU3DClockFreqs", NV_CTRL_GPU_3D_CLOCK_FREQS, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "NOT SUPPORTED." },
+ { "GPUDefault2DClockFreqs", NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "NOT SUPPORTED." },
+ { "GPUDefault3DClockFreqs", NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "NOT SUPPORTED." },
{ "GPUCurrentClockFreqs", NV_CTRL_GPU_CURRENT_CLOCK_FREQS, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "Returns the current GPU and memory clocks of the graphics device driving the X screen." },
{ "GPUCurrentProcessorClockFreqs", NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the current processor clock of the graphics device driving the X screen." },
{ "BusRate", NV_CTRL_BUS_RATE, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "If the device is on an AGP bus, then BusRate returns the configured AGP rate. If the device is on a PCI Express bus, then this attribute returns the width of the physical link." },
@@ -162,7 +164,7 @@ const AttributeTableEntry attributeTable[] = {
{ "PCIEGen", NV_CTRL_GPU_PCIE_GENERATION, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the PCIe generation that this GPU, in this system, is compliant with." },
{ "GPUErrors", NV_CTRL_NUM_GPU_ERRORS_RECOVERED, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the number of GPU errors occurred." },
{ "GPUPowerSource", NV_CTRL_GPU_POWER_SOURCE, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Reports the type of power source of the GPU." },
- { "GPUCurrentPerfMode", NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "DEPRECATED." },
+ { "GPUCurrentPerfMode", NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "NOT SUPPORTED." },
{ "GPUCurrentPerfLevel", NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Reports the current Performance level of the GPU driving the X screen. Each Performance level has associated NVClock and Mem Clock values." },
{ "GPUAdaptiveClockState", NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE, INT_ATTR, {0,0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Reports if Adaptive Clocking is Enabled on the GPU driving the X screen." },
{ "GPUPowerMizerMode", NV_CTRL_GPU_POWER_MIZER_MODE, INT_ATTR, {0,0,0,0,0,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Allows setting different GPU powermizer modes." },
@@ -373,7 +375,7 @@ const int attributeTableLen = ARRAY_LEN(attributeTable);
* the last attribute that the table knows about.
*/
-#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_VIDEO_DECODER_UTILIZATION
+#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_GPU_CURRENT_CORE_VOLTAGE
#warning "Have you forgotten to add a new integer attribute to attributeTable?"
#endif
@@ -392,7 +394,7 @@ const int attributeTableLen = ARRAY_LEN(attributeTable);
*
*/
const AttributeTableEntry *nv_get_attribute_entry(const int attr,
- const AttributeType type)
+ const CtrlAttributeType type)
{
int i;
@@ -429,116 +431,6 @@ static const AttributeTableEntry *nv_get_attribute_entry_by_name(const char *nam
/*
- * targetTypeTable[] - this table stores an association of the values
- * for each attribute target type.
- */
-
-const TargetTypeEntry targetTypeTable[] = {
-
- { "X Screen", /* name */
- "screen", /* parsed_name */
- X_SCREEN_TARGET, /* target_index */
- NV_CTRL_TARGET_TYPE_X_SCREEN, /* nvctrl */
- ATTRIBUTE_TYPE_X_SCREEN, /* permission_bit */
- NV_TRUE, /* uses_display_devices */
- 1, 6 }, /* required major,minor protocol rev */
-
- { "GPU", /* name */
- "gpu", /* parsed_name */
- GPU_TARGET, /* target_index */
- NV_CTRL_TARGET_TYPE_GPU, /* nvctrl */
- ATTRIBUTE_TYPE_GPU, /* permission_bit */
- NV_TRUE, /* uses_display_devices */
- 1, 10 }, /* required major,minor protocol rev */
-
- { "Frame Lock Device", /* name */
- "framelock", /* parsed_name */
- FRAMELOCK_TARGET, /* target_index */
- NV_CTRL_TARGET_TYPE_FRAMELOCK, /* nvctrl */
- ATTRIBUTE_TYPE_FRAMELOCK, /* permission_bit */
- NV_FALSE, /* uses_display_devices */
- 1, 10 }, /* required major,minor protocol rev */
-
- { "VCS", /* name */
- "vcs", /* parsed_name */
- VCS_TARGET, /* target_index */
- NV_CTRL_TARGET_TYPE_VCSC, /* nvctrl */
- ATTRIBUTE_TYPE_VCSC, /* permission_bit */
- NV_FALSE, /* uses_display_devices */
- 1, 12 }, /* required major,minor protocol rev */
-
- { "SDI Input Device", /* name */
- "gvi", /* parsed_name */
- GVI_TARGET, /* target_index */
- NV_CTRL_TARGET_TYPE_GVI, /* nvctrl */
- ATTRIBUTE_TYPE_GVI, /* permission_bit */
- NV_FALSE, /* uses_display_devices */
- 1, 18 }, /* required major,minor protocol rev */
-
- { "Fan", /* name */
- "fan", /* parsed_name */
- COOLER_TARGET, /* target_index */
- NV_CTRL_TARGET_TYPE_COOLER, /* nvctrl */
- ATTRIBUTE_TYPE_COOLER, /* permission_bit */
- NV_FALSE, /* uses_display_devices */
- 1, 20 }, /* required major,minor protocol rev */
-
- { "Thermal Sensor", /* name */
- "thermalsensor", /* parsed_name */
- THERMAL_SENSOR_TARGET, /* target_index */
- NV_CTRL_TARGET_TYPE_THERMAL_SENSOR, /* nvctrl */
- ATTRIBUTE_TYPE_THERMAL_SENSOR, /* permission_bit */
- NV_FALSE, /* uses_display_devices */
- 1, 23 }, /* required major,minor protocol rev */
-
- { "3D Vision Pro Transceiver", /* name */
- "svp", /* parsed_name */
- NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET, /* target_index */
- NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER, /* nvctrl */
- ATTRIBUTE_TYPE_3D_VISION_PRO_TRANSCEIVER, /* permission_bit */
- NV_FALSE, /* uses_display_devices */
- 1, 25 }, /* required major,minor protocol rev */
-
- { "Display Device", /* name */
- "dpy", /* parsed_name */
- DISPLAY_TARGET, /* target_index */
- NV_CTRL_TARGET_TYPE_DISPLAY, /* nvctrl */
- ATTRIBUTE_TYPE_DISPLAY, /* permission_bit */
- NV_FALSE, /* uses_display_devices */
- 1, 27 }, /* required major,minor protocol rev */
-};
-
-const int targetTypeTableLen = ARRAY_LEN(targetTypeTable);
-
-const TargetTypeEntry *nv_get_target_type_entry_by_nvctrl(int nvctrl)
-{
- int i;
-
- for (i = 0; i < targetTypeTableLen; i++) {
- if (targetTypeTable[i].nvctrl == nvctrl) {
- return &targetTypeTable[i];
- }
- }
-
- return NULL;
-}
-
-const TargetTypeEntry *nv_get_target_type_entry_by_name(const char *name)
-{
- int i;
-
- for (i = 0; i < targetTypeTableLen; i++) {
- if (nv_strcasecmp(targetTypeTable[i].parsed_name, name)) {
- return &targetTypeTable[i];
- }
- }
-
- return NULL;
-}
-
-
-
-/*
* nv_get_sdi_csc_matrix() - see comments in parse.h
*/
@@ -641,7 +533,7 @@ static int nv_parse_special_xscreen_target(ParsedAttribute *p,
}
p->parser_flags.has_target = NV_TRUE;
- p->target_type = NV_CTRL_TARGET_TYPE_X_SCREEN;
+ p->target_type = X_SCREEN_TARGET;
return NV_TRUE;
}
@@ -684,7 +576,7 @@ static int nv_parse_display_and_target(const char *start,
p->display = NULL;
p->target_id = -1;
- p->target_type = -1;
+ p->target_type = INVALID_TARGET;
p->target_specification = NULL;
p->parser_flags.has_x_display = NV_FALSE;
p->parser_flags.has_target = NV_FALSE;
@@ -784,7 +676,7 @@ int nv_parse_attribute_string(const char *str, int query, ParsedAttribute *p)
memset((void *) p, 0, sizeof(ParsedAttribute));
p->target_id = -1;
- p->target_type = -1;
+ p->target_type = INVALID_TARGET;
/* remove any white space from the string, to simplify parsing */
@@ -903,7 +795,7 @@ int nv_parse_attribute_string(const char *str, int query, ParsedAttribute *p)
tmp = s;
switch (a->type) {
- case NV_PARSER_ATTRIBUTE_TYPE_INTEGER:
+ case CTRL_ATTRIBUTE_TYPE_INTEGER:
if (a->f.int_flags.is_packed) {
/*
* Either a single 32-bit integer or two 16-bit integers,
@@ -943,19 +835,20 @@ int nv_parse_attribute_string(const char *str, int query, ParsedAttribute *p)
}
break;
- case NV_PARSER_ATTRIBUTE_TYPE_STRING:
+ case CTRL_ATTRIBUTE_TYPE_STRING:
/* Fall through */
- case NV_PARSER_ATTRIBUTE_TYPE_STRING_OPERATION:
+ case CTRL_ATTRIBUTE_TYPE_STRING_OPERATION:
+ case CTRL_ATTRIBUTE_TYPE_BINARY_DATA:
p->val.str = nvstrdup(s);
tmp = s + strlen(s);
break;
- case NV_PARSER_ATTRIBUTE_TYPE_COLOR:
+ case CTRL_ATTRIBUTE_TYPE_COLOR:
/* color attributes are floating point */
p->val.f = strtod(s, &tmp);
break;
- case NV_PARSER_ATTRIBUTE_TYPE_SDI_CSC:
+ case CTRL_ATTRIBUTE_TYPE_SDI_CSC:
/* String that names a standard CSC matrix */
p->val.pf = nv_get_sdi_csc_matrix(s);
tmp = s + strlen(s);
@@ -1088,12 +981,17 @@ static uint32 display_device_name_to_display_device_mask(const char *str)
/* sanity check */
if (!str || !*str) return INVALID_DISPLAY_DEVICE_MASK;
-
+
/* remove spaces from the string */
s = remove_spaces(str);
- if (!s || !*s) return INVALID_DISPLAY_DEVICE_MASK;
-
+ if (!s || !*s) {
+ if (s) {
+ free(s);
+ }
+ return INVALID_DISPLAY_DEVICE_MASK;
+ }
+
/*
* can the string be interpreted as a number? if so, use the number
* as the mask
@@ -1334,13 +1232,13 @@ static void nv_parsed_attribute_free_members(ParsedAttribute *p)
nvfree(p->target_specification);
if (a &&
- ((a->type == NV_PARSER_ATTRIBUTE_TYPE_STRING) ||
- ((a->type == NV_PARSER_ATTRIBUTE_TYPE_INTEGER) &&
+ ((a->type == CTRL_ATTRIBUTE_TYPE_STRING) ||
+ ((a->type == CTRL_ATTRIBUTE_TYPE_INTEGER) &&
(a->f.int_flags.is_display_id)))) {
nvfree(p->val.str);
}
- nv_target_list_free(p->targets);
+ NvCtrlTargetListFree(p->targets);
}
@@ -1422,7 +1320,10 @@ char *nv_standardize_screen_name(const char *orig, int screen)
free(display_name);
display_name = tmp;
colon = strchr(display_name, ':');
- if (!colon) return NULL;
+ if (!colon) {
+ nvfree(display_name);
+ return NULL;
+ }
}
}
diff --git a/src/parse.h b/src/parse.h
index fd27391..b13e1b5 100644
--- a/src/parse.h
+++ b/src/parse.h
@@ -24,6 +24,8 @@
#ifndef __PARSE_H__
#define __PARSE_H__
+#include "NvCtrlAttributes.h"
+
#define NV_PARSER_ASSIGNMENT 0
#define NV_PARSER_QUERY 1
@@ -63,20 +65,6 @@ typedef unsigned int uint32;
/*
- * attribute types used to know how to access each attribute (eg, to know which
- * of the NvCtrlXXX() backend functions to call).
- */
-
-typedef enum {
- NV_PARSER_ATTRIBUTE_TYPE_INTEGER,
- NV_PARSER_ATTRIBUTE_TYPE_STRING,
- NV_PARSER_ATTRIBUTE_TYPE_COLOR,
- NV_PARSER_ATTRIBUTE_TYPE_SDI_CSC,
- NV_PARSER_ATTRIBUTE_TYPE_STRING_OPERATION,
-} AttributeType;
-
-
-/*
* flags common to all attributes ('flags' in AttributeTableEntry)
*/
@@ -115,7 +103,7 @@ typedef struct _AttributeTableEntry {
char *name;
int attr;
- AttributeType type;
+ CtrlAttributeType type;
AttributeFlags flags;
union {
AttributeIntFlags int_flags;
@@ -168,7 +156,7 @@ typedef struct _ParsedAttribute {
* and/or target_specification get converted into a list of targets to
* which the attribute should be processed.
*/
- struct _CtrlHandleTargetNode *targets;
+ struct _CtrlTargetNode *targets;
} ParsedAttribute;
@@ -181,68 +169,6 @@ extern const AttributeTableEntry attributeTable[];
extern const int attributeTableLen;
-/*
- * Indices into both targetTypeTable[] and CtrlHandles->targets[] array; stored
- * in TargetTypeEntry.target_index.
- */
-
-#define X_SCREEN_TARGET 0
-#define GPU_TARGET 1
-#define FRAMELOCK_TARGET 2
-#define VCS_TARGET 3
-#define GVI_TARGET 4
-#define COOLER_TARGET 5
-#define THERMAL_SENSOR_TARGET 6
-#define NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET 7
-#define DISPLAY_TARGET 8
-#define MAX_TARGET_TYPES 9
-
-
-
-/*
- * TargetTypeEntry - an array of these structures defines the values
- * associated with each target type.
- */
-
-typedef struct {
- char *name; /* string describing the TargetType */
- char *parsed_name; /* name used by parser */
- int target_index; /* index into the CtrlHandles->targets[] array */
- int nvctrl; /* NV-CONTROL target type value (NV_CTRL_TARGET_TYPE) */
-
- /* flag set in NVCTRLAttributeValidValuesRec.permissions */
- unsigned int permission_bit;
-
- /* whether this target type is aware of display devices */
- int uses_display_devices;
-
- /*
- * the minimum NV-CONTROL Protocol version required to use this target
- * type; note that all future target types should be able to use 1.18,
- * since that version and later allows NV-CONTROL clients to query the
- * count of TargetTypes not recognized by the X server
- */
-
- int major;
- int minor;
-
-} TargetTypeEntry;
-
-
-/*
- * TargetType table; defined in parse.c
- */
-
-extern const TargetTypeEntry targetTypeTable[];
-extern const int targetTypeTableLen;
-
-/*
- * accessor functions for getting target type info based on NV-CONTROL
- * attribute type or by a name.
- */
-const TargetTypeEntry *nv_get_target_type_entry_by_nvctrl(int nvctrl);
-const TargetTypeEntry *nv_get_target_type_entry_by_name(const char *name);
-
/* nv_get_sdi_csc_matrxi() - Returns an array of floats that specifies
* all the color, offset and scale values for specifying one of the
@@ -367,7 +293,7 @@ void nv_parsed_attribute_free(ParsedAttribute *p);
void nv_parsed_attribute_clean(ParsedAttribute *p);
const AttributeTableEntry *nv_get_attribute_entry(const int attr,
- const AttributeType type);
+ const CtrlAttributeType type);
char *nv_standardize_screen_name(const char *display_name, int screen);
diff --git a/src/query-assign.c b/src/query-assign.c
index cfe4c50..b4e84f0 100644
--- a/src/query-assign.c
+++ b/src/query-assign.c
@@ -44,15 +44,15 @@
static int process_attribute_queries(const Options *,
int, char**, const char *,
- CtrlHandlesArray *);
+ CtrlSystemList *);
static int process_attribute_assignments(const Options *,
int, char**, const char *,
- CtrlHandlesArray *);
+ CtrlSystemList *);
-static int query_all(const Options *, const char *, CtrlHandlesArray *);
-static int query_all_targets(const char *display_name, const int target_index,
- CtrlHandlesArray *);
+static int query_all(const Options *, const char *, CtrlSystemList *);
+static int query_all_targets(const char *display_name, const int target_type,
+ CtrlSystemList *);
static void print_valid_values(const Options *op, const AttributeTableEntry *a,
NVCTRLAttributeValidValuesRec valid);
@@ -62,8 +62,7 @@ static void print_additional_info(const char *name,
NVCTRLAttributeValidValuesRec valid,
const char *indent);
-static ReturnStatus get_framelock_sync_state(NvCtrlAttributeHandle *t,
- CtrlHandles *h,
+static ReturnStatus get_framelock_sync_state(CtrlTarget *target,
int *enabled);
/*
@@ -73,7 +72,7 @@ static ReturnStatus get_framelock_sync_state(NvCtrlAttributeHandle *t,
*/
int nv_process_assignments_and_queries(const Options *op,
- CtrlHandlesArray *handles_array)
+ CtrlSystemList *systems)
{
int ret;
@@ -81,7 +80,7 @@ int nv_process_assignments_and_queries(const Options *op,
ret = process_attribute_queries(op,
op->num_queries,
op->queries, op->ctrl_display,
- handles_array);
+ systems);
if (!ret) return NV_FALSE;
}
@@ -90,7 +89,7 @@ int nv_process_assignments_and_queries(const Options *op,
op->num_assignments,
op->assignments,
op->ctrl_display,
- handles_array);
+ systems);
if (!ret) return NV_FALSE;
}
@@ -101,497 +100,6 @@ int nv_process_assignments_and_queries(const Options *op,
/*!
- * Queries the NV-CONTROL string attribute and returns the string as a simple
- * char *. This is useful to avoid having to track how strings are allocated
- * so we can cleanup all strings via nvfree().
- *
- * \param[in] t The CtrlHandleTarget to query the string on.
- * \param[in] attr The NV-CONTROL string to query.
- *
- * \return Return a nvalloc()'ed copy of the NV-CONTROL string; else, returns
- * NULL.
- */
-
-static char *query_x_name(const CtrlHandleTarget *t, int attr)
-{
- ReturnStatus status;
- char *x_str;
- char *str = NULL;
-
- status = NvCtrlGetStringAttribute(t->h, attr, &x_str);
- if (status == NvCtrlSuccess) {
- str = nvstrdup(x_str);
- XFree(x_str);
- }
-
- return str;
-}
-
-
-
-/*!
- * Retrieves and adds all the display device names for the given target.
- *
- * \param[in/out] t The CtrlHandleTarget to load names for.
- */
-
-static void load_display_target_proto_names(CtrlHandleTarget *t)
-{
- t->protoNames[NV_DPY_PROTO_NAME_TYPE_BASENAME] =
- query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME);
-
- t->protoNames[NV_DPY_PROTO_NAME_TYPE_ID] =
- query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID);
-
- t->protoNames[NV_DPY_PROTO_NAME_DP_GUID] =
- query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_DP_GUID);
-
- t->protoNames[NV_DPY_PROTO_NAME_EDID_HASH] =
- query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_EDID_HASH);
-
- t->protoNames[NV_DPY_PROTO_NAME_TARGET_INDEX] =
- query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_TARGET_INDEX);
-
- t->protoNames[NV_DPY_PROTO_NAME_RANDR] =
- query_x_name(t, NV_CTRL_STRING_DISPLAY_NAME_RANDR);
-}
-
-
-
-/*!
- * Adds the default name for the given target to the list of protocol names at
- * the given proto name index.
- *
- * \param[in/out] t The CtrlHandleTarget to load names for.
- * \param[in] proto_idx The name index where to add the name.
- */
-
-static void load_default_target_proto_name(CtrlHandleTarget *t,
- const int proto_idx)
-{
- const int target_type = NvCtrlGetTargetType(t->h);
- const int target_id = NvCtrlGetTargetId(t->h);
-
- const TargetTypeEntry *targetTypeEntry =
- nv_get_target_type_entry_by_nvctrl(target_type);
-
- if (proto_idx >= NV_PROTO_NAME_MAX) {
- return;
- }
-
- if (targetTypeEntry) {
- t->protoNames[proto_idx] = nvasprintf("%s-%d",
- targetTypeEntry->parsed_name,
- target_id);
- nvstrtoupper(t->protoNames[proto_idx]);
- }
-}
-
-
-
-/*!
- * Adds the GPU names to the given target to the list of protocol names.
- *
- * \param[in/out] t The CtrlHandleTarget to load names for.
- */
-
-static void load_gpu_target_proto_names(CtrlHandleTarget *t)
-{
- load_default_target_proto_name(t, NV_GPU_PROTO_NAME_TYPE_ID);
-
- t->protoNames[NV_GPU_PROTO_NAME_UUID] =
- query_x_name(t, NV_CTRL_STRING_GPU_UUID);
-}
-
-
-
-/*!
- * Adds the all the appropriate names for the given target to the list of
- * protocol names.
- *
- * \param[in/out] t The CtrlHandleTarget to load names for.
- */
-
-static void load_target_proto_names(CtrlHandleTarget *t)
-{
- const int target_type = NvCtrlGetTargetType(t->h);
-
- switch (target_type) {
- case NV_CTRL_TARGET_TYPE_DISPLAY:
- load_display_target_proto_names(t);
- break;
-
- case NV_CTRL_TARGET_TYPE_GPU:
- load_gpu_target_proto_names(t);
- break;
-
- default:
- load_default_target_proto_name(t, 0);
- break;
- }
-}
-
-
-
-/*!
- * Returns the CtrlHandleTarget from CtrlHandles with the given target type/
- * target id.
- *
- * \param[in] handles Container for all the CtrlHandleTargets to search.
- * \param[in] target_type The target type of the CtrlHandleTarget to search.
- * \param[in] target_id The target id of the CtrlHandleTarget to search.
- *
- * \return Returns the matching CtrlHandleTarget from CtrlHandles on success;
- * else, returns NULL.
- */
-
-static CtrlHandleTarget *nv_get_target(const CtrlHandles *handles,
- int target_type,
- int target_id)
-{
- const CtrlHandleTargets *targets;
- int i;
-
- if (!handles || target_type < 0 || target_type >= MAX_TARGET_TYPES) {
- return NULL;
- }
-
- targets = handles->targets + target_type;
- for (i = 0; i < targets->n; i++) {
- CtrlHandleTarget *target = targets->t + i;
- if (NvCtrlGetTargetId(target->h) == target_id) {
- return target;
- }
- }
-
- return NULL;
-}
-
-
-/*!
- * Returns the RandR name of the matching display target from the given
- * target ID and the list of target handles.
- *
- * \param[in] handles Container for all the CtrlHandleTargets to search.
- * \param[in] target_id The target id of the display CtrlHandleTarget to
- * search.
- *
- * \return Returns the NV_DPY_PROTO_NAME_RANDR name string from the matching
- * (display) CtrlHandleTarget from CtrlHandles on success; else,
- * returns NULL.
- *
- */
-const char *nv_get_display_target_config_name(const CtrlHandles *handles,
- int target_id)
-{
- CtrlHandleTarget *t = nv_get_target(handles,
- NV_CTRL_TARGET_TYPE_DISPLAY,
- target_id);
-
- if (!t) {
- return NULL;
- }
-
- return t->protoNames[NV_DPY_PROTO_NAME_RANDR];
-}
-
-
-
-/*!
- * Returns the NvCtrlAttributeHandle from CtrlHandles with the given target
- * type/target id.
- *
- * \param[in] handles Container for all the CtrlHandleTargets to search.
- * \param[in] target_type The target type of the CtrlHandleTarget to search.
- * \param[in] target_id The target id of the CtrlHandleTarget to search.
- *
- * \return Returns the NvCtrlAttributeHandle from the matching
- * CtrlHandleTarget from CtrlHandles on success; else, returns NULL.
- */
-
-NvCtrlAttributeHandle *nv_get_target_handle(const CtrlHandles *handles,
- int target_type,
- int target_id)
-{
- CtrlHandleTarget *target;
-
- target = nv_get_target(handles, target_type, target_id);
- if (target) {
- return target->h;
- }
-
- return NULL;
-}
-
-
-
-/*!
- * Appends the given CtrlHandleTarget 'target' to the end of the
- * CtrlHandleTarget list 'head' if 'target' is not already in the list.
- *
- * \param[in/out] head The first node in the CtrlHandleTarget list, to which
- * target should be inserted.
- * \param[in] target The CtrlHandleTarget to add to the list.
- * \param[in] enabled_display_check Whether or not to check that, if the
- * target is a display target, it is also
- * enabled.
- */
-
-static void nv_target_list_add(CtrlHandleTargetNode **head,
- CtrlHandleTarget *target,
- Bool enabled_display_check)
-{
- CtrlHandleTargetNode *new_t;
- CtrlHandleTargetNode *t;
-
- /* Do not add disabled displays to the list */
- if (enabled_display_check) {
- int target_type = NvCtrlGetTargetType(target->h);
-
- if (target_type == NV_CTRL_TARGET_TYPE_DISPLAY &&
- !target->display.enabled) {
- return;
- }
- }
-
- new_t = nvalloc(sizeof(CtrlHandleTargetNode));
- new_t->t = target;
-
- t = *head;
-
- /* List is empty */
- if (!t) {
- *head = new_t;
- return;
- }
-
- while (1) {
- if (t->t == target) {
- nvfree(new_t);
- return;
- }
- if (!t->next) {
- t->next = new_t;
- return;
- }
- t = t->next;
- }
-}
-
-
-
-/*!
- * Frees the memory used for tracking a list of CtrlHandleTargets.
- *
- * \param[in\out] head The first node in the CtrlHandleTarget list that is to
- * be freed.
- */
-
-void nv_target_list_free(CtrlHandleTargetNode *head)
-{
- CtrlHandleTargetNode *n;
-
- while (head) {
- n = head->next;
- free(head);
- head = n;
- }
-}
-
-
-
-/*!
- * Adds all the targets (of target type 'targetType') that are both present
- * in the CtrlHandle, and known to be associated to 't' by querying the list
- * of associated targets to 't' from NV-CONTROL via binary attribute 'attr',
- * and possibly reciprocally adding the reverse relationship.
- *
- * \param[in\out] h The list of all managed targets from
- * which associations are to be made to/
- * from.
- * \param[in\out] t The target to which association(s) are
- * being made.
- * \param[in] targetType The target type of the associated
- * targets being considered (queried.)
- * \param[in] attr The NV-CONTROL binary attribute that
- * should be queried to retrieve the list
- * of 'targetType' targets that are
- * associated to the (CtrlHandleTarget)
- * target 't'.
- * \param[in] implicit_reciprocal Whether or not to reciprocally add the
- * reverse relationship to the matching
- * targets.
- */
-
-static void add_target_relationships(const CtrlHandles *h, CtrlHandleTarget *t,
- int targetType, int attr,
- int implicit_reciprocal)
-{
- ReturnStatus status;
- int *pData;
- int len;
- int i;
-
- status =
- NvCtrlGetBinaryAttribute(t->h, 0,
- attr,
- (unsigned char **)(&pData), &len);
- if ((status != NvCtrlSuccess) || !pData) {
- nv_error_msg("Error querying target relations");
- return;
- }
-
- for (i = 0; i < pData[0]; i++) {
- int targetId = pData[i+1];
- CtrlHandleTarget *r;
-
- r = nv_get_target(h, targetType, targetId);
- if (r) {
- nv_target_list_add(&(t->relations), r, FALSE);
-
- /* Track connection state of display devices */
- if (attr == NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU) {
- r->display.connected = NV_TRUE;
- }
-
- if (implicit_reciprocal == NV_TRUE) {
- nv_target_list_add(&(r->relations), t, FALSE);
- }
- }
- }
-
- XFree(pData);
-}
-
-
-
-/*!
- * Adds all associations to/from an X screen target.
- *
- * \param[in\out] h The list of all managed targets from which associations
- * are to be made to/from.
- * \param[in\out] t The X screen target to which association(s) are being
- * made.
- */
-
-static void load_screen_target_relationships(CtrlHandles *h,
- CtrlHandleTarget *t)
-{
- add_target_relationships(h, t, NV_CTRL_TARGET_TYPE_GPU,
- NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN,
- NV_TRUE);
- add_target_relationships(h, t, NV_CTRL_TARGET_TYPE_DISPLAY,
- NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN,
- NV_TRUE);
-}
-
-
-
-/*!
- * Adds all associations to/from a GPU target.
- *
- * \param[in\out] h The list of all managed targets from which associations
- * are to be made to/from.
- * \param[in\out] t The GPU target to which association(s) are being made.
- */
-
-static void load_gpu_target_relationships(CtrlHandles *h, CtrlHandleTarget *t)
-{
- add_target_relationships(h, t, NV_CTRL_TARGET_TYPE_FRAMELOCK,
- NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU,
- NV_FALSE);
- add_target_relationships(h, t, NV_CTRL_TARGET_TYPE_VCSC,
- NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU,
- NV_FALSE);
- add_target_relationships(h, t, NV_CTRL_TARGET_TYPE_COOLER,
- NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU,
- NV_TRUE);
- add_target_relationships(h, t, NV_CTRL_TARGET_TYPE_THERMAL_SENSOR,
- NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU,
- NV_TRUE);
- add_target_relationships(h, t, NV_CTRL_TARGET_TYPE_DISPLAY,
- NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU,
- NV_TRUE);
- add_target_relationships(h, t, NV_CTRL_TARGET_TYPE_DISPLAY,
- NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU,
- NV_TRUE);
-}
-
-
-
-/*!
- * Adds all associations to/from a FrameLock target.
- *
- * \param[in\out] h The list of all managed targets from which associations
- * are to be made to/from.
- * \param[in\out] t The FrameLock target to which association(s) are being
- * made.
- */
-
-static void load_framelock_target_relationships(CtrlHandles *h,
- CtrlHandleTarget *t)
-{
- add_target_relationships(h, t, NV_CTRL_TARGET_TYPE_GPU,
- NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK,
- NV_FALSE);
-}
-
-
-
-/*!
- * Adds all associations to/from a VCS target.
- *
- * \param[in\out] h The list of all managed targets from which associations
- * are to be made to/from.
- * \param[in\out] t The VCS target to which association(s) are being made.
- */
-
-static void load_vcs_target_relationships(CtrlHandles *h, CtrlHandleTarget *t)
-{
- add_target_relationships(h, t, NV_CTRL_TARGET_TYPE_GPU,
- NV_CTRL_BINARY_DATA_GPUS_USING_VCSC,
- NV_FALSE);
-}
-
-
-
-/*!
- * Adds all associations to/from a target.
- *
- * \param[in\out] h The list of all managed targets from which associations
- * are to be made to/from.
- * \param[in\out] t The target to which association(s) are being made.
- */
-
-static void load_target_relationships(CtrlHandles *h, CtrlHandleTarget *t)
-{
- int target_type = NvCtrlGetTargetType(t->h);
-
- switch (target_type) {
- case NV_CTRL_TARGET_TYPE_X_SCREEN:
- load_screen_target_relationships(h, t);
- break;
-
- case NV_CTRL_TARGET_TYPE_GPU:
- load_gpu_target_relationships(h, t);
- break;
-
- case NV_CTRL_TARGET_TYPE_FRAMELOCK:
- load_framelock_target_relationships(h, t);
- break;
-
- case NV_CTRL_TARGET_TYPE_VCSC:
- load_vcs_target_relationships(h, t);
- break;
-
- default:
- break;
- }
-}
-
-
-
-/*!
* Determines if the target 't' has the name 'name'.
*
* \param[in] t The target being considered.
@@ -601,7 +109,7 @@ static void load_target_relationships(CtrlHandles *h, CtrlHandleTarget *t)
* returns NV_FALSE.
*/
-static int nv_target_has_name(const CtrlHandleTarget *t, const char *name)
+static int nv_target_has_name(const CtrlTarget *t, const char *name)
{
int n;
@@ -619,38 +127,42 @@ static int nv_target_has_name(const CtrlHandleTarget *t, const char *name)
/*!
* Determines if the target 't' matches a given target type, target id, and/or
- * target name.
+ * target name. If a match criteria is invalid, it is not matched against.
*
- * \param[in] t The target being considered.
- * \param[in] name The name to match against.
+ * \param[in] t The target being considered.
+ * \param[in] matchTargetTypeInfo The target type to match to
+ * \param[in] matchTargetId The target id to match to
+ * \param[in] matchTargetName The target name to match to
*
- * \return Returns NV_TRUE if the given target 't' has the name 'name'; else
- * returns NV_FALSE.
+ * \return Returns NV_TRUE if the given target 't' matches the given
+ * qualifiers; else returns NV_FALSE.
*/
-static int target_has_qualification(const CtrlHandleTarget *t,
- int matchTargetType,
+static int target_has_qualification(const CtrlTarget *t,
+ const CtrlTargetTypeInfo *matchTargetTypeInfo,
int matchTargetId,
const char *matchTargetName)
{
- const CtrlHandleTargetNode *n;
+ const CtrlTargetNode *n;
/* If no qualifications given, all targets match */
- if ((matchTargetType < 0) && (matchTargetId < 0) && (!matchTargetName)) {
+ if (!matchTargetTypeInfo &&
+ (matchTargetId < 0) &&
+ !matchTargetName) {
return NV_TRUE;
}
/* Look for any matching relationship */
for (n = t->relations; n; n = n->next) {
- const CtrlHandleTarget *r = n->t;
+ const CtrlTarget *r = n->t;
- if (matchTargetType >= 0 &&
- (matchTargetType != NvCtrlGetTargetType(r->h))) {
+ if (matchTargetTypeInfo &&
+ (matchTargetTypeInfo != r->targetTypeInfo)) {
continue;
}
if ((matchTargetId >= 0) &&
- matchTargetId != NvCtrlGetTargetId(r->h)) {
+ matchTargetId != NvCtrlGetTargetId(r)) {
continue;
}
@@ -679,13 +191,15 @@ static int target_has_qualification(const CtrlHandleTarget *t,
* - All targets of type BBB with either target id AAA if AAA is a numerical
* value, or target(s) named AAA otherwise.
*
- * \param[in] sAAA If sBBB is NULL, this is either the target name,
- * or a target type.
- * \param[in] sBBB If not NULL, this is the target type as a string.
- * \param[out] targetType Assigned the target type, or -1 for all target types.
- * \param[out] targetId Assigned the target id, or -1 for all targets.
- * \param[out] targetName Assigned the target name, or NULL for all target
- * names.
+ * \param[in] sAAA If sBBB is NULL, this is either the target name,
+ * or a target type.
+ * \param[in] sBBB If not NULL, this is the target type as a
+ * string.
+ * \param[out] pTargetTypeInfo Assigned the target type, or NULL for all target
+ * types.
+ * \param[out] pTargetId Assigned the target id, or -1 for all targets.
+ * \param[out] pTargetName Assigned the target name, or NULL for all target
+ * names.
*
* \return Returns NV_PARSER_STATUS_SUCCESS if sAAA and sBBB were successfully
* parsed into at target specification; else, returns
@@ -695,39 +209,39 @@ static int target_has_qualification(const CtrlHandleTarget *t,
static int parse_single_target_specification(const char *sAAA,
const char *sBBB,
- int *targetType,
- int *targetId,
- const char **targetName)
+ const CtrlTargetTypeInfo **pTargetTypeInfo,
+ int *pTargetId,
+ const char **pTargetName)
{
- const TargetTypeEntry *targetTypeEntry;
+ const CtrlTargetTypeInfo *targetTypeInfo;
- *targetType = -1; // Match all target types
- *targetId = -1; // Match all target ids
- *targetName = NULL; // Match all target names
+ *pTargetTypeInfo = NULL; // Match all target types
+ *pTargetId = -1; // Match all target ids
+ *pTargetName = NULL; // Match all target names
if (sBBB) {
/* If BBB is specified, then it must name a target type */
- targetTypeEntry = nv_get_target_type_entry_by_name(sBBB);
- if (!targetTypeEntry) {
+ targetTypeInfo = NvCtrlGetTargetTypeInfoByName(sBBB);
+ if (!targetTypeInfo) {
return NV_PARSER_STATUS_TARGET_SPEC_BAD_TARGET;
}
- *targetType = targetTypeEntry->nvctrl;
+ *pTargetTypeInfo = targetTypeInfo;
/* AAA can either be a name, or a target id */
- if (!nv_parse_numerical(sAAA, NULL, targetId)) {
- *targetName = sAAA;
+ if (!nv_parse_numerical(sAAA, NULL, pTargetId)) {
+ *pTargetName = sAAA;
}
} else {
/* If BBB is unspecified, then AAA could possibly name a target type */
- targetTypeEntry = nv_get_target_type_entry_by_name(sAAA);
- if (targetTypeEntry) {
- *targetType = targetTypeEntry->nvctrl;
+ targetTypeInfo = NvCtrlGetTargetTypeInfoByName(sAAA);
+ if (targetTypeInfo) {
+ *pTargetTypeInfo = targetTypeInfo;
} else {
/* If not, then AAA is a target name */
- *targetName = sAAA;
+ *pTargetName = sAAA;
}
}
@@ -738,7 +252,7 @@ static int parse_single_target_specification(const char *sAAA,
/*!
- * Computes the list of targets from the list of CtrlHandles 'h' that match the
+ * Computes the list of targets from the given CtrlSystem that match the
* ParsedAttribute's target specification string.
*
* The following target specifications string formats are supported:
@@ -767,9 +281,10 @@ static int parse_single_target_specification(const char *sAAA,
* - All the targets named (or target id) AAA of the target type BBB that are
* related to targets named (or target id) CCC of the target type DDD.
*
- * \param[in/out] p The ParsedAttribute whose target specification string
- * should be analyzed and converted into a list of targets.
- * \param[in] h The list of targets to choose from.
+ * \param[in/out] p The ParsedAttribute whose target specification string
+ * should be analyzed and converted into a list of
+ * targets.
+ * \param[in] system The list of targets to choose from.
*
* \return Returns NV_PARSER_STATUS_SUCCESS if the ParsedAttribute's target
* specification string was successfully parsed into a list of targets
@@ -779,7 +294,7 @@ static int parse_single_target_specification(const char *sAAA,
*/
static int nv_infer_targets_from_specification(ParsedAttribute *p,
- CtrlHandles *h)
+ CtrlSystem *system)
{
int ret = NV_PARSER_STATUS_SUCCESS;
@@ -796,23 +311,23 @@ static int nv_infer_targets_from_specification(ParsedAttribute *p,
char *sDDD = NULL; // Target2type name
char *s;
- char *tmp;
+ char *specification;
- int i, j;
+ int target_type;
- int matchTargetType;
+ const CtrlTargetTypeInfo *matchTargetTypeInfo;
int matchTargetId;
const char *matchTargetName;
- int matchQualifierTargetType;
+ const CtrlTargetTypeInfo *matchQualifierTargetTypeInfo;
int matchQualifierTargetId;
const char *matchQualifierTargetName;
- tmp = nvstrdup(p->target_specification);
+ specification = nvstrdup(p->target_specification);
/* Parse for 'YYY.XXX' or 'XXX' */
- s = strchr(tmp, '.');
+ s = strchr(specification, '.');
/* Skip over periods that are followed by a numerical value since
* target names and target types cannot start with these, and thus
@@ -828,9 +343,9 @@ static int nv_infer_targets_from_specification(ParsedAttribute *p,
if (s) {
*s = '\0';
sXXX = s+1;
- sYYY = tmp;
+ sYYY = specification;
} else {
- sXXX = tmp;
+ sXXX = specification;
}
/* Parse for 'BBB:AAA' or 'AAA' (in XXX above) */
@@ -860,7 +375,7 @@ static int nv_infer_targets_from_specification(ParsedAttribute *p,
/* Get target matching criteria */
ret = parse_single_target_specification(sAAA, sBBB,
- &matchTargetType,
+ &matchTargetTypeInfo,
&matchTargetId,
&matchTargetName);
if (ret != NV_PARSER_STATUS_SUCCESS) {
@@ -870,7 +385,7 @@ static int nv_infer_targets_from_specification(ParsedAttribute *p,
/* Get target qualifier matching criteria */
ret = parse_single_target_specification(sCCC, sDDD,
- &matchQualifierTargetType,
+ &matchQualifierTargetTypeInfo,
&matchQualifierTargetId,
&matchQualifierTargetName);
if (ret != NV_PARSER_STATUS_SUCCESS) {
@@ -878,22 +393,24 @@ static int nv_infer_targets_from_specification(ParsedAttribute *p,
}
/* Iterate over the target types */
- for (i = 0; i < targetTypeTableLen; i++) {
- const TargetTypeEntry *targetTypeEntry = &(targetTypeTable[i]);
- CtrlHandleTargets *hts;
-
- if (matchTargetType >= 0 &&
- (matchTargetType != targetTypeEntry->nvctrl)) {
+ for (target_type = 0;
+ target_type < MAX_TARGET_TYPES;
+ target_type++) {
+ const CtrlTargetTypeInfo *targetTypeInfo =
+ NvCtrlGetTargetTypeInfo(target_type);
+ CtrlTargetNode *node;
+
+ if (matchTargetTypeInfo &&
+ (matchTargetTypeInfo != targetTypeInfo)) {
continue;
}
/* For each target of this type, match the id and/or name */
- hts = &(h->targets[targetTypeEntry->target_index]);
- for (j = 0; j < hts->n; j++) {
- CtrlHandleTarget *t = &(hts->t[j]);
+ for (node = system->targets[target_type]; node; node = node->next) {
+ CtrlTarget *t = node->t;
if ((matchTargetId >= 0) &&
- matchTargetId != NvCtrlGetTargetId(t->h)) {
+ matchTargetId != NvCtrlGetTargetId(t)) {
continue;
}
if (matchTargetName &&
@@ -902,548 +419,46 @@ static int nv_infer_targets_from_specification(ParsedAttribute *p,
}
if (!target_has_qualification(t,
- matchQualifierTargetType,
+ matchQualifierTargetTypeInfo,
matchQualifierTargetId,
matchQualifierTargetName)) {
continue;
}
/* Target matches, add it to the list */
- nv_target_list_add(&(p->targets), t, TRUE);
+ NvCtrlTargetListAdd(&(p->targets), t, TRUE);
p->parser_flags.has_target = NV_TRUE;
}
}
done:
- if (tmp) {
- free(tmp);
- }
+ free(specification);
return ret;
}
-/*
- * nv_init_target() - Given the Display pointer, create an attribute
- * handle and initialize the handle target.
- */
-
-static void nv_init_target(Display *dpy, CtrlHandleTarget *t,
- int target, int targetId)
-{
- NvCtrlAttributeHandle *handle;
- ReturnStatus status;
- char *tmp;
- int len, d, c;
-
- /* allocate the handle */
-
- handle = NvCtrlAttributeInit(dpy,
- targetTypeTable[target].nvctrl, targetId,
- NV_CTRL_ATTRIBUTES_ALL_SUBSYSTEMS);
-
- t->h = handle;
-
- /*
- * silently fail: this might happen if not all X screens
- * are NVIDIA X screens
- */
-
- if (!handle) {
- return;
- }
-
- /*
- * get a name for this target; in the case of
- * X_SCREEN_TARGET targets, just use the string returned
- * from NvCtrlGetDisplayName(); for other target types,
- * append a target specification.
- */
-
- tmp = NvCtrlGetDisplayName(t->h);
-
- if (target == X_SCREEN_TARGET) {
- t->name = tmp;
- } else {
- len = strlen(tmp) + strlen(targetTypeTable[target].parsed_name) + 16;
- t->name = nvalloc(len);
-
- if (t->name) {
- snprintf(t->name, len, "%s[%s:%d]",
- tmp, targetTypeTable[target].parsed_name, targetId);
- free(tmp);
- } else {
- t->name = tmp;
- }
- }
-
- load_target_proto_names(t);
- t->relations = NULL;
-
- if (target == DISPLAY_TARGET) {
- status = NvCtrlGetAttribute(t->h, NV_CTRL_DISPLAY_ENABLED, &d);
- if (status != NvCtrlSuccess) {
- nv_error_msg("Error querying enabled state of display %s %d (%s).",
- targetTypeTable[target].name, targetId,
- NvCtrlAttributesStrError(status));
- d = NV_CTRL_DISPLAY_ENABLED_FALSE;
- }
- t->display.enabled = (d == NV_CTRL_DISPLAY_ENABLED_TRUE) ? 1 : 0;
- }
-
-
- /*
- * get the enabled display device mask; for X screens and
- * GPUs we query NV-CONTROL; for anything else
- * (framelock), we just assign this to 0.
- */
-
- if (targetTypeTable[target].uses_display_devices) {
-
- status = NvCtrlGetAttribute(t->h,
- NV_CTRL_ENABLED_DISPLAYS, &d);
-
- if (status != NvCtrlSuccess) {
- nv_error_msg("Error querying enabled displays on "
- "%s %d (%s).", targetTypeTable[target].name, targetId,
- NvCtrlAttributesStrError(status));
- d = 0;
- }
-
- status = NvCtrlGetAttribute(t->h,
- NV_CTRL_CONNECTED_DISPLAYS, &c);
-
- if (status != NvCtrlSuccess) {
- nv_error_msg("Error querying connected displays on "
- "%s %d (%s).", targetTypeTable[target].name, targetId,
- NvCtrlAttributesStrError(status));
- c = 0;
- }
- } else {
- d = 0;
- c = 0;
- }
-
- t->d = d;
- t->c = c;
-
-}
-
-
-/*
- * nv_add_ctrl_handle_target() - add a CtrlHandleTarget to the array
- * of Targets for the given target_index. This is used for dynamically
- * created targets that don't exist when the CtrlHandles are initialized.
- */
-
-NvCtrlAttributeHandle *nv_add_target(CtrlHandles *handles, Display *dpy,
- int target_index, int display_id)
-{
- CtrlHandleTargets *dt;
- CtrlHandleTarget *t;
-
- if (!handles) {
- return NULL;
- }
-
- dt = &handles->targets[target_index];
-
- dt->t = nvrealloc(dt->t, (dt->n+1) * sizeof(CtrlHandleTarget));
- t = &dt->t[dt->n];
- dt->n++;
-
- nv_init_target(dpy, t, target_index, display_id);
- return t->h;
-}
-
-/*
- * nv_alloc_ctrl_handles() - allocate a new CtrlHandles structure,
- * connect to the X server identified by display, and initialize an
- * NvCtrlAttributeHandle for each possible target (X screens, gpus,
- * FrameLock devices).
- */
-
-static CtrlHandles *nv_alloc_ctrl_handles(const char *display)
-{
- ReturnStatus status;
- CtrlHandles *h, *pQueryHandle = NULL;
- int i, j, val, len;
- int *pData = NULL;
-
- /* allocate the CtrlHandles struct */
-
- h = nvalloc(sizeof(CtrlHandles));
-
- /* store any given X display name */
-
- if (display) {
- h->display = strdup(display);
- } else {
- h->display = NULL;
- }
-
- /* open the X display connection */
-
- h->dpy = XOpenDisplay(h->display);
-
- if (!h->dpy) {
- nv_error_msg("Cannot open display '%s'.", XDisplayName(h->display));
- return h;
- }
-
- /*
- * loop over each target type and setup the appropriate
- * information
- */
-
- for (j = 0; j < targetTypeTableLen; j++) {
- const TargetTypeEntry *targetTypeEntry = &targetTypeTable[j];
- int target = targetTypeEntry->target_index;
- CtrlHandleTargets *targets = &(h->targets[target]);
-
- /*
- * get the number of targets of this type; if this is an X
- * screen target, just use Xlib's ScreenCount() (note: to
- * support Xinerama: we'll want to use
- * NvCtrlQueryTargetCount() rather than ScreenCount()); for
- * other target types, use NvCtrlQueryTargetCount().
- */
-
- if (target == X_SCREEN_TARGET) {
-
- targets->n = ScreenCount(h->dpy);
-
- } else {
-
- /*
- * note: pQueryHandle should be assigned below by a
- * previous iteration of this loop; depends on X screen
- * targets getting handled first
- */
-
- if (pQueryHandle) {
-
- /*
- * check that the NV-CONTROL protocol is new enough to
- * recognize this target type
- */
-
- ReturnStatus ret1, ret2;
- int major, minor;
-
- ret1 = NvCtrlGetAttribute(pQueryHandle,
- NV_CTRL_ATTR_NV_MAJOR_VERSION,
- &major);
- ret2 = NvCtrlGetAttribute(pQueryHandle,
- NV_CTRL_ATTR_NV_MINOR_VERSION,
- &minor);
-
- if ((ret1 == NvCtrlSuccess) && (ret2 == NvCtrlSuccess) &&
- ((major > targetTypeEntry->major) ||
- ((major == targetTypeEntry->major) &&
- (minor >= targetTypeEntry->minor)))) {
-
- if (target != DISPLAY_TARGET) {
- status = NvCtrlQueryTargetCount
- (pQueryHandle, targetTypeEntry->nvctrl,
- &val);
- } else {
- /* For targets that aren't simply enumerated,
- * query the list of valid IDs in pData which
- * will be used below
- */
- status =
- NvCtrlGetBinaryAttribute(pQueryHandle, 0,
- NV_CTRL_BINARY_DATA_DISPLAY_TARGETS,
- (unsigned char **)(&pData), &len);
- if (status == NvCtrlSuccess) {
- val = pData[0];
- }
- }
- } else {
- status = NvCtrlMissingExtension;
- }
- } else {
- status = NvCtrlMissingExtension;
- }
-
- if (status != NvCtrlSuccess) {
- nv_warning_msg("Unable to determine number of NVIDIA "
- "%ss on '%s'.",
- targetTypeEntry->name,
- XDisplayName(h->display));
- val = 0;
- }
-
- targets->n = val;
- }
-
- /* if there are no targets of this type, skip */
-
- if (targets->n == 0) {
- goto next_target_type;
- }
-
- /* allocate an array of CtrlHandleTarget's */
-
- targets->t = nvalloc(targets->n * sizeof(CtrlHandleTarget));
-
- /*
- * loop over all the targets of this type and setup the
- * CtrlHandleTarget's
- */
-
- for (i = 0; i < targets->n; i++) {
- CtrlHandleTarget *t = &(targets->t[i]);
- int targetId;
-
- switch (target) {
- case DISPLAY_TARGET:
- /* Grab the target Id from the pData list */
- targetId = pData[i+1];
- break;
- case X_SCREEN_TARGET:
- case GPU_TARGET:
- case FRAMELOCK_TARGET:
- case VCS_TARGET:
- case GVI_TARGET:
- case COOLER_TARGET:
- case THERMAL_SENSOR_TARGET:
- case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET:
- default:
- targetId = i;
- }
-
- nv_init_target(h->dpy, t, target, targetId);
-
- /*
- * store this handle, if it exists, so that we can use it to
- * query other target counts later
- */
-
- if (!pQueryHandle && t->h) {
- pQueryHandle = t->h;
- }
- }
-
- next_target_type:
- if (pData) {
- XFree(pData);
- pData = NULL;
- }
- }
-
-
- /* Load relationships to other targets */
-
- for (i = 0; i < MAX_TARGET_TYPES; i++) {
- CtrlHandleTargets *targets = &(h->targets[i]);
- for (j = 0; j < targets->n; j++) {
- CtrlHandleTarget *t = &(targets->t[j]);
- load_target_relationships(h, t);
- }
- }
-
- return h;
-
-} /* nv_alloc_ctrl_handles() */
-
-
-/*
- * nv_alloc_ctrl_handles_and_add_to_array() - if it doesn't exist, allocate a new
- * CtrlHandles structure via nv_alloc_ctrl_handles and add it to the
- * CtrlHandlesArray given and return the newly allocated handle. If it
- * does exist, simply return the existing handle.
- */
-
-CtrlHandles *
- nv_alloc_ctrl_handles_and_add_to_array(const char *display,
- CtrlHandlesArray *handles_array)
-{
- CtrlHandles *handle = nv_get_ctrl_handles(display, handles_array);
-
- if (handle == NULL) {
- handle = nv_alloc_ctrl_handles(display);
-
- if (handle) {
- handles_array->array = nvrealloc(handles_array->array,
- sizeof(CtrlHandles *)
- * (handles_array->n + 1));
- handles_array->array[handles_array->n] = handle;
- handles_array->n++;
- }
- }
-
- return handle;
-}
-
-
-
-/*
- * nv_free_ctrl_handles() - free the CtrlHandles structure allocated
- * by nv_alloc_ctrl_handles()
- */
-
-static void nv_free_ctrl_handles(CtrlHandles *h)
-{
- if (!h) return;
-
- if (h->display) free(h->display);
-
- if (h->dpy) {
- int i;
-
- /*
- * XXX It is unfortunate that the display connection needs
- * to be closed before the backends have had a chance to
- * tear down their state. If future backends need to send
- * protocol in this case or perform similar tasks, we'll
- * have to add e.g. NvCtrlAttributeTearDown(), which would
- * need to be called before XCloseDisplay().
- */
- XCloseDisplay(h->dpy);
- h->dpy = NULL;
-
- for (i = 0; i < targetTypeTableLen; i++) {
-
- CtrlHandleTargets *targets =
- &(h->targets[targetTypeTable[i].target_index]);
- int j;
-
- for (j = 0; j < targets->n; j++) {
- CtrlHandleTarget *t = &(targets->t[j]);
- int n;
-
- NvCtrlAttributeClose(t->h);
- free(t->name);
- for (n = 0; n < NV_PROTO_NAME_MAX; n++) {
- if (t->protoNames[n]) {
- XFree(t->protoNames[n]);
- }
- }
-
- memset(t, 0, sizeof(*t));
- }
- free(targets->t);
- }
- }
- free(h);
-
-} /* nv_free_ctrl_handles() */
-
-
-/*
- * nv_free_ctrl_handles_array() - free an array of CtrlHandles.
- */
-
-void nv_free_ctrl_handles_array(CtrlHandlesArray *handles_array)
-{
- int i;
-
- for (i = 0; i < handles_array->n; i++) {
- nv_free_ctrl_handles(handles_array->array[i]);
- }
-
- if (handles_array->array) {
- free(handles_array->array);
- }
-
- handles_array->n = 0;
- handles_array->array = NULL;
-}
-
-
-/*
- * nv_get_ctrl_handles() - return the CtrlHandles matching the given string.
- */
-CtrlHandles *nv_get_ctrl_handles(const char *display,
- CtrlHandlesArray *handles_array)
-{
- int i;
-
- for (i=0; i < handles_array->n; i++) {
- if (nv_strcasecmp(display, handles_array->array[i]->display)) {
- return handles_array->array[i];
- }
- }
-
- return NULL;
-}
-
/*!
- * Adds all the targets of the target type (specified via a target type index)
- * to the list of targets to process for the ParsedAttribute.
+ * Adds all the targets of the specified target type to the list of targets to
+ * process for the ParsedAttribute.
*
- * \param[in/out] p The ParsedAttribute to add targets to.
- * \param[in] h The list of targets to add from.
- * \param[in] targetIdx The target type index of the targets to add.
+ * \param[in/out] p The ParsedAttribute to add targets to.
+ * \param[in] system The CtrlSystem who's targets to include.
+ * \param[in] target_type The target type of the targets to add.
*/
-static void include_target_idx_targets(ParsedAttribute *p, const CtrlHandles *h,
- int targetIdx)
+static void include_target_type_targets(ParsedAttribute *p,
+ const CtrlSystem *system,
+ int target_type)
{
- const CtrlHandleTargets *targets = &(h->targets[targetIdx]);
- int i;
+ CtrlTargetNode *node;
- for (i = 0; i < targets->n; i++) {
- CtrlHandleTarget *target = &(targets->t[i]);
- nv_target_list_add(&(p->targets), target, TRUE);
- p->parser_flags.has_target = NV_TRUE;
- }
-}
+ for (node = system->targets[target_type]; node; node = node->next) {
+ CtrlTarget *target = node->t;
-
-/*!
- * Queries the permissions for the given attribute.
- *
- * \param[in] h CtrlHandles used to communicate with the X server.
- * \param[in] attr The attribute to query permissions for.
- * \param[in] flags The attribute flags to query permissions for.
- * \param[out] perms The permissions of the attribute.
- *
- * \return Returns TRUE if the permissions were queried successfully; else,
- * returns FALSE.
- */
-Bool nv_get_attribute_perms(CtrlHandles *h, const AttributeTableEntry *a,
- NVCTRLAttributePermissionsRec *perms)
-{
- memset(perms, 0, sizeof(*perms));
-
- switch (a->type) {
-
- case NV_PARSER_ATTRIBUTE_TYPE_INTEGER:
- return XNVCTRLQueryAttributePermissions(h->dpy, a->attr, perms);
-
- case NV_PARSER_ATTRIBUTE_TYPE_STRING:
- return XNVCTRLQueryStringAttributePermissions(h->dpy, a->attr, perms);
-
- case NV_PARSER_ATTRIBUTE_TYPE_STRING_OPERATION:
- return XNVCTRLQueryStringOperationAttributePermissions(h->dpy, a->attr,
- perms);
-
- case NV_PARSER_ATTRIBUTE_TYPE_COLOR:
- /* Allow non NV-CONTROL attributes to be read/written on X screen
- * targets
- */
- perms->type = ATTRIBUTE_TYPE_INTEGER;
- perms->permissions =
- ATTRIBUTE_TYPE_READ |
- ATTRIBUTE_TYPE_WRITE |
- ATTRIBUTE_TYPE_X_SCREEN;
- return TRUE;
-
- case NV_PARSER_ATTRIBUTE_TYPE_SDI_CSC:
- /* Allow SDI CSC matrix to be read/written on X screen targets */
- perms->type = ATTRIBUTE_TYPE_INTEGER;
- perms->permissions =
- ATTRIBUTE_TYPE_READ |
- ATTRIBUTE_TYPE_WRITE |
- ATTRIBUTE_TYPE_X_SCREEN;
- return TRUE;
+ NvCtrlTargetListAdd(&(p->targets), target, TRUE);
+ p->parser_flags.has_target = NV_TRUE;
}
-
- /* We shouldn't get here */
- return FALSE;
}
@@ -1458,8 +473,8 @@ Bool nv_get_attribute_perms(CtrlHandles *h, const AttributeTableEntry *a,
static void resolve_display_mask_string(ParsedAttribute *p, const char *whence)
{
- CtrlHandleTargetNode *head = NULL;
- CtrlHandleTargetNode *n;
+ CtrlTargetNode *head = NULL;
+ CtrlTargetNode *n;
int bit, i;
@@ -1510,43 +525,39 @@ static void resolve_display_mask_string(ParsedAttribute *p, const char *whence)
/* Look at attribute's target list... */
for (n = p->targets; n; n = n->next) {
- CtrlHandleTarget *t = n->t;
- CtrlHandleTargetNode *n_other;
- int target_type;
+ CtrlTarget *t = n->t;
+ CtrlTargetNode *n_other;
if (!t->h) {
continue;
}
- target_type = NvCtrlGetTargetType(t->h);
-
/* Include display targets that were previously resolved */
- if (target_type == NV_CTRL_TARGET_TYPE_DISPLAY) {
- nv_target_list_add(&head, t, TRUE);
+ if (NvCtrlGetTargetType(t) == DISPLAY_TARGET) {
+ NvCtrlTargetListAdd(&head, t, TRUE);
continue;
}
/* Include non-display target's related display targets, if any */
for (n_other = t->relations; n_other; n_other = n_other->next) {
- CtrlHandleTarget *t_other = n_other->t;
+ CtrlTarget *t_other = n_other->t;
if (!t_other->h) {
continue;
}
- target_type = NvCtrlGetTargetType(t_other->h);
- if (target_type != NV_CTRL_TARGET_TYPE_DISPLAY) {
+ if (NvCtrlGetTargetType(t_other) != DISPLAY_TARGET) {
continue;
}
/* Include all displays if no specification was given */
if (!p->parser_flags.has_display_device) {
- nv_target_list_add(&head, t_other, TRUE);
+ NvCtrlTargetListAdd(&head, t_other, TRUE);
continue;
}
for (i = 0; i < num_names; i++) {
if (nv_target_has_name(t_other, name_toks[i])) {
- nv_target_list_add(&head, t_other, TRUE);
+ NvCtrlTargetListAdd(&head, t_other, TRUE);
break;
}
}
@@ -1559,7 +570,7 @@ static void resolve_display_mask_string(ParsedAttribute *p, const char *whence)
}
/* Apply the new targets list */
- nv_target_list_free(p->targets);
+ NvCtrlTargetListFree(p->targets);
p->targets = head;
}
@@ -1567,17 +578,18 @@ static void resolve_display_mask_string(ParsedAttribute *p, const char *whence)
/*!
* Converts the ParsedAttribute 'a''s target specification (and/or target type
- * + id) into a list of CtrlHandleTarget to operate on. If the ParsedAttribute
- * has a target specification set, this is used to generate the list; Otherwise,
- * the target type and target id are used. If nothing is specified, all the
- * valid targets for the attribute are included.
+ * + id) into a list of CtrlTarget to operate on. If the ParsedAttribute has a
+ * target specification set, this is used to generate the list; Otherwise, the
+ * target type and target id are used. If nothing is specified, all the valid
+ * targets for the attribute are included.
*
* If this is a display attribute, and a (legacy) display mask string is given,
* all non-display targets are further resolved into the corresponding display
* targets that match the names represented by the display mask string.
*
- * \param[in/out] p ParsedAttribute to resolve.
- * \param[in] h CtrlHandles to resolve the target specification against.
+ * \param[in/out] p ParsedAttribute to resolve.
+ * \param[in] system CtrlSystem to resolve the target specification
+ * against.
*
* \return Return NV_PARSER_STATUS_SUCCESS if the attribute's target
* specification was successfully parsed into a list of targets to
@@ -1585,11 +597,12 @@ static void resolve_display_mask_string(ParsedAttribute *p, const char *whence)
* error codes that detail the particular parsing error.
*/
-static int resolve_attribute_targets(ParsedAttribute *p, CtrlHandles *h,
+static int resolve_attribute_targets(ParsedAttribute *p, CtrlSystem *system,
const char *whence)
{
- NVCTRLAttributePermissionsRec perms;
- Bool status;
+ CtrlAttributePerms perms;
+ CtrlTarget *ctrl_target;
+ ReturnStatus status;
int ret = NV_PARSER_STATUS_SUCCESS;
int i;
@@ -1601,8 +614,13 @@ static int resolve_attribute_targets(ParsedAttribute *p, CtrlHandles *h,
return NV_PARSER_STATUS_BAD_ARGUMENT;
}
- status = nv_get_attribute_perms(h, a, &perms);
- if (!status) {
+ ctrl_target = NvCtrlGetDefaultTarget(system);
+ if (ctrl_target == NULL) {
+ return NV_PARSER_STATUS_TARGET_SPEC_NO_TARGETS;
+ }
+
+ status = NvCtrlGetAttributePerms(ctrl_target, a->type, a->attr, &perms);
+ if (status != NvCtrlSuccess) {
// XXX Throw other error here...?
return NV_PARSER_STATUS_TARGET_SPEC_NO_TARGETS;
}
@@ -1615,20 +633,21 @@ static int resolve_attribute_targets(ParsedAttribute *p, CtrlHandles *h,
* list of targets to include.
*/
if (p->target_specification) {
- ret = nv_infer_targets_from_specification(p, h);
+ ret = nv_infer_targets_from_specification(p, system);
goto done;
}
/* If the target type and target id was given, use that. */
- if (p->target_type >= 0 && p->target_id >= 0) {
- CtrlHandleTarget *target = nv_get_target(h, p->target_type,
- p->target_id);
+ if (NvCtrlIsTargetTypeValid(p->target_type) && p->target_id >= 0) {
+ CtrlTarget *target = NvCtrlGetTarget(system, p->target_type,
+ p->target_id);
+
if (!target) {
return NV_PARSER_STATUS_TARGET_SPEC_NO_TARGETS;
}
- nv_target_list_add(&(p->targets), target, TRUE);
+ NvCtrlTargetListAdd(&(p->targets), target, TRUE);
p->parser_flags.has_target = NV_TRUE;
goto done;
}
@@ -1637,31 +656,22 @@ static int resolve_attribute_targets(ParsedAttribute *p, CtrlHandles *h,
/* If a target type was given, but no target id, process all the targets
* of that type.
*/
- if (p->target_type >= 0) {
- const TargetTypeEntry *targetTypeEntry =
- nv_get_target_type_entry_by_nvctrl(p->target_type);
-
- if (!targetTypeEntry) {
- return NV_PARSER_STATUS_TARGET_SPEC_BAD_TARGET;
- }
-
- include_target_idx_targets(p, h, targetTypeEntry->target_index);
+ if (NvCtrlIsTargetTypeValid(p->target_type)) {
+ include_target_type_targets(p, system, p->target_type);
goto done;
}
/* If no target type was given, assume all the appropriate targets for the
- * attribute by querying its permissions.
+ * attribute based on its permissions.
*/
for (i = 0; i < MAX_TARGET_TYPES; i++) {
- int permBit = targetTypeTable[i].permission_bit;
-
- if (!(perms.permissions & permBit)) {
+ if (!(perms.valid_targets & CTRL_TARGET_PERM_BIT(i))) {
continue;
}
/* Add all targets of type that are valid for this attribute */
- include_target_idx_targets(p, h, i);
+ include_target_type_targets(p, system, i);
}
done:
@@ -1672,7 +682,7 @@ static int resolve_attribute_targets(ParsedAttribute *p, CtrlHandles *h,
* displays added, otherwise include all related display targets.
*/
if (!(a->flags.hijack_display_device) &&
- (perms.permissions & ATTRIBUTE_TYPE_DISPLAY)) {
+ (perms.valid_targets & CTRL_TARGET_PERM_BIT(DISPLAY_TARGET))) {
resolve_display_mask_string(p, whence);
}
@@ -1699,12 +709,12 @@ static int resolve_attribute_targets(ParsedAttribute *p, CtrlHandles *h,
static int process_attribute_queries(const Options *op,
int num, char **queries,
const char *display_name,
- CtrlHandlesArray *handles_array)
+ CtrlSystemList *systems)
{
int query, ret, val;
ParsedAttribute a;
- CtrlHandles *h;
-
+ CtrlSystem *system;
+
val = NV_FALSE;
/* print a newline before we begin */
@@ -1720,7 +730,7 @@ static int process_attribute_queries(const Options *op,
/* special case the "all" query */
if (nv_strcasecmp(queries[query], "all")) {
- query_all(op, display_name, handles_array);
+ query_all(op, display_name, systems);
continue;
}
@@ -1728,49 +738,49 @@ static int process_attribute_queries(const Options *op,
if (nv_strcasecmp(queries[query], "screens") ||
nv_strcasecmp(queries[query], "xscreens")) {
- query_all_targets(display_name, X_SCREEN_TARGET, handles_array);
+ query_all_targets(display_name, X_SCREEN_TARGET, systems);
continue;
}
if (nv_strcasecmp(queries[query], "gpus")) {
- query_all_targets(display_name, GPU_TARGET, handles_array);
+ query_all_targets(display_name, GPU_TARGET, systems);
continue;
}
if (nv_strcasecmp(queries[query], "framelocks")) {
- query_all_targets(display_name, FRAMELOCK_TARGET, handles_array);
+ query_all_targets(display_name, FRAMELOCK_TARGET, systems);
continue;
}
if (nv_strcasecmp(queries[query], "vcs")) {
- query_all_targets(display_name, VCS_TARGET, handles_array);
+ query_all_targets(display_name, VCS_TARGET, systems);
continue;
}
if (nv_strcasecmp(queries[query], "gvis")) {
- query_all_targets(display_name, GVI_TARGET, handles_array);
+ query_all_targets(display_name, GVI_TARGET, systems);
continue;
}
if (nv_strcasecmp(queries[query], "fans")) {
- query_all_targets(display_name, COOLER_TARGET, handles_array);
+ query_all_targets(display_name, COOLER_TARGET, systems);
continue;
}
if (nv_strcasecmp(queries[query], "thermalsensors")) {
- query_all_targets(display_name, THERMAL_SENSOR_TARGET, handles_array);
+ query_all_targets(display_name, THERMAL_SENSOR_TARGET, systems);
continue;
}
if (nv_strcasecmp(queries[query], "svps")) {
query_all_targets(display_name,
NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET,
- handles_array);
+ systems);
continue;
}
if (nv_strcasecmp(queries[query], "dpys")) {
- query_all_targets(display_name, DISPLAY_TARGET, handles_array);
+ query_all_targets(display_name, DISPLAY_TARGET, systems);
continue;
}
@@ -1787,16 +797,16 @@ static int process_attribute_queries(const Options *op,
nv_assign_default_display(&a, display_name);
- /* allocate the CtrlHandles */
+ /* connect to all the systems */
- h = nv_alloc_ctrl_handles_and_add_to_array(a.display, handles_array);
- if (!h) {
+ system = NvCtrlConnectToSystem(a.display, systems);
+ if (!system) {
goto done;
}
/* call the processing engine to process the parsed query */
- ret = nv_process_parsed_attribute(op, &a, h, NV_FALSE, NV_FALSE,
+ ret = nv_process_parsed_attribute(op, &a, system, NV_FALSE, NV_FALSE,
"in query '%s'", queries[query]);
if (ret == NV_FALSE) goto done;
@@ -1829,11 +839,11 @@ static int process_attribute_queries(const Options *op,
static int process_attribute_assignments(const Options *op,
int num, char **assignments,
const char *display_name,
- CtrlHandlesArray *handles_array)
+ CtrlSystemList *systems)
{
int assignment, ret, val;
ParsedAttribute a;
- CtrlHandles *h;
+ CtrlSystem *system;
val = NV_FALSE;
@@ -1860,16 +870,16 @@ static int process_attribute_assignments(const Options *op,
nv_assign_default_display(&a, display_name);
- /* allocate the CtrlHandles */
+ /* allocate the CtrlSystem */
- h = nv_alloc_ctrl_handles_and_add_to_array(a.display, handles_array);
- if (!h) {
+ system = NvCtrlConnectToSystem(a.display, systems);
+ if (!system) {
goto done;
}
/* call the processing engine to process the parsed assignment */
- ret = nv_process_parsed_attribute(op, &a, h, NV_TRUE, NV_TRUE,
+ ret = nv_process_parsed_attribute(op, &a, system, NV_TRUE, NV_TRUE,
"in assignment '%s'",
assignments[assignment]);
if (ret == NV_FALSE) goto done;
@@ -1895,7 +905,7 @@ static int process_attribute_assignments(const Options *op,
* attribute, and check that the value to be assigned is valid.
*/
-static int validate_value(const Options *op, CtrlHandleTarget *t,
+static int validate_value(const Options *op, CtrlTarget *t,
ParsedAttribute *p, uint32 d, int target_type,
char *whence)
{
@@ -1904,21 +914,21 @@ static int validate_value(const Options *op, CtrlHandleTarget *t,
ReturnStatus status;
char d_str[256];
char *tmp_d_str;
- const TargetTypeEntry *targetTypeEntry;
+ const CtrlTargetTypeInfo *targetTypeInfo;
const AttributeTableEntry *a = p->attr_entry;
- if (a->type != NV_PARSER_ATTRIBUTE_TYPE_INTEGER) {
+ if (a->type != CTRL_ATTRIBUTE_TYPE_INTEGER) {
return NV_FALSE;
}
- status = NvCtrlGetValidDisplayAttributeValues(t->h, d, a->attr, &valid);
+ status = NvCtrlGetValidDisplayAttributeValues(t, d, a->attr, &valid);
if (status != NvCtrlSuccess) {
nv_error_msg("Unable to query valid values for attribute %s (%s).",
a->name, NvCtrlAttributesStrError(status));
return NV_FALSE;
}
- if (target_type != NV_CTRL_TARGET_TYPE_DISPLAY &&
+ if (target_type != DISPLAY_TARGET &&
valid.permissions & ATTRIBUTE_TYPE_DISPLAY) {
tmp_d_str = display_device_mask_to_display_device_name(d);
sprintf(d_str, ", display device: %s", tmp_d_str);
@@ -1926,7 +936,7 @@ static int validate_value(const Options *op, CtrlHandleTarget *t,
} else {
d_str[0] = '\0';
}
-
+
switch (valid.type) {
case ATTRIBUTE_TYPE_INTEGER:
case ATTRIBUTE_TYPE_BITMASK:
@@ -1975,9 +985,9 @@ static int validate_value(const Options *op, CtrlHandleTarget *t,
/* is this value available for this target type? */
- targetTypeEntry = nv_get_target_type_entry_by_nvctrl(target_type);
- if (!targetTypeEntry ||
- !(targetTypeEntry->permission_bit & valid.permissions)) {
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(target_type);
+ if (!targetTypeInfo ||
+ !(targetTypeInfo->permission_bit & valid.permissions)) {
bad_val = NV_TRUE;
}
@@ -2039,7 +1049,7 @@ static void print_valid_values(const Options *op, const AttributeTableEntry *a,
break;
case ATTRIBUTE_TYPE_INTEGER:
- if ((a->type == NV_PARSER_ATTRIBUTE_TYPE_INTEGER) &&
+ if ((a->type == CTRL_ATTRIBUTE_TYPE_INTEGER) &&
a->f.int_flags.is_packed) {
nv_msg(INDENT, "'%s' is a packed integer attribute.", name);
} else {
@@ -2057,7 +1067,7 @@ static void print_valid_values(const Options *op, const AttributeTableEntry *a,
break;
case ATTRIBUTE_TYPE_RANGE:
- if ((a->type == NV_PARSER_ATTRIBUTE_TYPE_INTEGER) &&
+ if ((a->type == CTRL_ATTRIBUTE_TYPE_INTEGER) &&
a->f.int_flags.is_packed) {
nv_msg(INDENT, "The valid values for '%s' are in the ranges "
"%" PRId64 " - %" PRId64 ", %" PRId64 " - %" PRId64
@@ -2079,7 +1089,7 @@ static void print_valid_values(const Options *op, const AttributeTableEntry *a,
for (bit = 0; bit < 32; bit++) {
if (valid.u.bits.ints & (1 << bit)) {
if ((bit > 15) &&
- (a->type == NV_PARSER_ATTRIBUTE_TYPE_INTEGER) &&
+ (a->type == CTRL_ATTRIBUTE_TYPE_INTEGER) &&
a->f.int_flags.is_packed) {
last2 = bit;
} else {
@@ -2097,7 +1107,7 @@ static void print_valid_values(const Options *op, const AttributeTableEntry *a,
for (bit = 0; bit < 32; bit++) {
if ((bit > 15) &&
- (a->type == NV_PARSER_ATTRIBUTE_TYPE_INTEGER) &&
+ (a->type == CTRL_ATTRIBUTE_TYPE_INTEGER) &&
a->f.int_flags.is_packed) {
print_bit = bit - 16;
at = &c2;
@@ -2117,7 +1127,7 @@ static void print_valid_values(const Options *op, const AttributeTableEntry *a,
}
}
- if ((a->type == NV_PARSER_ATTRIBUTE_TYPE_INTEGER) &&
+ if ((a->type == CTRL_ATTRIBUTE_TYPE_INTEGER) &&
a->f.int_flags.is_packed) {
nv_msg(INDENT, "Valid values for '%s' are: [%s], [%s].", name, str2,
str);
@@ -2140,10 +1150,13 @@ static void print_valid_values(const Options *op, const AttributeTableEntry *a,
c = str;
n = 0;
- for (i = 0; i < targetTypeTableLen; i++) {
- if (valid.permissions & targetTypeTable[i].permission_bit) {
+ for (i = 0; i < MAX_TARGET_TYPES; i++) {
+ const CtrlTargetTypeInfo *targetTypeInfo =
+ NvCtrlGetTargetTypeInfo(i);
+
+ if (valid.permissions & targetTypeInfo->permission_bit) {
if (n > 0) c += sprintf(c, ", ");
- c += sprintf(c, "%s", targetTypeTable[i].name);
+ c += sprintf(c, "%s", targetTypeInfo->name);
n++;
}
}
@@ -2154,7 +1167,7 @@ static void print_valid_values(const Options *op, const AttributeTableEntry *a,
name, str);
if (nv_get_verbosity() >= NV_VERBOSITY_ALL) {
- if (a->type == NV_PARSER_ATTRIBUTE_TYPE_INTEGER) {
+ if (a->type == CTRL_ATTRIBUTE_TYPE_INTEGER) {
print_additional_info(name, a->attr, valid, INDENT);
}
}
@@ -2177,8 +1190,7 @@ typedef enum {
} VerboseLevel;
static void print_queried_value(const Options *op,
- const CtrlHandles *handles,
- CtrlHandleTarget *t,
+ CtrlTarget *target,
NVCTRLAttributeValidValuesRec *v,
int val,
const AttributeTableEntry *a,
@@ -2188,14 +1200,14 @@ static void print_queried_value(const Options *op,
{
char d_str[64], val_str[64], *tmp_d_str;
- if (a->type != NV_PARSER_ATTRIBUTE_TYPE_INTEGER) {
+ if (a->type != CTRL_ATTRIBUTE_TYPE_INTEGER) {
return;
}
/* assign val_str */
if (a->f.int_flags.is_display_id && op->dpy_string) {
- const char *name = nv_get_display_target_config_name(handles, val);
+ const char *name = NvCtrlGetDisplayConfigName(target->system, val);
if (name) {
snprintf(val_str, 64, "%s", name);
} else {
@@ -2219,7 +1231,7 @@ static void print_queried_value(const Options *op,
/* append the display device name, if necessary */
- if ((NvCtrlGetTargetType(t->h) != NV_CTRL_TARGET_TYPE_DISPLAY) &&
+ if ((NvCtrlGetTargetType(target) != DISPLAY_TARGET) &&
v->permissions & ATTRIBUTE_TYPE_DISPLAY) {
tmp_d_str = display_device_mask_to_display_device_name(mask);
snprintf(d_str, 64, "; display device: %s", tmp_d_str);
@@ -2248,7 +1260,7 @@ static void print_queried_value(const Options *op,
* attribute
*/
nv_msg(indent, "Attribute '%s' (%s%s): %s.",
- a->name, t->name, d_str, val_str);
+ a->name, target->name, d_str, val_str);
break;
}
@@ -2352,16 +1364,16 @@ static void print_additional_info(const char *name,
*/
static int query_all(const Options *op, const char *display_name,
- CtrlHandlesArray *handles_array)
+ CtrlSystemList *systems)
{
int bit, entry, val, i;
uint32 mask;
ReturnStatus status;
NVCTRLAttributeValidValuesRec valid;
- CtrlHandles *h;
+ CtrlSystem *system;
- h = nv_alloc_ctrl_handles_and_add_to_array(display_name, handles_array);
- if (!h) {
+ system = NvCtrlConnectToSystem(display_name, systems);
+ if (!system) {
return NV_FALSE;
}
@@ -2371,14 +1383,13 @@ static int query_all(const Options *op, const char *display_name,
* Loop through all target types.
*/
- for (i = 0; i < targetTypeTableLen; i++) {
- CtrlHandleTargets *targets =
- &(h->targets[targetTypeTable[i].target_index]);
- int j;
+ for (i = 0; i < MAX_TARGET_TYPES; i++) {
+ CtrlTargetNode *node;
+ const CtrlTargetTypeInfo *targetTypeInfo = NvCtrlGetTargetTypeInfo(i);
- for (j = 0; j < targets->n; j++) {
- CtrlHandleTarget *t = &targets->t[j];
+ for (node = system->targets[i]; node; node = node->next) {
+ CtrlTarget *t = node->t;
if (!t->h) continue;
@@ -2393,7 +1404,7 @@ static int query_all(const Options *op, const char *display_name,
/* skip the color attributes */
- if (a->type == NV_PARSER_ATTRIBUTE_TYPE_COLOR) {
+ if (a->type == CTRL_ATTRIBUTE_TYPE_COLOR) {
continue;
}
@@ -2412,14 +1423,17 @@ static int query_all(const Options *op, const char *display_name,
* display devices), skip to the next bit
*/
- if (targetTypeTable[i].uses_display_devices &&
+ if (targetTypeInfo->uses_display_devices &&
((t->d & mask) == 0x0) && (t->d)) continue;
- if (a->type == NV_PARSER_ATTRIBUTE_TYPE_STRING) {
+ if (a->type == CTRL_ATTRIBUTE_TYPE_STRING) {
char *tmp_str = NULL;
- status = NvCtrlGetValidStringDisplayAttributeValues(t->h, mask,
- a->attr, &valid);
+ status =
+ NvCtrlGetValidStringDisplayAttributeValues(t,
+ mask,
+ a->attr,
+ &valid);
if (status == NvCtrlAttributeNotAvailable) {
goto exit_bit_loop;
}
@@ -2432,7 +1446,10 @@ static int query_all(const Options *op, const char *display_name,
goto exit_bit_loop;
}
- status = NvCtrlGetStringDisplayAttribute(t->h, mask, a->attr, &tmp_str);
+ status = NvCtrlGetStringDisplayAttribute(t,
+ mask,
+ a->attr,
+ &tmp_str);
if (status == NvCtrlAttributeNotAvailable) {
goto exit_bit_loop;
@@ -2456,9 +1473,14 @@ static int query_all(const Options *op, const char *display_name,
} else {
- status = NvCtrlGetValidDisplayAttributeValues(t->h, mask, a->attr, &valid);
+ status = NvCtrlGetValidDisplayAttributeValues(t,
+ mask,
+ a->attr,
+ &valid);
- if (status == NvCtrlAttributeNotAvailable) goto exit_bit_loop;
+ if (status == NvCtrlAttributeNotAvailable) {
+ goto exit_bit_loop;
+ }
if (status != NvCtrlSuccess) {
nv_error_msg("Error while querying valid values for "
@@ -2468,9 +1490,12 @@ static int query_all(const Options *op, const char *display_name,
goto exit_bit_loop;
}
- status = NvCtrlGetDisplayAttribute(t->h, mask, a->attr, &val);
+ status = NvCtrlGetDisplayAttribute(t, mask, a->attr,
+ &val);
- if (status == NvCtrlAttributeNotAvailable) goto exit_bit_loop;
+ if (status == NvCtrlAttributeNotAvailable) {
+ goto exit_bit_loop;
+ }
if (status != NvCtrlSuccess) {
nv_error_msg("Error while querying attribute '%s' "
@@ -2479,7 +1504,7 @@ static int query_all(const Options *op, const char *display_name,
goto exit_bit_loop;
}
- print_queried_value(op, h, t, &valid, val, a, mask,
+ print_queried_value(op, t, &valid, val, a, mask,
INDENT, op->terse ?
VerboseLevelAbbreviated :
VerboseLevelVerbose);
@@ -2522,14 +1547,16 @@ exit_bit_loop:
* product name of the given target.
*/
-static char * get_product_name(NvCtrlAttributeHandle *h, int attr)
+static char *get_product_name(CtrlTarget *ctrl_target, int attr)
{
char *product_name = NULL;
ReturnStatus status;
- status = NvCtrlGetStringAttribute(h, attr, &product_name);
+ status = NvCtrlGetStringAttribute(ctrl_target, attr, &product_name);
- if (status != NvCtrlSuccess) return strdup("Unknown");
+ if (status != NvCtrlSuccess) {
+ return strdup("Unknown");
+ }
return product_name;
}
@@ -2541,7 +1568,7 @@ static char * get_product_name(NvCtrlAttributeHandle *h, int attr)
* display target.
*/
-static char *get_display_product_name(CtrlHandleTarget *t)
+static char *get_display_product_name(CtrlTarget *t)
{
return nvstrdup(t->protoNames[NV_DPY_PROTO_NAME_RANDR]);
}
@@ -2553,7 +1580,7 @@ static char *get_display_product_name(CtrlHandleTarget *t)
* separated string.
*/
-static char *get_display_state_str(CtrlHandleTarget *t)
+static char *get_display_state_str(CtrlTarget *t)
{
char *str = NULL;
@@ -2578,25 +1605,24 @@ static char *get_display_state_str(CtrlHandleTarget *t)
* special handling.
*/
-static int print_target_connections(CtrlHandles *h,
- CtrlHandleTarget *t,
+static int print_target_connections(CtrlTarget *t,
const char *relation_str,
const char *null_relation_str,
unsigned int attrib,
- unsigned int target_index)
+ unsigned int target_type)
{
int *pData;
int len, i;
ReturnStatus status;
- const TargetTypeEntry *targetTypeEntry;
+ const CtrlTargetTypeInfo *targetTypeInfo;
- targetTypeEntry = &(targetTypeTable[target_index]);
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(target_type);
/* Query the connected targets */
status =
- NvCtrlGetBinaryAttribute(t->h, 0, attrib,
+ NvCtrlGetBinaryAttribute(t, 0, attrib,
(unsigned char **) &pData,
&len);
if (status != NvCtrlSuccess) return NV_FALSE;
@@ -2604,49 +1630,47 @@ static int print_target_connections(CtrlHandles *h,
if (pData[0] == 0) {
nv_msg(" ", "%s any %s.",
null_relation_str,
- targetTypeEntry->name);
+ targetTypeInfo->name);
nv_msg(NULL, "");
- XFree(pData);
+ free(pData);
return NV_TRUE;
}
nv_msg(" ", "%s the following %s%s:",
relation_str,
- targetTypeEntry->name,
+ targetTypeInfo->name,
((pData[0] > 1) ? "s" : ""));
/* List the connected targets */
for (i = 1; i <= pData[0]; i++) {
- CtrlHandleTarget *target =
- nv_get_target(h, targetTypeEntry->nvctrl, pData[i]);
+ CtrlTarget *other = NvCtrlGetTarget(t->system, target_type, pData[i]);
char *target_name = NULL;
char *product_name = NULL;
Bool is_x_name = NV_FALSE;
char *extra_str = NULL;
- if (target) {
- target_name = target->name;
+ if (other) {
+ target_name = other->name;
- switch (target_index) {
+ switch (target_type) {
case GPU_TARGET:
product_name =
- get_product_name(target->h, NV_CTRL_STRING_PRODUCT_NAME);
+ get_product_name(other, NV_CTRL_STRING_PRODUCT_NAME);
is_x_name = NV_TRUE;
break;
case VCS_TARGET:
product_name =
- get_product_name(target->h,
- NV_CTRL_STRING_VCSC_PRODUCT_NAME);
+ get_product_name(other, NV_CTRL_STRING_VCSC_PRODUCT_NAME);
is_x_name = NV_TRUE;
break;
case DISPLAY_TARGET:
- product_name = get_display_product_name(target);
- extra_str = get_display_state_str(target);
+ product_name = get_display_product_name(other);
+ extra_str = get_display_state_str(other);
break;
case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET:
@@ -2662,7 +1686,7 @@ static int print_target_connections(CtrlHandles *h,
if (!target_name) {
nv_msg(" ", "Unknown %s",
- targetTypeEntry->name);
+ targetTypeInfo->name);
} else if (product_name) {
nv_msg(" ", "%s (%s)%s%s%s",
@@ -2673,13 +1697,13 @@ static int print_target_connections(CtrlHandles *h,
} else {
nv_msg(" ", "%s (%s %d)",
target_name,
- targetTypeEntry->name,
+ targetTypeInfo->name,
pData[i]);
}
if (product_name) {
if (is_x_name) {
- XFree(product_name);
+ free(product_name);
} else {
nvfree(product_name);
}
@@ -2690,7 +1714,7 @@ static int print_target_connections(CtrlHandles *h,
}
nv_msg(NULL, "");
- XFree(pData);
+ free(pData);
return NV_TRUE;
} /* print_target_connections() */
@@ -2702,83 +1726,85 @@ static int print_target_connections(CtrlHandles *h,
* specified type) accessible via the Display connection.
*/
-static int query_all_targets(const char *display_name, const int target_index,
- CtrlHandlesArray *handles_array)
+static int query_all_targets(const char *display_name, const int target_type,
+ CtrlSystemList *systems)
{
- CtrlHandles *h;
- CtrlHandleTarget *t;
+ CtrlSystem *system;
+ CtrlTargetNode *node;
+ CtrlTarget *t;
char *str, *name;
- int i;
- const TargetTypeEntry *targetTypeEntry;
+ const CtrlTargetTypeInfo *targetTypeInfo;
+ int target_count;
+ int idx;
- targetTypeEntry = &(targetTypeTable[target_index]);
+ targetTypeInfo = NvCtrlGetTargetTypeInfo(target_type);
/* create handles */
- h = nv_alloc_ctrl_handles_and_add_to_array(display_name, handles_array);
- if (!h) {
+ system = NvCtrlConnectToSystem(display_name, systems);
+ if (!system) {
return NV_FALSE;
}
/* build the standard X server name */
-
- str = nv_standardize_screen_name(XDisplayName(h->display), -2);
-
+
+ str = nv_standardize_screen_name(XDisplayName(system->display), -2);
+
/* warn if we don't have any of the target type */
-
- if (h->targets[target_index].n <= 0) {
- nv_warning_msg("No %ss on %s", targetTypeEntry->name, str);
+
+ if (!system->targets[target_type]) {
+ nv_warning_msg("No %ss on %s", targetTypeInfo->name, str);
free(str);
return NV_FALSE;
}
-
+
/* print how many of the target type we have */
-
+
+ target_count = NvCtrlGetTargetTypeCount(system, target_type);
nv_msg(NULL, "%d %s%s on %s",
- h->targets[target_index].n,
- targetTypeEntry->name,
- (h->targets[target_index].n > 1) ? "s" : "",
+ target_count,
+ targetTypeInfo->name,
+ (target_count > 1) ? "s" : "",
str);
nv_msg(NULL, "");
-
+
free(str);
/* print information per target */
- for (i = 0; i < h->targets[target_index].n; i++) {
+ for (node = system->targets[target_type], idx = 0;
+ node;
+ node = node->next, idx++) {
char buff[PRODUCT_NAME_LEN];
- Bool is_x_name = NV_FALSE;
char *product_name = buff;
char *extra_str = NULL;
+ int target_id;
+
+ t = node->t;
- t = &h->targets[target_index].t[i];
+ target_id = NvCtrlGetTargetId(t);
str = NULL;
- if (target_index == NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET) {
- snprintf(product_name, PRODUCT_NAME_LEN,
- "3D Vision Pro Transceiver %d", i);
- } else if (target_index == THERMAL_SENSOR_TARGET) {
- snprintf(product_name, PRODUCT_NAME_LEN,
- "Thermal Sensor %d", i);
- } else if (target_index == COOLER_TARGET) {
- snprintf(product_name, PRODUCT_NAME_LEN,
- "Fan %d", i);
- } else if (target_index == FRAMELOCK_TARGET) {
- snprintf(product_name, PRODUCT_NAME_LEN,
- "Quadro Sync %d", i);
- } else if (target_index == VCS_TARGET) {
- product_name =
- get_product_name(t->h, NV_CTRL_STRING_VCSC_PRODUCT_NAME);
- is_x_name = NV_TRUE;
- } else if (target_index == GVI_TARGET) {
- snprintf(product_name, PRODUCT_NAME_LEN,
- "SDI Input %d", i);
- } else if (target_index == DISPLAY_TARGET) {
+
+ switch (target_type) {
+ case FRAMELOCK_TARGET:
+ case GVI_TARGET:
+ case COOLER_TARGET:
+ case THERMAL_SENSOR_TARGET:
+ case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET:
+ snprintf(product_name, PRODUCT_NAME_LEN, "%s %d",
+ targetTypeInfo->name, target_id);
+ break;
+ case VCS_TARGET:
+ product_name = get_product_name(t, NV_CTRL_STRING_VCSC_PRODUCT_NAME);
+ break;
+ case DISPLAY_TARGET:
product_name = get_display_product_name(t);
extra_str = get_display_state_str(t);
- } else {
- product_name = get_product_name(t->h, NV_CTRL_STRING_PRODUCT_NAME);
- is_x_name = NV_TRUE;
+ break;
+ default:
+ product_name = get_product_name(t, NV_CTRL_STRING_PRODUCT_NAME);
+ break;
}
/*
@@ -2794,7 +1820,8 @@ static int query_all_targets(const char *display_name, const int target_index,
}
nv_msg(" ", "[%d] %s (%s)%s%s%s",
- i, name,
+ idx,
+ name,
product_name,
extra_str ? " (" : "",
extra_str ? extra_str : "",
@@ -2802,11 +1829,7 @@ static int query_all_targets(const char *display_name, const int target_index,
nv_msg(NULL, "");
if (product_name != buff) {
- if (is_x_name) {
- XFree(product_name);
- } else {
- nvfree(product_name);
- }
+ free(product_name);
}
if (extra_str) {
nvfree(extra_str);
@@ -2829,40 +1852,40 @@ static int query_all_targets(const char *display_name, const int target_index,
/* Print connectivity information */
if (nv_get_verbosity() >= NV_VERBOSITY_ALL) {
- switch (target_index) {
+ switch (target_type) {
case GPU_TARGET:
print_target_connections
- (h, t,
+ (t,
"Is driving",
"Is not driving",
NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU,
X_SCREEN_TARGET);
print_target_connections
- (h, t,
+ (t,
"Supports",
"Does not support",
NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU,
DISPLAY_TARGET);
print_target_connections
- (h, t,
+ (t,
"Is connected to",
"Is not connected to",
NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU,
FRAMELOCK_TARGET);
print_target_connections
- (h, t,
+ (t,
"Is connected to",
"Is not connected to",
NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU,
VCS_TARGET);
print_target_connections
- (h, t,
+ (t,
"Is connected to",
"Is not connected to",
NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU,
COOLER_TARGET);
print_target_connections
- (h, t,
+ (t,
"Is connected to",
"Is not connected to",
NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU,
@@ -2871,13 +1894,13 @@ static int query_all_targets(const char *display_name, const int target_index,
case X_SCREEN_TARGET:
print_target_connections
- (h, t,
+ (t,
"Is driven by",
"Is not driven by",
NV_CTRL_BINARY_DATA_GPUS_USED_BY_XSCREEN,
GPU_TARGET);
print_target_connections
- (h, t,
+ (t,
"Is assigned",
"Is not assigned",
NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN,
@@ -2886,7 +1909,7 @@ static int query_all_targets(const char *display_name, const int target_index,
case FRAMELOCK_TARGET:
print_target_connections
- (h, t,
+ (t,
"Is connected to",
"Is not connected to",
NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK,
@@ -2895,7 +1918,7 @@ static int query_all_targets(const char *display_name, const int target_index,
case VCS_TARGET:
print_target_connections
- (h, t,
+ (t,
"Is connected to",
"Is not connected to",
NV_CTRL_BINARY_DATA_GPUS_USING_VCSC,
@@ -2904,7 +1927,7 @@ static int query_all_targets(const char *display_name, const int target_index,
case COOLER_TARGET:
print_target_connections
- (h, t,
+ (t,
"Is connected to",
"Is not connected to",
NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU,
@@ -2913,7 +1936,7 @@ static int query_all_targets(const char *display_name, const int target_index,
case THERMAL_SENSOR_TARGET:
print_target_connections
- (h, t,
+ (t,
"Is connected to",
"Is not connected to",
NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU,
@@ -2925,9 +1948,9 @@ static int query_all_targets(const char *display_name, const int target_index,
}
}
}
-
+
return NV_TRUE;
-
+
} /* query_all_targets() */
@@ -2941,8 +1964,8 @@ static int query_all_targets(const char *display_name, const int target_index,
*/
static int process_parsed_attribute_internal(const Options *op,
- const CtrlHandles *handles,
- CtrlHandleTarget *t,
+ const CtrlSystem *system,
+ CtrlTarget *t,
ParsedAttribute *p, uint32 d,
int target_type, int assign,
int verbose, char *whence,
@@ -2954,7 +1977,7 @@ static int process_parsed_attribute_internal(const Options *op,
int ret;
const AttributeTableEntry *a = p->attr_entry;
- if (target_type != NV_CTRL_TARGET_TYPE_DISPLAY &&
+ if (target_type != DISPLAY_TARGET &&
valid.permissions & ATTRIBUTE_TYPE_DISPLAY) {
tmp_d_str = display_device_mask_to_display_device_name(d);
sprintf(str, ", display device: %s", tmp_d_str);
@@ -2964,14 +1987,14 @@ static int process_parsed_attribute_internal(const Options *op,
}
if (assign) {
- if (a->type == NV_PARSER_ATTRIBUTE_TYPE_STRING) {
- status = NvCtrlSetStringAttribute(t->h, a->attr, p->val.str, NULL);
+ if (a->type == CTRL_ATTRIBUTE_TYPE_STRING) {
+ status = NvCtrlSetStringAttribute(t, a->attr, p->val.str);
} else {
ret = validate_value(op, t, p, d, target_type, whence);
if (!ret) return NV_FALSE;
- status = NvCtrlSetDisplayAttribute(t->h, d, a->attr, p->val.i);
+ status = NvCtrlSetDisplayAttribute(t, d, a->attr, p->val.i);
if (status != NvCtrlSuccess) {
nv_error_msg("Error assigning value %d to attribute '%s' "
@@ -2994,9 +2017,9 @@ static int process_parsed_attribute_internal(const Options *op,
}
} else { /* query */
- if (a->type == NV_PARSER_ATTRIBUTE_TYPE_STRING) {
+ if (a->type == CTRL_ATTRIBUTE_TYPE_STRING) {
char *tmp_str = NULL;
- status = NvCtrlGetStringDisplayAttribute(t->h, d, a->attr,
+ status = NvCtrlGetStringDisplayAttribute(t, d, a->attr,
&tmp_str);
if (status == NvCtrlAttributeNotAvailable) {
@@ -3022,7 +2045,7 @@ static int process_parsed_attribute_internal(const Options *op,
tmp_str = NULL;
}
} else {
- status = NvCtrlGetDisplayAttribute(t->h, d, a->attr, &p->val.i);
+ status = NvCtrlGetDisplayAttribute(t, d, a->attr, &p->val.i);
if (status == NvCtrlAttributeNotAvailable) {
nv_warning_msg("Error querying attribute '%s' specified %s; "
@@ -3036,7 +2059,7 @@ static int process_parsed_attribute_internal(const Options *op,
NvCtrlAttributesStrError(status));
return NV_FALSE;
} else {
- print_queried_value(op, handles, t, &valid, p->val.i, a, d,
+ print_queried_value(op, t, &valid, p->val.i, a, d,
" ", op->terse ?
VerboseLevelTerse : VerboseLevelVerbose);
print_valid_values(op, a, valid);
@@ -3084,11 +2107,6 @@ static int process_parsed_attribute_internal(const Options *op,
* TRUE, then a message will be printed out during each assignment (or
* query).
*
- * The CtrlHandles argument contains an array of
- * NvCtrlAttributeHandle's (one for each target on this X server), as
- * well as the number of targets, an array of enabled display devices
- * for each target, and a string description of each target.
- *
* The whence_fmt and following varargs are used by the callee to
* describe where the attribute came from. A whence string should be
* something like "on line 12 of config file ~/.nvidia-settings-rc" or
@@ -3101,14 +2119,14 @@ static int process_parsed_attribute_internal(const Options *op,
*/
int nv_process_parsed_attribute(const Options *op,
- ParsedAttribute *p, CtrlHandles *h,
+ ParsedAttribute *p, CtrlSystem *system,
int assign, int verbose,
char *whence_fmt, ...)
{
int ret, val;
char *whence, *tmp_d_str0, *tmp_d_str1;
ReturnStatus status;
- CtrlHandleTargetNode *n;
+ CtrlTargetNode *n;
NVCTRLAttributeValidValuesRec valid;
const AttributeTableEntry *a = p->attr_entry;
@@ -3123,7 +2141,7 @@ int nv_process_parsed_attribute(const Options *op,
/* if we don't have a Display connection, abort now */
- if (!h->dpy) {
+ if (system == NULL || system->dpy == NULL) {
nv_error_msg("Unable to %s attribute %s specified %s (no Display "
"connection).", assign ? "assign" : "query",
a->name, whence);
@@ -3143,11 +2161,24 @@ int nv_process_parsed_attribute(const Options *op,
*str ? str : "");
}
- /* Resolve any target specifications against the CtrlHandles that were
+ /* Print not supported messages */
+ if (strncmp(a->desc, "NOT SUPPORTED", 13) == 0) {
+ const char *str = a->desc + 13;
+ while (*str &&
+ (*str == ':' || *str == '.')) {
+ str++;
+ }
+ nv_deprecated_msg("The attribute '%s' is no longer supported%s%s",
+ a->name,
+ *str ? "," : ".",
+ *str ? str : "");
+ goto done;
+ }
+ /* Resolve any target specifications against the CtrlSystem that was
* allocated.
*/
- ret = resolve_attribute_targets(p, h, whence);
+ ret = resolve_attribute_targets(p, system, whence);
if (ret != NV_PARSER_STATUS_SUCCESS) {
nv_error_msg("Error resolving target specification '%s' "
"(%s), specified %s.",
@@ -3168,20 +2199,20 @@ int nv_process_parsed_attribute(const Options *op,
for (n = p->targets; n; n = n->next) {
- CtrlHandleTarget *t = n->t;
+ CtrlTarget *t = n->t;
int target_type;
uint32 mask;
if (!t->h) continue; /* no handle on this target; silently skip */
- target_type = NvCtrlGetTargetType(t->h);
+ target_type = NvCtrlGetTargetType(t);
if (op->list_targets) {
const char *name = t->protoNames[0];
const char *randr_name = NULL;
- if (target_type == NV_CTRL_TARGET_TYPE_DISPLAY) {
+ if (target_type == DISPLAY_TARGET) {
name = t->protoNames[NV_DPY_PROTO_NAME_TARGET_INDEX];
randr_name =t->protoNames[NV_DPY_PROTO_NAME_RANDR];
}
@@ -3200,7 +2231,7 @@ int nv_process_parsed_attribute(const Options *op,
/* special case the color attributes */
- if (a->type == NV_PARSER_ATTRIBUTE_TYPE_COLOR) {
+ if (a->type == CTRL_ATTRIBUTE_TYPE_COLOR) {
float v[3];
if (!assign) {
nv_msg(NULL, "Attribute '%s' cannot be queried.", a->name);
@@ -3215,7 +2246,7 @@ int nv_process_parsed_attribute(const Options *op,
v[0] = v[1] = v[2] = p->val.f;
- status = NvCtrlSetColorAttributes(t->h, v, v, v, a->attr);
+ status = NvCtrlSetColorAttributes(t, v, v, v, a->attr);
if (status != NvCtrlSuccess) {
nv_error_msg("Error assigning %f to attribute '%s' on %s "
@@ -3236,7 +2267,7 @@ int nv_process_parsed_attribute(const Options *op,
*/
if (assign &&
- (a->type == NV_PARSER_ATTRIBUTE_TYPE_INTEGER) &&
+ (a->type == CTRL_ATTRIBUTE_TYPE_INTEGER) &&
a->f.int_flags.is_display_mask) {
char *display_device_descriptor = NULL;
uint32 check_mask;
@@ -3296,10 +2327,9 @@ int nv_process_parsed_attribute(const Options *op,
* int which is ultimately written out to NV-CONTROL.
*/
if (assign &&
- (a->type == NV_PARSER_ATTRIBUTE_TYPE_INTEGER) &&
+ (a->type == CTRL_ATTRIBUTE_TYPE_INTEGER) &&
a->f.int_flags.is_display_id) {
- CtrlHandleTargets *dpy_targets = &(h->targets[DISPLAY_TARGET]);
- int i;
+ CtrlTargetNode *dpy_node;
int found = NV_FALSE;
int multi_match = NV_FALSE;
int is_id;
@@ -3313,12 +2343,14 @@ int nv_process_parsed_attribute(const Options *op,
(tmp != p->val.str) &&
(*tmp == '\0'));
- for (i = 0; i < dpy_targets->n; i++) {
- CtrlHandleTarget *dpy_target = dpy_targets->t + i;
+ for (dpy_node = system->targets[DISPLAY_TARGET];
+ dpy_node;
+ dpy_node = dpy_node->next) {
+ CtrlTarget *dpy_target = dpy_node->t;
if (is_id) {
/* Value given as display device (target) ID */
- if (id == NvCtrlGetTargetId(dpy_target->h)) {
+ if (id == NvCtrlGetTargetId(dpy_target)) {
found = NV_TRUE;
break;
}
@@ -3329,7 +2361,7 @@ int nv_process_parsed_attribute(const Options *op,
multi_match = TRUE;
break;
}
- id = NvCtrlGetTargetId(dpy_target->h);
+ id = NvCtrlGetTargetId(dpy_target);
found = NV_TRUE;
/* Keep looking to make sure the name doesn't alias to
@@ -3368,7 +2400,7 @@ int nv_process_parsed_attribute(const Options *op,
*/
if (assign &&
- (a->type == NV_PARSER_ATTRIBUTE_TYPE_INTEGER) &&
+ (a->type == CTRL_ATTRIBUTE_TYPE_INTEGER) &&
a->f.int_flags.no_zero) {
/* value must be non-zero */
@@ -3400,10 +2432,10 @@ int nv_process_parsed_attribute(const Options *op,
*/
if (a->flags.is_framelock_attribute &&
- (target_type != NV_CTRL_TARGET_TYPE_FRAMELOCK)) {
+ (target_type != FRAMELOCK_TARGET)) {
int available;
- status = NvCtrlGetAttribute(t->h, NV_CTRL_FRAMELOCK, &available);
+ status = NvCtrlGetAttribute(t, NV_CTRL_FRAMELOCK, &available);
if (status != NvCtrlSuccess) {
nv_error_msg("The attribute '%s' specified %s cannot be "
"%s; error querying frame lock availability on "
@@ -3424,12 +2456,12 @@ int nv_process_parsed_attribute(const Options *op,
/* Do assignments based on the frame lock sync status */
if (assign &&
- (a->type == NV_PARSER_ATTRIBUTE_TYPE_INTEGER) &&
+ (a->type == CTRL_ATTRIBUTE_TYPE_INTEGER) &&
(a->attr != NV_CTRL_FRAMELOCK_SYNC)) {
int enabled;
- status = get_framelock_sync_state(t->h, h, &enabled);
-
+ status = get_framelock_sync_state(t, &enabled);
+
if (status != NvCtrlSuccess) {
nv_error_msg("The attribute '%s' specified %s cannot be "
"assigned; error querying frame lock sync "
@@ -3463,10 +2495,10 @@ int nv_process_parsed_attribute(const Options *op,
*/
if (a->flags.is_sdi_attribute &&
- target_type != NV_CTRL_TARGET_TYPE_GVI) {
+ target_type != GVI_TARGET) {
int available;
- status = NvCtrlGetAttribute(t->h, NV_CTRL_GVO_SUPPORTED,
+ status = NvCtrlGetAttribute(t, NV_CTRL_GVO_SUPPORTED,
&available);
if (status != NvCtrlSuccess) {
nv_error_msg("The attribute '%s' specified %s cannot be "
@@ -3488,7 +2520,7 @@ int nv_process_parsed_attribute(const Options *op,
/* Handle string operations */
- if (a->type == NV_PARSER_ATTRIBUTE_TYPE_STRING_OPERATION) {
+ if (a->type == CTRL_ATTRIBUTE_TYPE_STRING_OPERATION) {
char *ptrOut = NULL;
/* NOTE: You can only assign string operations */
@@ -3500,7 +2532,7 @@ int nv_process_parsed_attribute(const Options *op,
continue;
}
- status = NvCtrlStringOperation(t->h, 0, a->attr, p->val.str,
+ status = NvCtrlStringOperation(t, 0, a->attr, p->val.str,
&ptrOut);
if (status != NvCtrlSuccess) {
nv_error_msg("Error processing attribute '%s' (%s %s) "
@@ -3515,7 +2547,7 @@ int nv_process_parsed_attribute(const Options *op,
nv_msg(" ", "Attribute '%s' (%s %s): %s",
a->name, t->name, p->val.str, ptrOut);
}
- XFree(ptrOut);
+ free(ptrOut);
continue;
}
@@ -3523,7 +2555,7 @@ int nv_process_parsed_attribute(const Options *op,
/* Special case the GVO CSC attribute */
- if (a->type == NV_PARSER_ATTRIBUTE_TYPE_SDI_CSC) {
+ if (a->type == CTRL_ATTRIBUTE_TYPE_SDI_CSC) {
float colorMatrix[3][3];
float colorOffset[3];
float colorScale[3];
@@ -3548,12 +2580,12 @@ int nv_process_parsed_attribute(const Options *op,
colorScale[r] = p->val.pf[r*5 + 4];
}
- status = NvCtrlSetGvoColorConversion(t->h,
+ status = NvCtrlSetGvoColorConversion(t,
colorMatrix,
colorOffset,
colorScale);
} else {
- status = NvCtrlGetGvoColorConversion(t->h,
+ status = NvCtrlGetGvoColorConversion(t,
colorMatrix,
colorOffset,
colorScale);
@@ -3613,13 +2645,13 @@ int nv_process_parsed_attribute(const Options *op,
mask = 0;
}
- if (a->type == NV_PARSER_ATTRIBUTE_TYPE_STRING) {
- status = NvCtrlGetValidStringDisplayAttributeValues(t->h,
+ if (a->type == CTRL_ATTRIBUTE_TYPE_STRING) {
+ status = NvCtrlGetValidStringDisplayAttributeValues(t,
mask,
a->attr,
&valid);
} else {
- status = NvCtrlGetValidDisplayAttributeValues(t->h,
+ status = NvCtrlGetValidDisplayAttributeValues(t,
mask,
a->attr,
&valid);
@@ -3651,9 +2683,9 @@ int nv_process_parsed_attribute(const Options *op,
continue;
}
- ret = process_parsed_attribute_internal(op, h, t, p, mask, target_type,
- assign, verbose, whence,
- valid);
+ ret = process_parsed_attribute_internal(op, system, t, p, mask,
+ target_type, assign, verbose,
+ whence, valid);
if (ret == NV_FALSE) {
continue;
}
@@ -3669,48 +2701,36 @@ int nv_process_parsed_attribute(const Options *op,
-static ReturnStatus get_framelock_sync_state(NvCtrlAttributeHandle *t,
- CtrlHandles *h,
+static ReturnStatus get_framelock_sync_state(CtrlTarget *ctrl_target,
int *enabled)
{
- NVCTRLAttributePermissionsRec perms;
- Bool status;
- int permBit;
- int target_type = NvCtrlGetTargetType (t);
+ CtrlTargetNode *node;
+ CtrlTarget *query_target;
/* NV_CTRL_FRAMELOCK_SYNC should be queried on a GPU target,
* so use the display's connected GPU when querying via a display
* target.
*/
- if (target_type == NV_CTRL_TARGET_TYPE_DISPLAY) {
- CtrlHandleTargetNode *node;
- CtrlHandleTarget *dpy_target;
-
- dpy_target = nv_get_target(h, target_type, NvCtrlGetTargetId (t));
-
- for (node = dpy_target->relations; node; node = node->next) {
- target_type = NvCtrlGetTargetType(node->t->h);
+ switch (NvCtrlGetTargetType(ctrl_target)) {
+ case GPU_TARGET:
+ query_target = ctrl_target;
+ break;
- if (target_type == NV_CTRL_TARGET_TYPE_GPU) {
- t = node->t->h;
+ case DISPLAY_TARGET:
+ for (node = ctrl_target->relations; node; node = node->next) {
+ if (NvCtrlGetTargetType(node->t) == GPU_TARGET) {
+ query_target = node->t;
goto query;
}
}
+ /* Failed to find the GPU driving the display! */
return NvCtrlError;
- }
-query:
- status = XNVCTRLQueryAttributePermissions(h->dpy,
- NV_CTRL_FRAMELOCK_SYNC,
- &perms);
- if (!status) {
- return NvCtrlError;
- }
-
- permBit = targetTypeTable[GPU_TARGET].permission_bit;
- if (perms.permissions & permBit) {
- return NvCtrlGetAttribute(t, NV_CTRL_FRAMELOCK_SYNC, enabled);
+ default:
+ /* Can't query NV_CTRL_FRAMELOCK_SYNC on any other target */
+ return NvCtrlAttributeNotAvailable;
}
- return NvCtrlAttributeNotAvailable;
-}
+query:
+ return NvCtrlGetAttribute(query_target, NV_CTRL_FRAMELOCK_SYNC, enabled);
+}
diff --git a/src/query-assign.h b/src/query-assign.h
index bf19be8..823c98e 100644
--- a/src/query-assign.h
+++ b/src/query-assign.h
@@ -30,99 +30,14 @@
#include "parse.h"
#include "command-line.h"
-enum {
- NV_DPY_PROTO_NAME_TYPE_BASENAME = 0,
- NV_DPY_PROTO_NAME_TYPE_ID,
- NV_DPY_PROTO_NAME_DP_GUID,
- NV_DPY_PROTO_NAME_EDID_HASH,
- NV_DPY_PROTO_NAME_TARGET_INDEX,
- NV_DPY_PROTO_NAME_RANDR,
- NV_DPY_PROTO_NAME_MAX,
-};
-enum {
- NV_GPU_PROTO_NAME_TYPE_ID = 0,
- NV_GPU_PROTO_NAME_UUID,
- NV_GPU_PROTO_NAME_MAX,
-};
-
-#define NV_PROTO_NAME_MAX (NV_MAX((int)NV_DPY_PROTO_NAME_MAX, (int)NV_GPU_PROTO_NAME_MAX))
-
-
-/*
- * The CtrlHandles struct contains an array of target types for an X
- * server. For each target type, we store the number of those targets
- * on this X server. Per target, we store a NvCtrlAttributeHandle, a
- * bitmask of what display devices are enabled on that target, and a
- * string description of that target.
- */
-
-typedef struct {
- NvCtrlAttributeHandle *h; /* handle for this target */
- uint32 d; /* display device mask for this target */
- uint32 c; /* Connected display device mask for target */
- char *name; /* Name for this target */
- char *protoNames[NV_PROTO_NAME_MAX]; /* List of valid names for this target */
-
- struct {
- Bool connected; /* Connection state of display device */
- Bool enabled; /* Enabled state of display device */
- } display;
-
- struct _CtrlHandleTargetNode *relations; /* List of associated targets */
-} CtrlHandleTarget;
-
-typedef struct {
- int n; /* number of targets */
- CtrlHandleTarget *t; /* dynamically allocated array of targets */
-} CtrlHandleTargets;
-
-typedef struct {
- char *display; /* string for XOpenDisplay */
- Display *dpy; /* X display connection */
- CtrlHandleTargets targets[MAX_TARGET_TYPES];
-} CtrlHandles;
-
-/* Used to keep track of lists of targets */
-typedef struct _CtrlHandleTargetNode {
- struct _CtrlHandleTargetNode *next;
- CtrlHandleTarget *t;
-} CtrlHandleTargetNode;
-
-typedef struct _CtrlHandlesArray {
- int n; /* number of CtrlHandles */
- CtrlHandles **array; /* dynamically allocated array of CtrlHandles */
-} CtrlHandlesArray;
-
-int nv_process_assignments_and_queries(const Options *op,
- CtrlHandlesArray *handles_array);
-
-CtrlHandles *
- nv_alloc_ctrl_handles_and_add_to_array(const char *display,
- CtrlHandlesArray *handles_array);
-
-void nv_free_ctrl_handles_array(CtrlHandlesArray *handles_array);
-
-CtrlHandles *nv_get_ctrl_handles(const char *display,
- CtrlHandlesArray *handles_array);
-
-NvCtrlAttributeHandle *nv_get_target_handle(const CtrlHandles *handles,
- int target_type,
- int target_id);
-
-Bool nv_get_attribute_perms(CtrlHandles *h, const AttributeTableEntry *a,
- NVCTRLAttributePermissionsRec *perms);
+int nv_process_assignments_and_queries(const Options *op,
+ CtrlSystemList *systems);
int nv_process_parsed_attribute(const Options *op,
- ParsedAttribute*, CtrlHandles *h,
+ ParsedAttribute*, CtrlSystem *system,
int, int, char*, ...) NV_ATTRIBUTE_PRINTF(6, 7);
-void nv_target_list_free(CtrlHandleTargetNode *head);
-
-NvCtrlAttributeHandle *nv_add_target(CtrlHandles *handles, Display *dpy,
- int target_index, int display_id);
-const char *nv_get_display_target_config_name(const CtrlHandles *handles,
- int target_id);
#endif /* __QUERY_ASSIGN_H__ */
diff --git a/src/src.mk b/src/src.mk
index 625da2c..36d4112 100644
--- a/src/src.mk
+++ b/src/src.mk
@@ -132,6 +132,8 @@ LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesVidMode.c
LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesXv.c
LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesGlx.c
LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesXrandr.c
+LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesUtils.c
+LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesNvml.c
NVIDIA_SETTINGS_SRC += $(LIB_XNVCTRL_ATTRIBUTES_SRC)
@@ -169,6 +171,9 @@ NVIDIA_SETTINGS_EXTRA_DIST += $(LIB_XPM_DATA_EXTRA_DIST)
#
# files in the src/gtk+-2.x directory of nvidia-settings
#
+# The GTK_SRC files are not added to NVIDIA_SETTINGS_SRC so that we can build
+# the GTK 2 and 3 GUI libraries from the same source.
+#
GTK_SRC += gtk+-2.x/ctkxvideo.c
GTK_SRC += gtk+-2.x/ctkui.c
@@ -193,7 +198,6 @@ GTK_SRC += gtk+-2.x/ctkpowermizer.c
GTK_SRC += gtk+-2.x/ctkgvo.c
GTK_SRC += gtk+-2.x/ctkgvo-csc.c
GTK_SRC += gtk+-2.x/ctkdropdownmenu.c
-GTK_SRC += gtk+-2.x/ctkclocks.c
GTK_SRC += gtk+-2.x/ctkutils.c
GTK_SRC += gtk+-2.x/ctkedid.c
GTK_SRC += gtk+-2.x/ctkserver.c
@@ -216,7 +220,6 @@ GTK_SRC += gtk+-2.x/ctkcolorcontrols.c
GTK_SRC += gtk+-2.x/ctk3dvisionpro.c
GTK_SRC += gtk+-2.x/ctkvdpau.c
-NVIDIA_SETTINGS_SRC += $(GTK_SRC)
GTK_EXTRA_DIST += gtk+-2.x/ctkxvideo.h
GTK_EXTRA_DIST += gtk+-2.x/ctkui.h
@@ -242,7 +245,6 @@ GTK_EXTRA_DIST += gtk+-2.x/ctkpowermizer.h
GTK_EXTRA_DIST += gtk+-2.x/ctkgvo.h
GTK_EXTRA_DIST += gtk+-2.x/ctkgvo-csc.h
GTK_EXTRA_DIST += gtk+-2.x/ctkdropdownmenu.h
-GTK_EXTRA_DIST += gtk+-2.x/ctkclocks.h
GTK_EXTRA_DIST += gtk+-2.x/ctkutils.h
GTK_EXTRA_DIST += gtk+-2.x/ctkedid.h
GTK_EXTRA_DIST += gtk+-2.x/ctkserver.h
@@ -303,4 +305,5 @@ JANSSON_EXTRA_DIST += jansson/utf.h
NVIDIA_SETTINGS_EXTRA_DIST += $(JANSSON_EXTRA_DIST)
NVIDIA_SETTINGS_DIST_FILES += $(NVIDIA_SETTINGS_SRC)
+NVIDIA_SETTINGS_DIST_FILES += $(GTK_SRC)
NVIDIA_SETTINGS_DIST_FILES += $(NVIDIA_SETTINGS_EXTRA_DIST)
diff --git a/src/version.h b/src/version.h
new file mode 100644
index 0000000..e6373db
--- /dev/null
+++ b/src/version.h
@@ -0,0 +1 @@
+#define NVIDIA_VERSION "346.16"
diff --git a/src/version.mk b/src/version.mk
index 66ba96f..14c4194 100644
--- a/src/version.mk
+++ b/src/version.mk
@@ -1 +1 @@
-NVIDIA_VERSION = 343.22
+NVIDIA_VERSION = 346.16
diff --git a/utils.mk b/utils.mk
index cc989d0..88598d2 100644
--- a/utils.mk
+++ b/utils.mk
@@ -55,6 +55,7 @@ endif
INSTALL ?= install
INSTALL_BIN_ARGS ?= -m 755
+INSTALL_LIB_ARGS ?= -m 644
INSTALL_DOC_ARGS ?= -m 644
M4 ?= m4
@@ -98,6 +99,26 @@ ifndef TARGET_ARCH
TARGET_ARCH := $(subst i686,x86,$(TARGET_ARCH))
endif
+ifeq ($(TARGET_ARCH),x86)
+ CFLAGS += -DNV_X86 -DNV_ARCH_BITS=32
+endif
+
+ifeq ($(TARGET_ARCH),x86_64)
+ CFLAGS += -DNV_X86_64 -DNV_ARCH_BITS=64
+endif
+
+ifeq ($(TARGET_ARCH),armv7l)
+ CFLAGS += -DNV_ARMV7 -DNV_ARCH_BITS=32
+endif
+
+ifeq ($(TARGET_ARCH),aarch64)
+ CFLAGS += -DNV_AARCH64 -DNV_ARCH_BITS=64
+endif
+
+ifeq ($(TARGET_ARCH),ppc64le)
+ CFLAGS += -DNV_PPC64LE -DNV_ARCH_BITS=64
+endif
+
ifeq ($(TARGET_OS),Linux)
LIBDL_LIBS = -ldl
else
@@ -113,6 +134,14 @@ ifeq ($(TARGET_ARCH),armv7l)
endif
TARGET_ARCH_ABI ?=
+ifeq ($(TARGET_ARCH_ABI),gnueabi)
+ CFLAGS += -DNV_GNUEABI
+endif
+
+ifeq ($(TARGET_ARCH_ABI),gnueabihf)
+ CFLAGS += -DNV_GNUEABIHF
+endif
+
OUTPUTDIR ?= _out/$(TARGET_OS)_$(TARGET_ARCH)
OUTPUTDIR_ABSOLUTE ?= $(CURDIR)/$(OUTPUTDIR)
@@ -143,6 +172,7 @@ endif
PREFIX ?= /usr/local
BINDIR = $(DESTDIR)$(PREFIX)/bin
+LIBDIR = $(DESTDIR)$(PREFIX)/lib
MANDIR = $(DESTDIR)$(PREFIX)/share/man/man1
@@ -230,7 +260,7 @@ NV_MODULE_LOGGING_NAME ?=
ifeq ($(NV_VERBOSE),0)
quiet_cmd = @$(PRINTF) \
- " $(if $(NV_MODULE_LOGGING_NAME),[ %-17.17s ],%s) $(quiet_$(1))\n" \
+ " $(if $(NV_MODULE_LOGGING_NAME),[ %-17.17s ],%s) $(quiet_$(1))\n" \
"$(NV_MODULE_LOGGING_NAME)" && $($(1))
else
quiet_cmd = $($(1))
@@ -262,32 +292,49 @@ quiet_STRIP_CMD = $(call define_quiet_cmd,STRIP ,$@)
##############################################################################
# function to generate a list of object files from their corresponding
-# source files; example usage:
+# source files using the specified path. The _WITH_DIR variant takes an
+# output path as the second argument while the BUILD_OBJECT_LIST defaults
+# to using the value of OUTPUTDIR as the output path. example usage:
#
-# OBJS = $(call BUILD_OBJECT_LIST,$(SRC))
+# OBJS = $(call BUILD_OBJECT_LIST_WITH_DIR,$(SRC),$(DIR))
##############################################################################
+BUILD_OBJECT_LIST_WITH_DIR = \
+ $(addprefix $(2)/,$(notdir $(addsuffix .o,$(basename $(1)))))
+
BUILD_OBJECT_LIST = \
- $(addprefix $(OUTPUTDIR)/,$(notdir $(addsuffix .o,$(basename $(1)))))
+ $(call BUILD_OBJECT_LIST_WITH_DIR,$(1),$(OUTPUTDIR))
##############################################################################
# function to generate a list of dependency files from their
-# corresponding source files; example usage:
+# corresponding source files using the specified path. The _WITH_DIR
+# variant takes an output path as the second argument while the
+# BUILD_DEPENDENCY_LIST default to using the value of OUTPUTDIR as the
+# output path. example usage:
#
-# DEPS = $(call BUILD_DEPENDENCY_LIST,$(SRC))
+# DEPS = $(call BUILD_DEPENDENCY_LIST_WITH_DIR,$(SRC),$(DIR))
##############################################################################
+BUILD_DEPENDENCY_LIST_WITH_DIR = \
+ $(addprefix $(2)/,$(notdir $(addsuffix .d,$(basename $(1)))))
+
BUILD_DEPENDENCY_LIST = \
- $(addprefix $(OUTPUTDIR)/,$(notdir $(addsuffix .d,$(basename $(1)))))
+ $(call BUILD_DEPENDENCY_LIST_WITH_DIR,$(1),$(OUTPUTDIR))
##############################################################################
# functions to define a rule to build an object file; the first
-# argument whether the rule is for the target or host platform ("HOST"
-# or "TARGET"), the second argument is the source file to compile, and
-# the third argument (_WITH_OBJECT_NAME-only) is the object filename
-# to produce. Example usage:
+# argument for all functions is whether the rule is for the target or
+# host platform ("HOST" or "TARGET"), the second argument for all
+# functions is the source file to compile.
+#
+# The _WITH_OBJECT_NAME and _WITH_DIR function name suffixes describe
+# the third and possibly fourth arguments based on order. The
+# _WITH_OBJECT_NAME argument is the object filename to produce while
+# the _WITH_DIR argument is the destination path for the object file.
+#
+# Example usage:
#
# $(eval $(call DEFINE_OBJECT_RULE,TARGET,foo.c))
#
@@ -299,26 +346,35 @@ BUILD_DEPENDENCY_LIST = \
# from the source file name (this is normally what you want).
##############################################################################
-define DEFINE_OBJECT_RULE_WITH_OBJECT_NAME
+define DEFINE_OBJECT_RULE_WITH_OBJECT_NAME_WITH_DIR
$(3): $(2)
- @$(MKDIR) $(OUTPUTDIR)
+ @$(MKDIR) $(4)
$$(call quiet_cmd,$(call host_target_cc,$(1))) \
$$($(call host_target_cflags,$(1))) -c $$< -o $$@ \
$(call AUTO_DEP_CMD,$(1),$(2),$(3))
- -include $$(call BUILD_DEPENDENCY_LIST,$(3))
+ -include $$(call BUILD_DEPENDENCY_LIST_WITH_DIR,$(3),$(4))
# declare empty rule for generating dependency file; we generate the
# dependency files implicitly when compiling the source file (see
# AUTO_DEP_CMD above), so we don't want gmake to spend time searching
# for an explicit rule to generate the dependency file
- $$(call BUILD_DEPENDENCY_LIST,$(3)): ;
+ $$(call BUILD_DEPENDENCY_LIST_WITH_DIR,$(3),$(4)): ;
+
+endef
+
+define DEFINE_OBJECT_RULE_WITH_OBJECT_NAME
+ $$(eval $$(call DEFINE_OBJECT_RULE_WITH_OBJECT_NAME_WITH_DIR,$(1),$(2),\
+ $(3),$(OUTPUTDIR)))
+endef
+define DEFINE_OBJECT_RULE_WITH_DIR
+ $$(eval $$(call DEFINE_OBJECT_RULE_WITH_OBJECT_NAME_WITH_DIR,$(1),$(2),\
+ $$(call BUILD_OBJECT_LIST_WITH_DIR,$(2),$(3)),$(3)))
endef
define DEFINE_OBJECT_RULE
- $$(eval $$(call DEFINE_OBJECT_RULE_WITH_OBJECT_NAME,$(1),$(2),\
- $$(call BUILD_OBJECT_LIST,$(2))))
+ $$(eval $$(call DEFINE_OBJECT_RULE_WITH_DIR,$(1),$(2),$(OUTPUTDIR)))
endef
diff --git a/version.mk b/version.mk
index 66ba96f..14c4194 100644
--- a/version.mk
+++ b/version.mk
@@ -1 +1 @@
-NVIDIA_VERSION = 343.22
+NVIDIA_VERSION = 346.16