diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2010-05-21 13:51:55 -0700 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2010-05-21 13:51:55 -0700 |
commit | 9f277148255d8d2f4e7970e8d13d1f77068dbed9 (patch) | |
tree | 432502a183909f5ac83f6c1a5536ddddabb79087 /src | |
parent | 291e6adb5ddbc574fe673b2d3810839c2fda36bc (diff) |
256.25256.25
Diffstat (limited to 'src')
98 files changed, 2202 insertions, 984 deletions
diff --git a/src/Makefile.inc b/src/Makefile.inc deleted file mode 100644 index 2dfee54..0000000 --- a/src/Makefile.inc +++ /dev/null @@ -1,51 +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 of Version 2 of the GNU General Public -# License 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 Version 2 -# of the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the: -# -# Free Software Foundation, Inc. -# 59 Temple Place - Suite 330 -# Boston, MA 02111-1307, USA -# - -# -# src files and headers -# - -SRC += \ - command-line.c \ - config-file.c \ - msg.c \ - nvidia-settings.c \ - parse.c \ - query-assign.c \ - nvgetopt.c \ - glxinfo.c \ - lscf.c - -EXTRA_DIST += \ - Makefile.inc \ - command-line.h \ - config-file.h \ - msg.h \ - parse.h \ - query-assign.h \ - nvgetopt.h \ - glxinfo.h \ - lscf.h - -dist_list:: - @ echo $(SRC) $(EXTRA_DIST) diff --git a/src/XF86Config-parser/Makefile b/src/XF86Config-parser/Makefile deleted file mode 100644 index 721945d..0000000 --- a/src/XF86Config-parser/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -SRC = \ - DRI.c \ - Device.c \ - Files.c \ - Flags.c \ - Input.c \ - Keyboard.c \ - Layout.c \ - Module.c \ - Monitor.c \ - Pointer.c \ - Screen.c \ - Vendor.c \ - Video.c \ - Read.c \ - Scan.c \ - Write.c \ - Util.c \ - Extensions.c \ - Generate.c \ - Merge.c - -OBJS = $(SRC:%.c=%.o) -DEPS = $(SRC:%.c=%.d) - -ifndef CC - CC = gcc -endif - -CFLAGS = -Wall -g - -ifdef NV_CFLAGS - CFLAGS += $(NV_CFLAGS) -endif - -ifndef RANLIB - RANLIB = ranlib -endif - -LIB = libXF86Config-parser.a -LIB_O = $(LIB:%.a=%.o) - -default all: $(LIB) - -.PHONY: clean clobber - -$(LIB): $(OBJS) - $(LD) -r -o $(LIB_O) $(OBJS) - $(AR) ruv $(LIB) $(LIB_O) - $(RANLIB) $(LIB) - -%.o: %.c - $(CC) -c $(CFLAGS) $< -o $@ - -%.d: %.c - @set -e; $(CC) -MM $(CPPFLAGS) $< \ - | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \ - [ -s $@ ] || rm -f $@ - -clean clobber: - rm -rf *.o *~ *.d $(LIB) $(LIB_O) - --include $(DEPS) diff --git a/src/XF86Config-parser/Makefile.inc b/src/XF86Config-parser/Makefile.inc deleted file mode 100644 index 2215dfb..0000000 --- a/src/XF86Config-parser/Makefile.inc +++ /dev/null @@ -1,59 +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 of Version 2 of the GNU General Public -# License 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 Version 2 -# of the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the: -# -# Free Software Foundation, Inc. -# 59 Temple Place - Suite 330 -# Boston, MA 02111-1307, USA -# - -# -# src files and headers -# - -SRC += \ - Device.c \ - DRI.c \ - Extensions.c \ - Files.c \ - Flags.c \ - Generate.c \ - Input.c \ - Keyboard.c \ - Layout.c \ - Merge.c \ - Module.c \ - Monitor.c \ - Pointer.c \ - Read.c \ - Scan.c \ - Screen.c \ - Util.c \ - Vendor.c \ - Video.c \ - Write.c - -EXTRA_DIST += \ - Makefile.inc \ - Configint.h \ - configProcs.h \ - Makefile \ - xf86Parser.h \ - xf86tokens.h - -dist_list:: - @ echo $(SRC) $(EXTRA_DIST) diff --git a/src/XF86Config-parser/Scan.c b/src/XF86Config-parser/Scan.c index d0a4258..19473af 100644 --- a/src/XF86Config-parser/Scan.c +++ b/src/XF86Config-parser/Scan.c @@ -188,7 +188,7 @@ static unsigned int xconfigStrToUL (char *str) * support that. */ -static char *xconfigGetNextLine() +static char *xconfigGetNextLine(void) { static int configBufLen = CONFIG_BUF_LEN; char *tmpConfigBuf, *tmpConfigRBuf; diff --git a/src/XF86Config-parser/src.mk b/src/XF86Config-parser/src.mk new file mode 100644 index 0000000..f43afb7 --- /dev/null +++ b/src/XF86Config-parser/src.mk @@ -0,0 +1,29 @@ +# makefile fragment included by nvidia-xconfig and nvidia-settings + +XCONFIG_PARSER_SRC += DRI.c +XCONFIG_PARSER_SRC += Device.c +XCONFIG_PARSER_SRC += Extensions.c +XCONFIG_PARSER_SRC += Files.c +XCONFIG_PARSER_SRC += Flags.c +XCONFIG_PARSER_SRC += Generate.c +XCONFIG_PARSER_SRC += Input.c +XCONFIG_PARSER_SRC += Keyboard.c +XCONFIG_PARSER_SRC += Layout.c +XCONFIG_PARSER_SRC += Merge.c +XCONFIG_PARSER_SRC += Module.c +XCONFIG_PARSER_SRC += Monitor.c +XCONFIG_PARSER_SRC += Pointer.c +XCONFIG_PARSER_SRC += Read.c +XCONFIG_PARSER_SRC += Scan.c +XCONFIG_PARSER_SRC += Screen.c +XCONFIG_PARSER_SRC += Util.c +XCONFIG_PARSER_SRC += Vendor.c +XCONFIG_PARSER_SRC += Video.c +XCONFIG_PARSER_SRC += Write.c + +XCONFIG_PARSER_EXTRA_DIST += Configint.h +XCONFIG_PARSER_EXTRA_DIST += configProcs.h +XCONFIG_PARSER_EXTRA_DIST += xf86Parser.h +XCONFIG_PARSER_EXTRA_DIST += xf86tokens.h +XCONFIG_PARSER_EXTRA_DIST += src.mk + diff --git a/src/command-line.c b/src/command-line.c index 37ba1de..7aa1452 100644 --- a/src/command-line.c +++ b/src/command-line.c @@ -48,7 +48,6 @@ static void print_assign_help(void); static void print_query_help(void); static void print_attribute_help(char *attr); static void print_help(void); -static char *tilde_expansion(char *str); static char *nvstrcat(const char *str, ...); /* @@ -74,7 +73,7 @@ static void print_version(void) nv_msg(TAB, "This program is used to configure the " "NVIDIA Linux graphics driver."); nv_msg(NULL, ""); - nv_msg(TAB, "Copyright (C) 2004 - 2008 NVIDIA Corporation."); + nv_msg(TAB, "Copyright (C) 2004 - 2010 NVIDIA Corporation."); nv_msg(NULL, ""); } /* print_version() */ @@ -474,14 +473,15 @@ Options *parse_command_line(int argc, char *argv[], char *dpy) * user's home directory. */ -static char *tilde_expansion(char *str) +char *tilde_expansion(const char *str) { char *prefix = NULL; - char *replace, *user, *ret; + const char *replace; + char *user, *ret; struct passwd *pw; int len; - if ((!str) || (str[0] != '~')) return str; + if ((!str) || (str[0] != '~')) return strdup(str); if ((str[1] == '/') || (str[1] == '\0')) { @@ -514,7 +514,7 @@ static char *tilde_expansion(char *str) free (user); } - if (!prefix) return str; + if (!prefix) return strdup(str); ret = malloc(strlen(prefix) + strlen(replace) + 1); strcpy(ret, prefix); diff --git a/src/command-line.h b/src/command-line.h index c26e1c5..c173524 100644 --- a/src/command-line.h +++ b/src/command-line.h @@ -95,5 +95,6 @@ typedef struct { Options *parse_command_line(int argc, char *argv[], char *dpy); +char *tilde_expansion(const char *str); #endif /* __COMMAND_LINE_H__ */ diff --git a/src/glxinfo.c b/src/glxinfo.c index c6d89e3..0378bda 100644 --- a/src/glxinfo.c +++ b/src/glxinfo.c @@ -49,6 +49,7 @@ format_extension_list(const char *ext) { int i; char * extTmp = NULL; /* Actual string to print */ + const char *extCountTmp; if ( !ext || !ext[0] ) @@ -56,19 +57,19 @@ format_extension_list(const char *ext) /* Count number of extensions (to get number of commas needed) */ i = 0; - extTmp = (char *)ext; - while ( *extTmp != '\0' ) { - if ( *extTmp == ' ' ) { + extCountTmp = ext; + while ( *extCountTmp != '\0' ) { + if ( *extCountTmp == ' ' ) { i++; } - extTmp++; + extCountTmp++; } /* * Allocate buffer that will hold the extension string with * commas in it */ - extTmp = (char *) malloc( (strlen(ext) +i +1) *sizeof(char) ); + extTmp = malloc( (strlen(ext) +i +1) *sizeof(char) ); if ( extTmp == NULL ) { return NULL; } diff --git a/src/gtk+-2.x/Makefile.inc b/src/gtk+-2.x/Makefile.inc deleted file mode 100644 index ac33d9c..0000000 --- a/src/gtk+-2.x/Makefile.inc +++ /dev/null @@ -1,123 +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 of Version 2 of the GNU General Public -# License 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 Version 2 -# of the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the: -# -# Free Software Foundation, Inc. -# 59 Temple Place - Suite 330 -# Boston, MA 02111-1307, USA -# - -# -# GTK+ 2.0 sources and extra files to be included in the distribution -# - -SRC += \ - ctkxvideo.c \ - ctkcursorshadow.c \ - ctkui.c \ - ctkframelock.c \ - ctkgauge.c \ - ctkcurve.c \ - ctkcolorcorrection.c \ - ctkscale.c \ - ctkmultisample.c \ - ctkconfig.c \ - ctkevent.c \ - ctkwindow.c \ - ctkopengl.c \ - ctkglx.c \ - ctkhelp.c \ - ctkimagesliders.c \ - ctkdisplaydevice-crt.c \ - ctkdisplaydevice-tv.c \ - ctkdisplaydevice-dfp.c \ - ctkthermal.c \ - ctkpowermizer.c \ - ctkgvo.c \ - ctkgvo-csc.c \ - ctkdropdownmenu.c \ - ctkrandr.c \ - ctkclocks.c \ - ctkutils.c \ - ctkedid.c \ - ctkserver.c \ - ctkdisplaylayout.c \ - ctkdisplayconfig.c \ - ctkscreen.c \ - ctkslimm.c \ - ctkgpu.c \ - ctkbanner.c \ - ctkvcs.c \ - ctkdisplayconfig-utils.c \ - ctkgvo-banner.c \ - ctkgvo-sync.c \ - ctkgvi.c \ - ctklicense.c \ - ctkpowersavings.c \ - ctkecc.c - - -EXTRA_DIST += \ - Makefile.inc \ - ctkxvideo.h \ - ctkcursorshadow.h \ - ctkui.h \ - ctkframelock.h \ - ctkgauge.h \ - ctkcurve.h \ - ctkcolorcorrection.h \ - ctkscale.h \ - ctkmultisample.h \ - ctkconfig.h \ - ctkevent.h \ - ctkwindow.h \ - ctkopengl.h \ - ctkglx.h \ - ctkhelp.h \ - ctkimagesliders.h \ - ctkdisplaydevice-crt.h \ - ctkdisplaydevice-tv.h \ - ctkdisplaydevice-dfp.h \ - ctkconstants.h \ - ctkthermal.h \ - ctkpowermizer.h \ - ctkgvo.h \ - ctkgvo-csc.h \ - ctkdropdownmenu.h \ - ctkrandr.h \ - ctkclocks.h \ - ctkutils.h \ - ctkedid.h \ - ctkserver.h \ - ctkdisplaylayout.h \ - ctkdisplayconfig.h \ - ctkscreen.h \ - ctkslimm.h \ - ctkgpu.h \ - ctkbanner.h \ - ctkvcs.h \ - ctkdisplayconfig-utils.h \ - ctkpowersavings.h \ - ctkgvo-banner.h \ - ctkgvo-sync.h \ - ctkgvi.h \ - ctklicense.h \ - ctkpowersavings.h \ - ctkecc.h - -dist_list:: - @ echo $(SRC) $(EXTRA_DIST) diff --git a/src/gtk+-2.x/ctkcolorcorrection.c b/src/gtk+-2.x/ctkcolorcorrection.c index b375347..169190e 100644 --- a/src/gtk+-2.x/ctkcolorcorrection.c +++ b/src/gtk+-2.x/ctkcolorcorrection.c @@ -380,7 +380,6 @@ GtkWidget* ctk_color_correction_new(NvCtrlAttributeHandle *handle, (gpointer) ctk_color_correction); ctk_color_correction->confirm_button = confirm_button; - gtk_widget_set_size_request(confirm_button, 160, -1); ctk_config_set_tooltip(ctk_config, eventbox, __confirm_button_help); ctk_config_set_tooltip(ctk_config, button, __resest_button_help); diff --git a/src/gtk+-2.x/ctkconfig.c b/src/gtk+-2.x/ctkconfig.c index f9d0542..1cb58a8 100644 --- a/src/gtk+-2.x/ctkconfig.c +++ b/src/gtk+-2.x/ctkconfig.c @@ -333,7 +333,7 @@ GtkWidget* ctk_config_new(ConfigProperties *conf, CtrlHandles *pCtrlHandles) static void save_rc_clicked(GtkWidget *widget, gpointer user_data) { gint result; - gchar *rc_filename = NULL; + const gchar *rc_filename = NULL; CtkConfig *ctk_config = CTK_CONFIG(user_data); CtkWindow *ctk_window = CTK_WINDOW(ctk_get_parent_window(GTK_WIDGET(ctk_config))); @@ -344,7 +344,7 @@ static void save_rc_clicked(GtkWidget *widget, gpointer user_data) switch (result) { case GTK_RESPONSE_ACCEPT: case GTK_RESPONSE_OK: - rc_filename = (gchar *)gtk_file_selection_get_filename + rc_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION(ctk_config->rc_file_selector)); break; default: diff --git a/src/gtk+-2.x/ctkdisplayconfig-utils.c b/src/gtk+-2.x/ctkdisplayconfig-utils.c index fed2001..81280e6 100644 --- a/src/gtk+-2.x/ctkdisplayconfig-utils.c +++ b/src/gtk+-2.x/ctkdisplayconfig-utils.c @@ -25,7 +25,6 @@ #include <stdlib.h> /* malloc */ #include <string.h> /* strlen, strdup */ #include <unistd.h> /* lseek, close */ -#include <locale.h> #include <errno.h> #include <fcntl.h> @@ -38,6 +37,7 @@ #include "msg.h" #include "parse.h" +#include "command-line.h" #include "ctkdisplayconfig-utils.h" #include "ctkutils.h" @@ -257,25 +257,16 @@ static nvModeLinePtr modeline_parse(nvDisplayPtr display, { nvModeLinePtr modeline = NULL; const char *str = modeline_str; - char *tmp, *old_locale; + char *tmp; char *tokens, *nptr; - double pclk, htotal, vtotal, factor; + double htotal, vtotal, factor; + gdouble pclk; if (!str) return NULL; modeline = (nvModeLinePtr)calloc(1, sizeof(nvModeLine)); if (!modeline) return NULL; - /* Make sure strtod uses . instead of , as the decimal separator */ - old_locale = setlocale(LC_NUMERIC, NULL); - - if (old_locale) - old_locale = strdup(old_locale); - - if (!old_locale || !setlocale(LC_NUMERIC, "C")) - nv_warning_msg("Error parsing server modeline '%s': could not " - "set the locale 'C'.", modeline_str); - /* Parse the modeline tokens */ tmp = strstr(str, "::"); if (tmp) { @@ -397,7 +388,12 @@ static nvModeLinePtr modeline_parse(nvDisplayPtr display, htotal = (double) modeline->data.htotal; vtotal = (double) modeline->data.vtotal; - pclk = strtod(modeline->data.clock, &nptr); + /* + * Use g_ascii_strtod(), so that we do not have to change the locale + * to "C". + */ + pclk = g_ascii_strtod((const gchar *)modeline->data.clock, + (gchar **)&nptr); if ((pclk == 0.0) || !nptr || *nptr != '\0' || ((htotal * vtotal) == 0)) { nv_warning_msg("Failed to compute the refresh rate " @@ -420,12 +416,6 @@ static nvModeLinePtr modeline_parse(nvDisplayPtr display, modeline->refresh_rate *= factor; } - /* Restore the locale */ - if (old_locale) { - setlocale(LC_NUMERIC, old_locale); - free(old_locale); - } - return modeline; @@ -433,12 +423,6 @@ static nvModeLinePtr modeline_parse(nvDisplayPtr display, fail: free(modeline); - /* Restore the locale */ - if (old_locale) { - setlocale(LC_NUMERIC, old_locale); - free(old_locale); - } - return NULL; } /* modeline_parse() */ @@ -1270,14 +1254,16 @@ static void screen_remove_metamodes(nvScreenPtr screen) * screen's display devices (at the end of the list) * **/ -static Bool screen_add_metamode(nvScreenPtr screen, char *metamode_str, +static Bool screen_add_metamode(nvScreenPtr screen, const char *metamode_str, gchar **err_str) { - char *mode_str; + char *mode_str_itr; char *str = NULL; - char *tmp; + const char *tmp; char *tokens; + char *metamode_copy; nvMetaModePtr metamode; + int str_offset = 0; if (!screen || !screen->gpu || !metamode_str) goto fail; @@ -1287,29 +1273,33 @@ static Bool screen_add_metamode(nvScreenPtr screen, char *metamode_str, if (!metamode) goto fail; - /* Copy the string so we can split it up */ - str = strdup(metamode_str); - if (!str) goto fail; - - /* Read the MetaMode ID */ - tmp = strstr(str, "::"); + tmp = strstr(metamode_str, "::"); if (tmp) { - tokens = strdup(str); - tokens[ tmp-str ] = '\0'; + + tokens = strdup(metamode_str); + if (!tokens) goto fail; + + tokens[ tmp-metamode_str ] = '\0'; tmp += 2; parse_token_value_pairs(tokens, apply_metamode_token, (void *)metamode); free(tokens); + str_offset = tmp - metamode_str; } else { /* No tokens? Try the old "ID: METAMODE_STR" syntax */ - tmp = (char *)parse_read_integer(str, &(metamode->id)); + const char *read_offset; + read_offset = parse_read_integer(metamode_str, &(metamode->id)); metamode->source = METAMODE_SOURCE_NVCONTROL; - if (*tmp == ':') { - tmp++; + if (*read_offset == ':') { + read_offset++; + str_offset = read_offset - metamode_str; } } + /* Copy the string so we can split it up */ + metamode_copy = strdup(metamode_str + str_offset); + if (!metamode_copy) goto fail; /* Add the metamode at the end of the screen's metamode list */ xconfigAddListItem((GenericListPtr *)(&screen->metamodes), @@ -1317,18 +1307,18 @@ static Bool screen_add_metamode(nvScreenPtr screen, char *metamode_str, /* Split up the metamode into separate modes */ - for (mode_str = strtok(tmp, ","); - mode_str; - mode_str = strtok(NULL, ",")) { + for (mode_str_itr = strtok(metamode_copy, ","); + mode_str_itr; + mode_str_itr = strtok(NULL, ",")) { nvModePtr mode; unsigned int device_mask; nvDisplayPtr display; - const char *orig_mode_str = parse_skip_whitespace(mode_str); - + const char *orig_mode_str = parse_skip_whitespace(mode_str_itr); + const char *mode_str; /* Parse the display device bitmask from the name */ - mode_str = (char *)parse_read_display_name(mode_str, &device_mask); + mode_str = parse_read_display_name(mode_str_itr, &device_mask); if (!mode_str) { *err_str = g_strdup_printf("Failed to read a display device name " "on screen %d (on GPU-%d)\nwhile " @@ -2663,69 +2653,6 @@ nvScreenPtr layout_get_a_screen(nvLayoutPtr layout, nvGpuPtr preferred_gpu) /* - * tilde_expansion() - do tilde expansion on the given path name; - * based loosely on code snippets found in the comp.unix.programmer - * FAQ. The tilde expansion rule is: if a tilde ('~') is alone or - * followed by a '/', then substitute the current user's home - * directory; if followed by the name of a user, then substitute that - * user's home directory. - * - * Code adapted from nvidia-xconfig - */ - -char *tilde_expansion(char *str) -{ - char *prefix = NULL; - char *replace, *user, *ret; - struct passwd *pw; - int len; - - if ((!str) || (str[0] != '~')) return str; - - if ((str[1] == '/') || (str[1] == '\0')) { - - /* expand to the current user's home directory */ - - prefix = getenv("HOME"); - if (!prefix) { - - /* $HOME isn't set; get the home directory from /etc/passwd */ - - pw = getpwuid(getuid()); - if (pw) prefix = pw->pw_dir; - } - - replace = str + 1; - - } else { - - /* expand to the specified user's home directory */ - - replace = strchr(str, '/'); - if (!replace) replace = str + strlen(str); - - len = replace - str; - user = malloc(len + 1); - strncpy(user, str+1, len-1); - user[len] = '\0'; - pw = getpwnam(user); - if (pw) prefix = pw->pw_dir; - free (user); - } - - if (!prefix) return str; - - ret = malloc(strlen(prefix) + strlen(replace) + 1); - strcpy(ret, prefix); - strcat(ret, replace); - - return ret; - -} /* tilde_expansion() */ - - - -/* * update_banner() - add our banner at the top of the config, but * first we need to remove any lines that already include our prefix * (because presumably they are a banner from an earlier run of @@ -2800,6 +2727,7 @@ static int save_xconfig_file(SaveXConfDlg *dlg, FILE *fp = NULL; size_t size; gchar *err_msg = NULL; + struct stat st; int ret = 0; @@ -2811,6 +2739,23 @@ static int save_xconfig_file(SaveXConfDlg *dlg, /* Backup any existing file */ if ((access(filename, F_OK) == 0)) { + /* Verify the file-write permission */ + if ((access(filename, W_OK) != 0)) { + err_msg = + g_strdup_printf("You do not have adequate permission to" + " open the existing X configuration file '%s' for writing.", + filename); + + /* Verify the user permissions */ + if (stat(filename, &st) == 0) { + if ((getuid() != 0) && (st.st_uid == 0) && + !(st.st_mode & (S_IWGRP | S_IWOTH))) + err_msg = g_strconcat(err_msg, " You must be 'root'" + " to modify the file.", NULL); + } + goto done; + } + backup_filename = g_strdup_printf("%s.backup", filename); nv_info_msg("", "X configuration file '%s' already exists, " "backing up file as '%s'", filename, @@ -2907,7 +2852,7 @@ static const char *get_non_regular_file_type_description(mode_t mode) */ static void update_xconfig_save_buffer(SaveXConfDlg *dlg) { - gchar *filename; + const gchar *filename; XConfigPtr xconfCur = NULL; XConfigPtr xconfGen = NULL; @@ -2931,7 +2876,7 @@ static void update_xconfig_save_buffer(SaveXConfDlg *dlg) merge = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dlg->btn_xconfig_merge)); - filename = (gchar *)gtk_entry_get_text(GTK_ENTRY(dlg->txt_xconfig_file)); + filename = gtk_entry_get_text(GTK_ENTRY(dlg->txt_xconfig_file)); /* Assume we can save until we find out otherwise */ @@ -2944,6 +2889,7 @@ static void update_xconfig_save_buffer(SaveXConfDlg *dlg) if (filename && (stat(filename, &st) == 0)) { const char *non_regular_file_type_description = get_non_regular_file_type_description(st.st_mode); + const char *test_filename; /* Make sure this is a regular file */ if (non_regular_file_type_description) { @@ -2959,8 +2905,8 @@ static void update_xconfig_save_buffer(SaveXConfDlg *dlg) } /* Must be able to open the file */ - tmp_filename = (char *)xconfigOpenConfigFile(filename, NULL); - if (!tmp_filename || strcmp(tmp_filename, filename)) { + test_filename = xconfigOpenConfigFile(filename, NULL); + if (!test_filename || strcmp(test_filename, filename)) { xconfigCloseConfigFile(); } else { @@ -3231,7 +3177,7 @@ void run_save_xconfig_dialog(SaveXConfDlg *dlg) void *buf; GtkTextIter buf_start, buf_end; gchar *filename; - gchar *tmp_filename; + const gchar *tmp_filename; struct stat st; gint result; @@ -3263,11 +3209,12 @@ void run_save_xconfig_dialog(SaveXConfDlg *dlg) case GTK_RESPONSE_ACCEPT: /* Get the filename to write to */ - tmp_filename = - (gchar *) gtk_entry_get_text(GTK_ENTRY(dlg->txt_xconfig_file)); + tmp_filename = gtk_entry_get_text(GTK_ENTRY(dlg->txt_xconfig_file)); filename = tilde_expansion(tmp_filename); - if (filename == tmp_filename) { - filename = g_strdup(tmp_filename); + + if (!filename) { + nv_error_msg("Failed to get X configuration filename!"); + break; } /* If the file exists, make sure it is a regular file */ @@ -3327,7 +3274,7 @@ SaveXConfDlg *create_save_xconfig_dialog(GtkWidget *parent, GtkWidget *hbox; GtkWidget *hbox2; gchar *filename; - + const char *tmp_filename; dlg = (SaveXConfDlg *) malloc (sizeof(SaveXConfDlg)); if (!dlg) return NULL; @@ -3338,9 +3285,9 @@ SaveXConfDlg *create_save_xconfig_dialog(GtkWidget *parent, dlg->callback_data = callback_data; /* Setup the default filename */ - filename = (gchar *) xconfigOpenConfigFile(NULL, NULL); - if (filename) { - filename = g_strdup(filename); + tmp_filename = xconfigOpenConfigFile(NULL, NULL); + if (tmp_filename) { + filename = g_strdup(tmp_filename); } else { filename = g_strdup(""); } diff --git a/src/gtk+-2.x/ctkdisplayconfig.c b/src/gtk+-2.x/ctkdisplayconfig.c index 7947005..7e19d33 100644 --- a/src/gtk+-2.x/ctkdisplayconfig.c +++ b/src/gtk+-2.x/ctkdisplayconfig.c @@ -138,7 +138,6 @@ typedef struct SwitchModeCallbackInfoRec { #define VALIDATE_APPLY 0 #define VALIDATE_SAVE 1 -#define SCREEN_DEPTH_COUNT 5 /*** G L O B A L S ***********************************************************/ @@ -3069,6 +3068,30 @@ static void setup_screen_virtual_size(CtkDisplayConfig *ctk_object) +/** grow_screen_depth_table() ************************************** + * + * realloc the screen_depth_table, if possible. + * + **/ + +static gboolean grow_screen_depth_table(CtkDisplayConfig *ctk_object) +{ + int *tmp = realloc(ctk_object->screen_depth_table, + sizeof(int) * + (ctk_object->screen_depth_table_len + 1)); + if (!tmp) { + return False; + } + + ctk_object->screen_depth_table = tmp; + ctk_object->screen_depth_table_len++; + + return True; + +} /* grow_screen_depth_table() */ + + + /** setup_screen_depth_dropdown() ************************************ * * Generates the color depth dropdown based on the currently selected @@ -3081,11 +3104,10 @@ static void setup_screen_depth_dropdown(CtkDisplayConfig *ctk_object) GtkWidget *menu; GtkWidget *menu_item; int cur_idx; - int screen_depth_table_len = 0; gboolean add_depth_30_option; nvScreenPtr screen = ctk_display_layout_get_selected_screen (CTK_DISPLAY_LAYOUT(ctk_object->obj_layout)); - + if (!screen) { gtk_widget_hide(ctk_object->box_screen_depth); return; @@ -3093,8 +3115,8 @@ static void setup_screen_depth_dropdown(CtkDisplayConfig *ctk_object) if (ctk_object->screen_depth_table) { free(ctk_object->screen_depth_table); } - ctk_object->screen_depth_table = - (char *) malloc(sizeof(char) * SCREEN_DEPTH_COUNT); + ctk_object->screen_depth_table = NULL; + ctk_object->screen_depth_table_len = 0; menu = gtk_menu_new(); @@ -3109,33 +3131,45 @@ static void setup_screen_depth_dropdown(CtkDisplayConfig *ctk_object) } if (add_depth_30_option) { - menu_item = gtk_menu_item_new_with_label - ("1.1 Billion Colors (Depth 30) - Experimental"); + + if (grow_screen_depth_table(ctk_object)) { + menu_item = gtk_menu_item_new_with_label + ("1.1 Billion Colors (Depth 30) - Experimental"); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); + gtk_widget_show(menu_item); + + ctk_object->screen_depth_table[ctk_object->screen_depth_table_len-1] = 30; + } + } + + if (grow_screen_depth_table(ctk_object)) { + menu_item = gtk_menu_item_new_with_label("16.7 Million Colors (Depth 24)"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); gtk_widget_show(menu_item); - ctk_object->screen_depth_table[screen_depth_table_len++] = 30; + ctk_object->screen_depth_table[ctk_object->screen_depth_table_len-1] = 24; } - menu_item = gtk_menu_item_new_with_label("16.7 Million Colors (Depth 24)"); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); - gtk_widget_show(menu_item); - ctk_object->screen_depth_table[screen_depth_table_len++] = 24; - menu_item = gtk_menu_item_new_with_label("65,536 Colors (Depth 16)"); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); - gtk_widget_show(menu_item); - ctk_object->screen_depth_table[screen_depth_table_len++] = 16; + if (grow_screen_depth_table(ctk_object)) { + menu_item = gtk_menu_item_new_with_label("65,536 Colors (Depth 16)"); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); + gtk_widget_show(menu_item); + ctk_object->screen_depth_table[ctk_object->screen_depth_table_len-1] = 16; + } - menu_item = gtk_menu_item_new_with_label("32,768 Colors (Depth 15)"); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); - gtk_widget_show(menu_item); - ctk_object->screen_depth_table[screen_depth_table_len++] = 15; + if (grow_screen_depth_table(ctk_object)) { + menu_item = gtk_menu_item_new_with_label("32,768 Colors (Depth 15)"); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); + gtk_widget_show(menu_item); + ctk_object->screen_depth_table[ctk_object->screen_depth_table_len-1] = 15; + } - menu_item = gtk_menu_item_new_with_label("256 Colors (Depth 8)"); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); - gtk_widget_show(menu_item); - ctk_object->screen_depth_table[screen_depth_table_len++] = 8; + if (grow_screen_depth_table(ctk_object)) { + menu_item = gtk_menu_item_new_with_label("256 Colors (Depth 8)"); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); + gtk_widget_show(menu_item); + ctk_object->screen_depth_table[ctk_object->screen_depth_table_len-1] = 8; + } - assert(screen_depth_table_len <= SCREEN_DEPTH_COUNT); g_signal_handlers_block_by_func(G_OBJECT(ctk_object->mnu_screen_depth), G_CALLBACK(screen_depth_changed), (gpointer) ctk_object); @@ -3143,7 +3177,7 @@ static void setup_screen_depth_dropdown(CtkDisplayConfig *ctk_object) gtk_option_menu_set_menu (GTK_OPTION_MENU(ctk_object->mnu_screen_depth), menu); - for (cur_idx = 0; cur_idx < SCREEN_DEPTH_COUNT; cur_idx++) { + for (cur_idx = 0; cur_idx < ctk_object->screen_depth_table_len; cur_idx++) { if (screen->depth == ctk_object->screen_depth_table[cur_idx]) { gtk_option_menu_set_history (GTK_OPTION_MENU(ctk_object->mnu_screen_depth), cur_idx); @@ -3453,6 +3487,7 @@ static void setup_screen_page(CtkDisplayConfig *ctk_object) gchar *tmp; gint page_num; GtkWidget *tab_label; + GParamSpec* param_spec = NULL; page_num = gtk_notebook_page_num(GTK_NOTEBOOK(ctk_object->notebook), @@ -3476,8 +3511,21 @@ static void setup_screen_page(CtkDisplayConfig *ctk_object) /* Setup the screen number */ tmp = g_strdup_printf("%d", screen->scrnum); - g_object_set(gtk_widget_get_settings(ctk_object->txt_screen_num), - "gtk-label-select-on-focus", FALSE, NULL); + + param_spec = g_object_class_find_property + (G_OBJECT_GET_CLASS(gtk_widget_get_settings(ctk_object->txt_screen_num)), + "gtk-label-select-on-focus"); + + if (param_spec) { + /* + * When running against versions of gtk that have the + * "gtk-label-select-on-focus" property, set the property to FALSE for + * the screen label so that it isn't auto-selected when switching tabs + */ + g_object_set(gtk_widget_get_settings(ctk_object->txt_screen_num), + "gtk-label-select-on-focus", FALSE, NULL); + } + gtk_label_set_text(GTK_LABEL(ctk_object->txt_screen_num), tmp); g_free(tmp); @@ -3583,7 +3631,8 @@ static gint validation_fix_crowded_metamodes(CtkDisplayConfig *ctk_object, /* Delete the metamode */ ctk_display_layout_delete_screen_metamode - (CTK_DISPLAY_LAYOUT(ctk_object->obj_layout), screen, i); + (CTK_DISPLAY_LAYOUT(ctk_object->obj_layout), screen, i, + TRUE); nv_info_msg(TAB, "Removed MetaMode %d on Screen %d (No " "active display devices)\n", i, @@ -3646,7 +3695,8 @@ static gint validation_remove_dupe_metamodes(CtkDisplayConfig *ctk_object, /* Delete the metamode */ ctk_display_layout_delete_screen_metamode - (CTK_DISPLAY_LAYOUT(ctk_object->obj_layout), screen, i); + (CTK_DISPLAY_LAYOUT(ctk_object->obj_layout), screen, i, + TRUE); nv_info_msg(TAB, "Removed MetaMode %d on Screen %d (Is " "Duplicate of MetaMode %d)\n", i+1, screen->scrnum, @@ -4213,6 +4263,7 @@ static void prepare_gpu_for_twinview(CtkDisplayConfig *ctk_object, /* Delete implicit metamodes from all screens involved */ for (screen = gpu->screens; screen; screen = screen->next) { nvMetaModePtr next; + Bool updated = FALSE; m = 0; metamode = screen->metamodes; @@ -4223,12 +4274,24 @@ static void prepare_gpu_for_twinview(CtkDisplayConfig *ctk_object, (metamode != screen->cur_metamode)) { ctk_display_layout_delete_screen_metamode - (CTK_DISPLAY_LAYOUT(ctk_object->obj_layout), screen, m); + (CTK_DISPLAY_LAYOUT(ctk_object->obj_layout), screen, m, + FALSE); + updated = TRUE; } else { m++; } metamode = next; } + + /* Now that all the implicit metamodes have been deleted, + * we can recalculate and reselect the current mode + * for the screen. + */ + if (updated) { + ctk_display_layout_set_screen_metamode + (CTK_DISPLAY_LAYOUT(ctk_object->obj_layout), + screen, screen->cur_metamode_idx); + } } /* Make all other X screens in the layout relative to the GPU's @@ -5458,6 +5521,8 @@ static void screen_depth_changed(GtkWidget *widget, gpointer user_data) if (!screen) return; + if (idx >= ctk_object->screen_depth_table_len) return; + depth = ctk_object->screen_depth_table[idx]; if (depth == 30) { @@ -5786,7 +5851,7 @@ static void screen_metamode_delete_clicked(GtkWidget *widget, ctk_display_layout_delete_screen_metamode (CTK_DISPLAY_LAYOUT(ctk_object->obj_layout), - screen, screen->cur_metamode_idx); + screen, screen->cur_metamode_idx, TRUE); /* Update the GUI */ setup_display_page(ctk_object); @@ -5998,7 +6063,7 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object, case GTK_RESPONSE_YES: ctk_display_layout_delete_screen_metamode (CTK_DISPLAY_LAYOUT(ctk_object->obj_layout), - screen, screen->cur_metamode_idx); + screen, screen->cur_metamode_idx, TRUE); nv_info_msg(TAB, "Removed MetaMode %d on Screen %d.\n", screen->cur_metamode_idx+1, @@ -6085,14 +6150,14 @@ static Bool switch_to_current_metamode(CtkDisplayConfig *ctk_object, static char *find_metamode_string(char *metamode_str, char *metamode_strs) { char *m; - char *str; + const char *str; for (m = metamode_strs; m && strlen(m); m += strlen(m) +1) { /* Skip tokens if any */ str = strstr(m, "::"); if (str) { - str = (char *)parse_skip_whitespace(str +2); + str = parse_skip_whitespace(str +2); } else { str = m; } @@ -6242,8 +6307,8 @@ static void order_metamodes(nvScreenPtr screen) static void postprocess_metamodes(nvScreenPtr screen, char *metamode_strs) { - char *metamode_str; - char *str; + char *metamode_str, *tmp; + const char *str; ReturnStatus ret; @@ -6256,16 +6321,19 @@ static void postprocess_metamodes(nvScreenPtr screen, char *metamode_strs) str = strstr(metamode_str, "::"); if (!str) continue; - str = (char *)parse_skip_whitespace(str +2); - + str = parse_skip_whitespace(str +2); + tmp = strdup(str); + if (!tmp) continue; /* Delete the metamode */ ret = NvCtrlSetStringAttribute(screen->handle, NV_CTRL_STRING_DELETE_METAMODE, - str, NULL); + tmp, NULL); if (ret == NvCtrlSuccess) { nv_info_msg(TAB, "Removed > %s", str); } + + free(tmp); } /* Reorder the list of metamodes */ @@ -6286,7 +6354,7 @@ static int update_screen_metamodes(CtkDisplayConfig *ctk_object, { char *metamode_strs = NULL; char *cur_metamode_str = NULL; - char *metamode_str; + const char *metamode_str; int len; int clear_apply = 0; /* Set if we should clear the apply button */ @@ -6334,7 +6402,7 @@ static int update_screen_metamodes(CtkDisplayConfig *ctk_object, /* Skip tokens */ metamode_str = strstr(cur_metamode_str, "::"); if (metamode_str) { - metamode_str = (char *)parse_skip_whitespace(metamode_str +2); + metamode_str = parse_skip_whitespace(metamode_str +2); } else { metamode_str = cur_metamode_str; } diff --git a/src/gtk+-2.x/ctkdisplayconfig.h b/src/gtk+-2.x/ctkdisplayconfig.h index 6a35513..6aacca0 100644 --- a/src/gtk+-2.x/ctkdisplayconfig.h +++ b/src/gtk+-2.x/ctkdisplayconfig.h @@ -132,8 +132,10 @@ typedef struct _CtkDisplayConfig GtkWidget *btn_screen_metamode; GtkWidget *btn_screen_metamode_add; GtkWidget *btn_screen_metamode_delete; - - char *screen_depth_table; + + int *screen_depth_table; + int screen_depth_table_len; + /* Dialogs */ GtkWidget *dlg_display_config; GtkWidget *rad_display_config_disabled; diff --git a/src/gtk+-2.x/ctkdisplaydevice-crt.c b/src/gtk+-2.x/ctkdisplaydevice-crt.c index fffa40d..b2f989a 100644 --- a/src/gtk+-2.x/ctkdisplaydevice-crt.c +++ b/src/gtk+-2.x/ctkdisplaydevice-crt.c @@ -33,6 +33,7 @@ #include "ctkedid.h" #include "ctkconfig.h" #include "ctkhelp.h" +#include "ctkutils.h" #include <stdio.h> static void ctk_display_device_crt_class_init(CtkDisplayDeviceCrtClass *); @@ -224,6 +225,10 @@ GtkWidget* ctk_display_device_crt_new(NvCtrlAttributeHandle *handle, /* Update the GUI */ + update_display_enabled_flag(ctk_display_device_crt->handle, + &ctk_display_device_crt->display_enabled, + ctk_display_device_crt->display_device_mask); + ctk_display_device_crt_setup(ctk_display_device_crt); /* handle enable/disable events on the display device */ @@ -304,20 +309,6 @@ static void reset_button_clicked(GtkButton *button, gpointer user_data) static void ctk_display_device_crt_setup(CtkDisplayDeviceCrt *ctk_display_device_crt) { - ReturnStatus ret; - unsigned int enabled_displays; - - - /* Is display enabled? */ - - ret = NvCtrlGetAttribute(ctk_display_device_crt->handle, - NV_CTRL_ENABLED_DISPLAYS, - (int *)&enabled_displays); - - ctk_display_device_crt->display_enabled = - (ret == NvCtrlSuccess && - (enabled_displays & (ctk_display_device_crt->display_device_mask))); - /* Update CRT-specific settings */ crt_info_setup(ctk_display_device_crt); @@ -394,6 +385,16 @@ static void enabled_displays_received(GtkObject *object, gpointer arg1, { CtkDisplayDeviceCrt *ctk_object = CTK_DISPLAY_DEVICE_CRT(user_data); + /* Requery display information only if display disabled */ + + update_display_enabled_flag(ctk_object->handle, + &ctk_object->display_enabled, + ctk_object->display_device_mask); + + if (ctk_object->display_enabled) { + return; + } + ctk_display_device_crt_setup(ctk_object); } /* enabled_displays_received() */ diff --git a/src/gtk+-2.x/ctkdisplaydevice-dfp.c b/src/gtk+-2.x/ctkdisplaydevice-dfp.c index 6cab80f..7829bfb 100644 --- a/src/gtk+-2.x/ctkdisplaydevice-dfp.c +++ b/src/gtk+-2.x/ctkdisplaydevice-dfp.c @@ -29,6 +29,7 @@ #include "ctkdisplaydevice-dfp.h" +#include "ctkditheringcontrols.h" #include "ctkimagesliders.h" #include "ctkedid.h" #include "ctkconfig.h" @@ -204,6 +205,8 @@ GtkWidget* ctk_display_device_dfp_new(NvCtrlAttributeHandle *handle, GtkWidget *alignment; GtkWidget *table; + ReturnStatus ret1, ret2; + gint val_target, val_method; object = g_object_new(CTK_TYPE_DISPLAY_DEVICE_DFP, NULL); if (!object) return NULL; @@ -215,6 +218,28 @@ GtkWidget* ctk_display_device_dfp_new(NvCtrlAttributeHandle *handle, ctk_display_device_dfp->display_device_mask = display_device_mask; ctk_display_device_dfp->name = g_strdup(name); + /* cache the default scaling target & method values */ + ret1 = + NvCtrlGetDisplayAttribute(ctk_display_device_dfp->handle, + ctk_display_device_dfp->display_device_mask, + NV_CTRL_GPU_SCALING_DEFAULT_TARGET, + &val_target); + ret2 = + NvCtrlGetDisplayAttribute(ctk_display_device_dfp->handle, + ctk_display_device_dfp->display_device_mask, + NV_CTRL_GPU_SCALING_DEFAULT_METHOD, + &val_method); + + if (ret1 != NvCtrlSuccess || ret2 != NvCtrlSuccess || + val_target == NV_CTRL_GPU_SCALING_TARGET_INVALID || + val_method == NV_CTRL_GPU_SCALING_METHOD_INVALID) { + val_target = NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_BEST_FIT; + val_method = NV_CTRL_GPU_SCALING_METHOD_STRETCHED; + } + + ctk_display_device_dfp->default_scaling_target = val_target; + ctk_display_device_dfp->default_scaling_method = val_method; + gtk_box_set_spacing(GTK_BOX(object), 10); /* banner */ @@ -435,6 +460,21 @@ GtkWidget* ctk_display_device_dfp_new(NvCtrlAttributeHandle *handle, G_CALLBACK(dfp_update_received), (gpointer) ctk_display_device_dfp); + /* pack the dithering controls */ + + ctk_display_device_dfp->dithering_controls = + ctk_dithering_controls_new(ctk_display_device_dfp->handle, + ctk_display_device_dfp->ctk_config, + ctk_display_device_dfp->ctk_event, + ctk_display_device_dfp->reset_button, + ctk_display_device_dfp->display_device_mask); + + if (ctk_display_device_dfp->dithering_controls) { + gtk_box_pack_start(GTK_BOX(object), + ctk_display_device_dfp->dithering_controls, + FALSE, FALSE, 0); + } + /* pack the image sliders */ ctk_display_device_dfp->image_sliders = @@ -459,6 +499,10 @@ GtkWidget* ctk_display_device_dfp_new(NvCtrlAttributeHandle *handle, /* Update the GUI */ + update_display_enabled_flag(ctk_display_device_dfp->handle, + &ctk_display_device_dfp->display_enabled, + ctk_display_device_dfp->display_device_mask); + ctk_display_device_dfp_setup(ctk_display_device_dfp); /* handle enable/disable events on the display device */ @@ -667,16 +711,23 @@ static void reset_button_clicked(GtkButton *button, gpointer user_data) if (ctk_display_device_dfp->active_attributes & __SCALING) { value = - MAKE_SCALING_VALUE(NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_BEST_FIT, - NV_CTRL_GPU_SCALING_METHOD_STRETCHED); + MAKE_SCALING_VALUE(ctk_display_device_dfp->default_scaling_target, + ctk_display_device_dfp->default_scaling_method); + NvCtrlSetDisplayAttribute(ctk_display_device_dfp->handle, ctk_display_device_dfp->display_device_mask, NV_CTRL_GPU_SCALING, value); - dfp_scaling_update_buttons(ctk_display_device_dfp, value); + dfp_scaling_setup(ctk_display_device_dfp); } - + + /* Reset the dithering configuration */ + if (ctk_display_device_dfp->dithering_controls) { + ctk_dithering_controls_reset + (CTK_DITHERING_CONTROLS(ctk_display_device_dfp->dithering_controls)); + } + /* Update the reset button */ gtk_widget_set_sensitive(ctk_display_device_dfp->reset_button, FALSE); @@ -878,6 +929,11 @@ GtkTextBuffer *ctk_display_device_dfp_create_help(GtkTextTagTable *table, "aspect ratio) to expand and fit as much of the entire " "flat panel as possible."); + if (ctk_display_device_dfp->dithering_controls) { + add_dithering_controls_help + (CTK_DITHERING_CONTROLS(ctk_display_device_dfp->dithering_controls), b, &i); + } + add_image_sliders_help (CTK_IMAGE_SLIDERS(ctk_display_device_dfp->image_sliders), b, &i); @@ -1172,21 +1228,6 @@ static void dfp_scaling_setup(CtkDisplayDeviceDfp *ctk_display_device_dfp) static void ctk_display_device_dfp_setup(CtkDisplayDeviceDfp *ctk_display_device_dfp) { - ReturnStatus ret; - unsigned int enabled_displays; - - - /* Is display enabled? */ - - ret = NvCtrlGetAttribute(ctk_display_device_dfp->handle, - NV_CTRL_ENABLED_DISPLAYS, - (int *)&enabled_displays); - - ctk_display_device_dfp->display_enabled = - (ret == NvCtrlSuccess && - (enabled_displays & (ctk_display_device_dfp->display_device_mask))); - - /* Update DFP-specific settings */ dfp_info_setup(ctk_display_device_dfp); @@ -1228,6 +1269,10 @@ static void ctk_display_device_dfp_setup(CtkDisplayDeviceDfp ctk_display_device_dfp->edid, TRUE, TRUE, 0); } + /* Update the dithering setup */ + + ctk_dithering_controls_setup + (CTK_DITHERING_CONTROLS(ctk_display_device_dfp->dithering_controls)); /* update the reset button */ @@ -1247,6 +1292,16 @@ static void enabled_displays_received(GtkObject *object, gpointer arg1, { CtkDisplayDeviceDfp *ctk_object = CTK_DISPLAY_DEVICE_DFP(user_data); + /* Requery display information only if display disabled */ + + update_display_enabled_flag(ctk_object->handle, + &ctk_object->display_enabled, + ctk_object->display_device_mask); + + if (ctk_object->display_enabled) { + return; + } + ctk_display_device_dfp_setup(ctk_object); } /* enabled_displays_received() */ diff --git a/src/gtk+-2.x/ctkdisplaydevice-dfp.h b/src/gtk+-2.x/ctkdisplaydevice-dfp.h index 03b2051..b8621ba 100644 --- a/src/gtk+-2.x/ctkdisplaydevice-dfp.h +++ b/src/gtk+-2.x/ctkdisplaydevice-dfp.h @@ -65,6 +65,7 @@ struct _CtkDisplayDeviceDfp GtkWidget *reset_button; GtkWidget *edid_box; GtkWidget *edid; + GtkWidget *dithering_controls; GtkWidget *txt_chip_location; GtkWidget *txt_link; @@ -86,6 +87,8 @@ struct _CtkDisplayDeviceDfp unsigned int active_attributes; char *name; + gint default_scaling_target; + gint default_scaling_method; }; struct _CtkDisplayDeviceDfpClass diff --git a/src/gtk+-2.x/ctkdisplaydevice-tv.c b/src/gtk+-2.x/ctkdisplaydevice-tv.c index 954e980..076227e 100644 --- a/src/gtk+-2.x/ctkdisplaydevice-tv.c +++ b/src/gtk+-2.x/ctkdisplaydevice-tv.c @@ -38,6 +38,7 @@ #include "ctkconfig.h" #include "ctkhelp.h" #include "ctkscale.h" +#include "ctkutils.h" #include <stdio.h> #define FRAME_PADDING 5 @@ -388,6 +389,10 @@ GtkWidget* ctk_display_device_tv_new(NvCtrlAttributeHandle *handle, /* update the GUI */ + update_display_enabled_flag(ctk_display_device_tv->handle, + &ctk_display_device_tv->display_enabled, + ctk_display_device_tv->display_device_mask); + ctk_display_device_tv_setup(ctk_display_device_tv); /* handle enable/disable events on the display device */ @@ -808,21 +813,6 @@ static void setup_scale(CtkDisplayDeviceTv *ctk_display_device_tv, static void ctk_display_device_tv_setup(CtkDisplayDeviceTv *ctk_display_device_tv) { - ReturnStatus ret; - unsigned int enabled_displays; - - - /* Is display enabled? */ - - ret = NvCtrlGetAttribute(ctk_display_device_tv->handle, - NV_CTRL_ENABLED_DISPLAYS, - (int *)&enabled_displays); - - ctk_display_device_tv->display_enabled = - (ret == NvCtrlSuccess && - (enabled_displays & (ctk_display_device_tv->display_device_mask))); - - /* Update Information Frame */ tv_info_setup(ctk_display_device_tv); @@ -949,6 +939,16 @@ static void enabled_displays_received(GtkObject *object, gpointer arg1, { CtkDisplayDeviceTv *ctk_object = CTK_DISPLAY_DEVICE_TV(user_data); + /* Requery display information only if display disabled */ + + update_display_enabled_flag(ctk_object->handle, + &ctk_object->display_enabled, + ctk_object->display_device_mask); + + if (ctk_object->display_enabled) { + return; + } + ctk_display_device_tv_setup(ctk_object); } /* enabled_displays_received() */ diff --git a/src/gtk+-2.x/ctkdisplaylayout.c b/src/gtk+-2.x/ctkdisplaylayout.c index b572a4d..3a119f3 100644 --- a/src/gtk+-2.x/ctkdisplaylayout.c +++ b/src/gtk+-2.x/ctkdisplaylayout.c @@ -3721,7 +3721,8 @@ void ctk_display_layout_add_screen_metamode(CtkDisplayLayout *ctk_object, void ctk_display_layout_delete_screen_metamode(CtkDisplayLayout *ctk_object, nvScreenPtr screen, - int metamode_idx) + int metamode_idx, + Bool reselect) { nvDisplayPtr display; nvMetaModePtr metamode; @@ -3802,8 +3803,10 @@ void ctk_display_layout_delete_screen_metamode(CtkDisplayLayout *ctk_object, /* Update which metamode should be selected */ - ctk_display_layout_set_screen_metamode - (ctk_object, screen, screen->cur_metamode_idx); + if (reselect) { + ctk_display_layout_set_screen_metamode + (ctk_object, screen, screen->cur_metamode_idx); + } } /* ctk_display_layout_delete_screen_metamode() */ diff --git a/src/gtk+-2.x/ctkdisplaylayout.h b/src/gtk+-2.x/ctkdisplaylayout.h index bd56d7c..10ea728 100644 --- a/src/gtk+-2.x/ctkdisplaylayout.h +++ b/src/gtk+-2.x/ctkdisplaylayout.h @@ -519,7 +519,8 @@ void ctk_display_layout_set_screen_metamode (CtkDisplayLayout *, void ctk_display_layout_add_screen_metamode (CtkDisplayLayout *, nvScreenPtr); void ctk_display_layout_delete_screen_metamode (CtkDisplayLayout *, nvScreenPtr, - int metamode_idx); + int metamode_idx, + Bool reselect); void ctk_display_layout_disable_display (CtkDisplayLayout *ctk_object, nvDisplayPtr display); diff --git a/src/gtk+-2.x/ctkditheringcontrols.c b/src/gtk+-2.x/ctkditheringcontrols.c new file mode 100644 index 0000000..3d3f5b6 --- /dev/null +++ b/src/gtk+-2.x/ctkditheringcontrols.c @@ -0,0 +1,563 @@ +/* + * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix + * and Linux systems. + * + * Copyright (C) 2010 NVIDIA Corporation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of Version 2 of the GNU General Public + * License 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 Version 2 + * of the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the: + * + * Free Software Foundation, Inc. + * 59 Temple Place - Suite 330 + * Boston, MA 02111-1307, USA + * + */ + +#include <gtk/gtk.h> +#include <NvCtrlAttributes.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/mman.h> +#include <errno.h> + +#include "ctkconfig.h" +#include "ctkhelp.h" +#include "ctkditheringcontrols.h" + +/* function prototypes */ +static gboolean build_dithering_mode_table(CtkDitheringControls *ctk_dithering_controls, + NVCTRLAttributeValidValuesRec valid); + +static gint map_nvctrl_value_to_table(CtkDitheringControls *ctk_dithering_controls, + gint val); + +static void enable_dithering_toggled(GtkWidget *widget, gpointer user_data); + +static Bool update_dithering_mode_menu_info(gpointer user_data); + +static void update_dithering_mode_menu_event(GtkObject *object, + gpointer arg1, + gpointer user_data); + +static void dithering_mode_menu_changed(GtkOptionMenu *dithering_mode_menu, + gpointer user_data); + +static void dithering_update_received(GtkObject *object, gpointer arg1, + gpointer user_data); + +/* macros */ +#define FRAME_PADDING 5 + +/* help text */ +static const char * __dithering_help = +"The Dithering Controls show the current state of dithering and allow " +"changing the dithering configuration. Dithering will be performed " +"when dithering is enabled here, and the flat panel's bitdepth is " +"less than that of the GPU's internal pixel pipeline."; + +GType ctk_dithering_controls_get_type(void) +{ + static GType ctk_dithering_controls_type = 0; + + if (!ctk_dithering_controls_type) { + static const GTypeInfo ctk_dithering_controls_info = { + sizeof (CtkDitheringControlsClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + NULL, /* class_init, */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (CtkDitheringControls), + 0, /* n_preallocs */ + NULL, /* instance_init */ + }; + + ctk_dithering_controls_type = + g_type_register_static (GTK_TYPE_VBOX, + "CtkDitheringControls", + &ctk_dithering_controls_info, 0); + } + + return ctk_dithering_controls_type; +} /* ctk_dithering_controls_get_type() */ + +GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle, + CtkConfig *ctk_config, + CtkEvent *ctk_event, + GtkWidget *reset_button, + unsigned int display_device_mask) +{ + GObject *object; + CtkDitheringControls *ctk_dithering_controls; + GtkWidget *frame, *vbox, *hbox, *label; + GtkWidget *menu, *table, *menu_item = NULL; + GtkWidget *button, *vseparator; + ReturnStatus ret1, ret2; + NVCTRLAttributeValidValuesRec valid; + gint val, i, dithering_config, dithering_mode; + + /* check if dithering modes are supported */ + ret1 = NvCtrlGetValidDisplayAttributeValues(handle, display_device_mask, + NV_CTRL_FLATPANEL_DITHERING_MODE, + &valid); + + ret2 = NvCtrlGetDisplayAttribute(handle, display_device_mask, + NV_CTRL_FLATPANEL_DITHERING_MODE, + &val); + + if ((ret1 != NvCtrlSuccess) || (ret2 != NvCtrlSuccess) || + (valid.type != ATTRIBUTE_TYPE_INT_BITS)) { + return NULL; + } + + /* create the object */ + object = g_object_new(CTK_TYPE_DITHERING_CONTROLS, NULL); + if (!object) { + return NULL; + } + + ctk_dithering_controls = CTK_DITHERING_CONTROLS(object); + ctk_dithering_controls->handle = handle; + ctk_dithering_controls->ctk_config = ctk_config; + ctk_dithering_controls->reset_button = reset_button; + ctk_dithering_controls->display_device_mask = display_device_mask; + + /* build a table holding available dithering modes */ + if (!build_dithering_mode_table(ctk_dithering_controls, valid)) { + return NULL; + } + + /* cache the default dithering config & mode values */ + ret1 = + NvCtrlGetDisplayAttribute(ctk_dithering_controls->handle, + ctk_dithering_controls->display_device_mask, + NV_CTRL_FLATPANEL_DEFAULT_DITHERING, + &dithering_config); + + ret2 = + NvCtrlGetDisplayAttribute(ctk_dithering_controls->handle, + ctk_dithering_controls->display_device_mask, + NV_CTRL_FLATPANEL_DEFAULT_DITHERING_MODE, + &dithering_mode); + + if (ret1 != NvCtrlSuccess || ret2 != NvCtrlSuccess) { + dithering_config = NV_CTRL_FLATPANEL_DITHERING_ENABLED; + dithering_mode = NV_CTRL_FLATPANEL_DITHERING_MODE_DYNAMIC_2X2; + } + + ctk_dithering_controls->default_dithering_config = dithering_config; + ctk_dithering_controls->default_dithering_mode = dithering_mode; + + /* create main dithering box & frame */ + + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(object), hbox, FALSE, FALSE, FRAME_PADDING); + ctk_dithering_controls->dithering_controls_main = hbox; + + frame = gtk_frame_new("Dithering Controls"); + gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, FALSE, 0); + + hbox = gtk_hbox_new(FALSE, FRAME_PADDING); + gtk_container_set_border_width(GTK_CONTAINER(hbox), FRAME_PADDING); + gtk_container_add(GTK_CONTAINER(frame), hbox); + + /* add checkbox */ + button = gtk_check_button_new_with_label("Enable"); + ctk_dithering_controls->enable_dithering_button = button; + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); + ctk_config_set_tooltip(ctk_config, button, __dithering_help); + + g_signal_connect(G_OBJECT(button), "toggled", + G_CALLBACK(enable_dithering_toggled), + (gpointer) ctk_dithering_controls); + + /* add vseparator */ + vseparator = gtk_vseparator_new(); + gtk_box_pack_start(GTK_BOX(hbox), vseparator, TRUE, TRUE, 0); + + /* add dropdown menu */ + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), FRAME_PADDING); + gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); + ctk_dithering_controls->dithering_mode_box = vbox; + + /* Specifying drop down list */ + menu = gtk_menu_new(); + + for (i = 0; i < ctk_dithering_controls->dithering_mode_table_size; i++) { + switch (ctk_dithering_controls->dithering_mode_table[i]) { + case NV_CTRL_FLATPANEL_DITHERING_MODE_DYNAMIC_2X2: + menu_item = gtk_menu_item_new_with_label("Dynamic 2X2 mode"); + break; + case NV_CTRL_FLATPANEL_DITHERING_MODE_STATIC_2X2: + menu_item = gtk_menu_item_new_with_label("Static 2X2 mode"); + break; + } + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); + gtk_widget_show(menu_item); + } + + ctk_dithering_controls->dithering_mode_menu = gtk_option_menu_new(); + gtk_option_menu_set_menu + (GTK_OPTION_MENU(ctk_dithering_controls->dithering_mode_menu), + menu); + + g_signal_connect(G_OBJECT(ctk_dithering_controls->dithering_mode_menu), + "changed", G_CALLBACK(dithering_mode_menu_changed), + (gpointer) ctk_dithering_controls); + + /* Packing the drop down list */ + table = gtk_table_new(1, 2, FALSE); + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), 3); + gtk_table_set_col_spacings(GTK_TABLE(table), 15); + gtk_container_set_border_width(GTK_CONTAINER(table), 5); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + label = gtk_label_new("Mode:"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + gtk_box_pack_start(GTK_BOX(hbox), + ctk_dithering_controls->dithering_mode_menu, + FALSE, FALSE, 0); + + gtk_widget_show_all(GTK_WIDGET(object)); + + ctk_dithering_controls_setup(ctk_dithering_controls); + + g_signal_connect(G_OBJECT(ctk_event), + CTK_EVENT_NAME(NV_CTRL_FLATPANEL_DITHERING_MODE), + G_CALLBACK(update_dithering_mode_menu_event), + (gpointer) ctk_dithering_controls); + g_signal_connect(G_OBJECT(ctk_event), + CTK_EVENT_NAME(NV_CTRL_FLATPANEL_DITHERING), + G_CALLBACK(dithering_update_received), + (gpointer) ctk_dithering_controls); + + return GTK_WIDGET(object); + +} /* ctk_dithering_controls_new() */ + + +/* + * ctk_dithering_controls_setup() - Setup routine for dithering attributes. Used + * in DFP setup stage as well as for updating the GUI when there is change in + * dithering mode or config (enabled/disabled). + */ +void ctk_dithering_controls_setup(CtkDitheringControls *ctk_dithering_controls) +{ + gint val; + + if (!ctk_dithering_controls) { + return; + } + + /* update flatpanel dithering controls */ + if (NvCtrlSuccess != + NvCtrlGetDisplayAttribute(ctk_dithering_controls->handle, + ctk_dithering_controls->display_device_mask, + NV_CTRL_FLATPANEL_DITHERING, &val)) { + val = NV_CTRL_FLATPANEL_DITHERING_DISABLED; + } + + if (val == NV_CTRL_FLATPANEL_DITHERING_ENABLED) { + g_signal_handlers_block_by_func + (G_OBJECT(ctk_dithering_controls->enable_dithering_button), + G_CALLBACK(enable_dithering_toggled), + (gpointer) ctk_dithering_controls); + + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON(ctk_dithering_controls->enable_dithering_button), + TRUE); + + g_signal_handlers_unblock_by_func + (G_OBJECT(ctk_dithering_controls->enable_dithering_button), + G_CALLBACK(enable_dithering_toggled), + (gpointer) ctk_dithering_controls); + + gtk_widget_set_sensitive(ctk_dithering_controls->dithering_mode_box, + TRUE); + } else if (val == NV_CTRL_FLATPANEL_DITHERING_DISABLED) { + g_signal_handlers_block_by_func + (G_OBJECT(ctk_dithering_controls->enable_dithering_button), + G_CALLBACK(enable_dithering_toggled), + (gpointer) ctk_dithering_controls); + + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON(ctk_dithering_controls->enable_dithering_button), + FALSE); + + g_signal_handlers_unblock_by_func + (G_OBJECT(ctk_dithering_controls->enable_dithering_button), + G_CALLBACK(enable_dithering_toggled), + (gpointer) ctk_dithering_controls); + + gtk_widget_set_sensitive(ctk_dithering_controls->dithering_mode_box, + FALSE); + } + + if (!update_dithering_mode_menu_info + ((gpointer)ctk_dithering_controls)) { + gtk_widget_set_sensitive(ctk_dithering_controls->dithering_controls_main, + FALSE); + gtk_widget_hide_all(ctk_dithering_controls->dithering_controls_main); + } + +} /* ctk_dithering_controls_setup() */ + + +static void update_dithering_mode_menu_event(GtkObject *object, + gpointer arg1, + gpointer user_data) +{ + update_dithering_mode_menu_info(user_data); +} /* update_dithering_mode_menu_event() */ + +static Bool update_dithering_mode_menu_info(gpointer user_data) +{ + CtkDitheringControls *ctk_dithering_controls = + CTK_DITHERING_CONTROLS(user_data); + gint dithering_mode = NV_CTRL_FLATPANEL_DITHERING_MODE_DYNAMIC_2X2; + + if (NvCtrlSuccess != + NvCtrlGetDisplayAttribute(ctk_dithering_controls->handle, + ctk_dithering_controls->display_device_mask, + NV_CTRL_FLATPANEL_DITHERING_MODE, + &dithering_mode)) { + free(ctk_dithering_controls->dithering_mode_table); + return FALSE; + } + + dithering_mode = map_nvctrl_value_to_table(ctk_dithering_controls, + dithering_mode); + + g_signal_handlers_block_by_func + (G_OBJECT(ctk_dithering_controls->dithering_mode_menu), + G_CALLBACK(dithering_mode_menu_changed), + (gpointer) ctk_dithering_controls); + + gtk_option_menu_set_history + (GTK_OPTION_MENU(ctk_dithering_controls->dithering_mode_menu), + dithering_mode); + + g_signal_handlers_unblock_by_func + (G_OBJECT(ctk_dithering_controls->dithering_mode_menu), + G_CALLBACK(dithering_mode_menu_changed), + (gpointer) ctk_dithering_controls); + + gtk_widget_set_sensitive(ctk_dithering_controls->dithering_mode_menu, TRUE); + gtk_widget_show(ctk_dithering_controls->dithering_mode_menu); + + return TRUE; +} /* update_dithering_mode_menu_info() */ + +static void dithering_mode_menu_changed(GtkOptionMenu *dithering_mode_menu, + gpointer user_data) +{ + CtkDitheringControls *ctk_dithering_controls = + CTK_DITHERING_CONTROLS(user_data); + gint history, dithering_mode = NV_CTRL_FLATPANEL_DITHERING_MODE_DYNAMIC_2X2; + + history = gtk_option_menu_get_history(dithering_mode_menu); + + dithering_mode = ctk_dithering_controls->dithering_mode_table[history]; + + NvCtrlSetDisplayAttribute(ctk_dithering_controls->handle, + ctk_dithering_controls->display_device_mask, + NV_CTRL_FLATPANEL_DITHERING_MODE, + dithering_mode); + + dithering_mode = map_nvctrl_value_to_table(ctk_dithering_controls, + dithering_mode); + g_signal_handlers_block_by_func + (G_OBJECT(ctk_dithering_controls->dithering_mode_menu), + G_CALLBACK(dithering_mode_menu_changed), + (gpointer) ctk_dithering_controls); + + gtk_option_menu_set_history + (GTK_OPTION_MENU(ctk_dithering_controls->dithering_mode_menu), + dithering_mode); + + g_signal_handlers_unblock_by_func + (G_OBJECT(ctk_dithering_controls->dithering_mode_menu), + G_CALLBACK(dithering_mode_menu_changed), + (gpointer) ctk_dithering_controls); + + /* reflecting the change in dithering mode to reset button */ + gtk_widget_set_sensitive(ctk_dithering_controls->reset_button, TRUE); + +} /* dithering_mode_menu_changed() */ + + +/* + * enable_dithering_toggled() - Callback routine for Enable Dithering + * check box. + */ +static void enable_dithering_toggled(GtkWidget *widget, gpointer user_data) +{ + gboolean checked = FALSE; + CtkDitheringControls *ctk_dithering_controls = + CTK_DITHERING_CONTROLS(user_data); + + if (!ctk_dithering_controls) { + return; + } + + /* Get the checkbox status */ + checked = gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON(ctk_dithering_controls->enable_dithering_button)); + + if (checked) { + /* Enable the dithering effects */ + NvCtrlSetDisplayAttribute(ctk_dithering_controls->handle, + ctk_dithering_controls->display_device_mask, + NV_CTRL_FLATPANEL_DITHERING, + NV_CTRL_FLATPANEL_DITHERING_ENABLED); + } else { + /* Disable the dithering effects. */ + NvCtrlSetDisplayAttribute(ctk_dithering_controls->handle, + ctk_dithering_controls->display_device_mask, + NV_CTRL_FLATPANEL_DITHERING, + NV_CTRL_FLATPANEL_DITHERING_DISABLED); + } + + ctk_dithering_controls_setup(ctk_dithering_controls); + + /* Reflecting the change in dithering configuration to reset button */ + gtk_widget_set_sensitive(ctk_dithering_controls->reset_button, TRUE); + +} /* enable_dithering_toggled() */ + + +/* + * ctk_dithering_controls_reset() - Resets the dithering config (enabled/disabled) + * & dithering mode when Reset HW Defaults is clicked + */ +void ctk_dithering_controls_reset(CtkDitheringControls *ctk_dithering_controls) +{ + if (!ctk_dithering_controls) { + return; + } + + NvCtrlSetDisplayAttribute(ctk_dithering_controls->handle, + ctk_dithering_controls->display_device_mask, + NV_CTRL_FLATPANEL_DITHERING, + ctk_dithering_controls->default_dithering_config); + + if (ctk_dithering_controls->default_dithering_config == + NV_CTRL_FLATPANEL_DITHERING_ENABLED) { + + /* Setting dithering mode only makes sense when dithering is + * enabled by default + */ + NvCtrlSetDisplayAttribute(ctk_dithering_controls->handle, + ctk_dithering_controls->display_device_mask, + NV_CTRL_FLATPANEL_DITHERING_MODE, + ctk_dithering_controls->default_dithering_mode); + } + + ctk_dithering_controls_setup(ctk_dithering_controls); +} /* ctk_dithering_controls_reset() */ + + +/* + * add_dithering_controls_help() - + */ +void add_dithering_controls_help(CtkDitheringControls *ctk_dithering_controls, + GtkTextBuffer *b, + GtkTextIter *i) +{ + ctk_help_heading(b, i, "Dithering Controls"); + ctk_help_para(b, i, __dithering_help); +} /* add_dithering_controls_help() */ + + +/* + * When DFP dithering configuration is enabled/disabled, + * we should update the GUI to reflect the current state. + */ +static void dithering_update_received(GtkObject *object, gpointer arg1, + gpointer user_data) +{ + CtkDitheringControls *ctk_object = CTK_DITHERING_CONTROLS(user_data); + CtkEventStruct *event_struct = (CtkEventStruct *) arg1; + + /* if the event is not for this display device, return */ + + if (!(event_struct->display_mask & ctk_object->display_device_mask)) { + return; + } + + ctk_dithering_controls_setup(ctk_object); +} /* dithering_update_received() */ + + +/* + * build_dithering_mode_table() - build a table of dithering modes presently + * supported by the HW. + */ +static gboolean build_dithering_mode_table(CtkDitheringControls *ctk_dithering_controls, + NVCTRLAttributeValidValuesRec valid) +{ + gint i, n = 0, num_of_modes = 0; + gint mask = valid.u.bits.ints; + + if (valid.type != ATTRIBUTE_TYPE_INT_BITS) { + return False; + } + + /* count no. of supported modes */ + while(mask) { + mask = mask & (mask - 1); + num_of_modes++; + } + + ctk_dithering_controls->dithering_mode_table_size = num_of_modes; + ctk_dithering_controls->dithering_mode_table = calloc(1, num_of_modes); + if (!ctk_dithering_controls->dithering_mode_table) { + return False; + } + + for (i = 0; i <= num_of_modes; i++) { + if (valid.u.bits.ints & (1 << i)) { + ctk_dithering_controls->dithering_mode_table[n] = i; + n++; + } + } + + return True; + +} /* build_dithering_mode_table() */ + + +static gint map_nvctrl_value_to_table(CtkDitheringControls *ctk_dithering_controls, + gint val) +{ + int i; + for (i = 0; i < ctk_dithering_controls->dithering_mode_table_size; i++) { + if (val == ctk_dithering_controls->dithering_mode_table[i]) { + return i; + } + } + + return 0; +} /*map_nvctrl_value_to_table() */ diff --git a/src/gtk+-2.x/ctkditheringcontrols.h b/src/gtk+-2.x/ctkditheringcontrols.h new file mode 100644 index 0000000..4580eba --- /dev/null +++ b/src/gtk+-2.x/ctkditheringcontrols.h @@ -0,0 +1,93 @@ +/* + * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix + * and Linux systems. + * + * Copyright (C) 2010 NVIDIA Corporation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of Version 2 of the GNU General Public + * License 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 Version 2 + * of the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the: + * + * Free Software Foundation, Inc. + * 59 Temple Place - Suite 330 + * Boston, MA 02111-1307, USA + * + */ + +#ifndef __CTK_DITHERING_CONTROLS_H__ +#define __CTK_DITHERING_CONTROLS_H__ + +#include "ctkevent.h" +#include "ctkconfig.h" + +G_BEGIN_DECLS + +#define CTK_TYPE_DITHERING_CONTROLS (ctk_dithering_controls_get_type()) + +#define CTK_DITHERING_CONTROLS(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), CTK_TYPE_DITHERING_CONTROLS, \ + CtkDitheringControls)) + +#define CTK_DITHERING_CONTROLS_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), CTK_TYPE_DITHERING_CONTROLS, \ + CtkDitheringControlsClass)) + +#define CTK_IS_DITHERING_CONTROLS(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CTK_TYPE_DITHERING_CONTROLS)) + +#define CTK_IS_DITHERING_CONTROLS_CLASS(class) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), CTK_TYPE_DITHERING_CONTROLS)) + +#define CTK_DITHERING_CONTROLS_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), CTK_TYPE_DITHERING_CONTROLS, \ + CtkDitheringControlsClass)) + +typedef struct _CtkDitheringControls CtkDitheringControls; +typedef struct _CtkDitheringControlsClass CtkDitheringControlsClass; + +struct _CtkDitheringControls +{ + GtkVBox parent; + + NvCtrlAttributeHandle *handle; + CtkConfig *ctk_config; + GtkWidget *reset_button; + GtkWidget *dithering_controls_main; + GtkWidget *dithering_mode_menu; + GtkWidget *dithering_mode_box; + GtkWidget *enable_dithering_button; + + gint display_device_mask; + gint *dithering_mode_table; + gint dithering_mode_table_size; + gint default_dithering_config; + gint default_dithering_mode; +}; + +struct _CtkDitheringControlsClass +{ + GtkVBoxClass parent_class; +}; + +GType ctk_dithering_controls_get_type (void) G_GNUC_CONST; +GtkWidget* ctk_dithering_controls_new (NvCtrlAttributeHandle *, + CtkConfig *, CtkEvent *, + GtkWidget *, + unsigned int display_device_mask); + +void ctk_dithering_controls_reset (CtkDitheringControls*); +void ctk_dithering_controls_setup (CtkDitheringControls*); +void add_dithering_controls_help (CtkDitheringControls*, GtkTextBuffer *b, + GtkTextIter *i); + +G_END_DECLS + +#endif /* __CTK_DITHERING_CONTROLS_H__ */ diff --git a/src/gtk+-2.x/ctkevent.c b/src/gtk+-2.x/ctkevent.c index babe9e1..8645dcc 100644 --- a/src/gtk+-2.x/ctkevent.c +++ b/src/gtk+-2.x/ctkevent.c @@ -235,6 +235,8 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) MAKE_SIGNAL(NV_CTRL_DYNAMIC_TWINVIEW); MAKE_SIGNAL(NV_CTRL_MULTIGPU_DISPLAY_OWNER); MAKE_SIGNAL(NV_CTRL_GPU_SCALING); + MAKE_SIGNAL(NV_CTRL_GPU_SCALING_DEFAULT_TARGET); + MAKE_SIGNAL(NV_CTRL_GPU_SCALING_DEFAULT_METHOD); MAKE_SIGNAL(NV_CTRL_FRONTEND_RESOLUTION); MAKE_SIGNAL(NV_CTRL_BACKEND_RESOLUTION); MAKE_SIGNAL(NV_CTRL_FLATPANEL_NATIVE_RESOLUTION); @@ -300,6 +302,13 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) MAKE_SIGNAL(NV_CTRL_GPU_CORES); MAKE_SIGNAL(NV_CTRL_GPU_MEMORY_BUS_WIDTH); MAKE_SIGNAL(NV_CTRL_GVI_TEST_MODE); + MAKE_SIGNAL(NV_CTRL_FLATPANEL_DITHERING); + MAKE_SIGNAL(NV_CTRL_FLATPANEL_DITHERING_MODE); + MAKE_SIGNAL(NV_CTRL_FLATPANEL_DEFAULT_DITHERING); + MAKE_SIGNAL(NV_CTRL_FLATPANEL_DEFAULT_DITHERING_MODE); + MAKE_SIGNAL(NV_CTRL_THERMAL_SENSOR_READING); + MAKE_SIGNAL(NV_CTRL_THERMAL_SENSOR_PROVIDER); + MAKE_SIGNAL(NV_CTRL_THERMAL_SENSOR_TARGET); #undef MAKE_SIGNAL @@ -310,7 +319,7 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) * knows about. */ -#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_GVI_TEST_MODE +#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_THERMAL_SENSOR_TARGET #warning "There are attributes that do not emit signals!" #endif @@ -379,10 +388,11 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) MAKE_BINARY_SIGNAL(NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU); MAKE_BINARY_SIGNAL(NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU); MAKE_BINARY_SIGNAL(NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN); + MAKE_BINARY_SIGNAL(NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU); #undef MAKE_BINARY_SIGNAL -#if NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE != NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN +#if NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE != NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU #warning "There are attributes that do not emit signals!" #endif diff --git a/src/gtk+-2.x/ctkframelock.c b/src/gtk+-2.x/ctkframelock.c index 204880e..c9e1ad9 100644 --- a/src/gtk+-2.x/ctkframelock.c +++ b/src/gtk+-2.x/ctkframelock.c @@ -1171,7 +1171,7 @@ static void list_entry_update_gpu_controls(CtkFramelock *ctk_framelock, nvListEntryPtr entry) { nvGPUDataPtr data = (nvGPUDataPtr)(entry->data); - unsigned int slaveables; + int slaveables; nvDisplayDataPtr display_data; nvListEntryPtr child; ReturnStatus ret; diff --git a/src/gtk+-2.x/ctkgauge.c b/src/gtk+-2.x/ctkgauge.c index da36cbe..12c3b59 100644 --- a/src/gtk+-2.x/ctkgauge.c +++ b/src/gtk+-2.x/ctkgauge.c @@ -241,7 +241,8 @@ void ctk_gauge_set_current(CtkGauge *ctk_gauge, gint current) g_return_if_fail(CTK_IS_GAUGE(ctk_gauge)); ctk_gauge->current = current; - ts = g_strdup_printf("%d\xc2\xb0", current); + ts = g_strdup_printf("%d\xc2\xb0" /* split for g_utf8_validate() */ "C", + current); pango_layout_set_text(ctk_gauge->pango_layout, ts, -1); g_free(ts); diff --git a/src/gtk+-2.x/ctkglx.c b/src/gtk+-2.x/ctkglx.c index 8d38188..3cf1c9b 100644 --- a/src/gtk+-2.x/ctkglx.c +++ b/src/gtk+-2.x/ctkglx.c @@ -255,7 +255,7 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle, &glx_info_str); free(glx_info_str); if ( ret != NvCtrlSuccess ) { - err_str = "Fail to query the GLX server vendor."; + err_str = "Failed to query the GLX server vendor."; goto fail; } diff --git a/src/gtk+-2.x/ctkgvi.c b/src/gtk+-2.x/ctkgvi.c index 3356749..1087009 100644..100755 --- a/src/gtk+-2.x/ctkgvi.c +++ b/src/gtk+-2.x/ctkgvi.c @@ -125,7 +125,7 @@ typedef struct { int color_space; int bpc; int link_id; - unsigned int smpte352_id; + int smpte352_id; } ChannelInfo; @@ -443,7 +443,8 @@ static void update_sdi_input_info_all(CtkGvi *ctk_gvi) gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 5, 6); - label_str = g_strdup_printf("0x%08x", channel_info.smpte352_id); + label_str = g_strdup_printf("0x%08x", + (unsigned int) channel_info.smpte352_id); label = gtk_label_new(label_str); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 5, 6); diff --git a/src/gtk+-2.x/ctkgvi.h b/src/gtk+-2.x/ctkgvi.h index cff6e2e..cff6e2e 100644..100755 --- a/src/gtk+-2.x/ctkgvi.h +++ b/src/gtk+-2.x/ctkgvi.h diff --git a/src/gtk+-2.x/ctkgvo.c b/src/gtk+-2.x/ctkgvo.c index f509b15..8969a7c 100644 --- a/src/gtk+-2.x/ctkgvo.c +++ b/src/gtk+-2.x/ctkgvo.c @@ -991,7 +991,7 @@ static void fill_output_video_format_menu(CtkGvo *ctk_gvo) gint num_valid_entries = 0; gchar *str; gchar *tmp; - + const gchar *constStr; ctk_drop_down_menu_reset(CTK_DROP_DOWN_MENU(dmenu)); @@ -1022,7 +1022,8 @@ static void fill_output_video_format_menu(CtkGvo *ctk_gvo) } if (valid == GVO_VIDEO_FORMAT_VALID) { - str = (gchar *)videoFormatNames[i].name; + constStr = videoFormatNames[i].name; + str = NULL; } else { str = g_strconcat(videoFormatNames[i].name, " -", NULL); @@ -1041,11 +1042,12 @@ static void fill_output_video_format_menu(CtkGvo *ctk_gvo) g_free(str); str = tmp; } + constStr = str; } - label = ctk_drop_down_menu_append_item(dmenu, str, + label = ctk_drop_down_menu_append_item(dmenu, constStr, videoFormatNames[i].format); - if (str != videoFormatNames[i].name) { + if (str) { g_free(str); } @@ -1123,6 +1125,7 @@ static void fill_output_data_format_menu(CtkGvo *ctk_gvo) GtkWidget *label; gboolean valid; gchar *str; + const gchar *constStr; ctk_drop_down_menu_reset(CTK_DROP_DOWN_MENU(dmenu)); @@ -1134,15 +1137,17 @@ static void fill_output_data_format_menu(CtkGvo *ctk_gvo) } if (valid) { - str = (gchar *)dataFormatNames[i].name; + constStr = dataFormatNames[i].name; + str = NULL; } else { str = g_strconcat(dataFormatNames[i].name, " - Invalid for Clone Mode", NULL); + constStr = str; } - label = ctk_drop_down_menu_append_item(dmenu, str, + label = ctk_drop_down_menu_append_item(dmenu, constStr, dataFormatNames[i].format); - if (str != dataFormatNames[i].name) { + if (str) { g_free(str); } @@ -1460,6 +1465,10 @@ static void output_data_format_ui_changed(CtkDropDownMenu *menu, update_gvo_sensitivity(ctk_gvo); + /* Made GVO banner to update current output data format */ + CTK_GVO_BANNER(ctk_gvo->banner)->output_data_format = + ctk_gvo->output_data_format; + post_output_data_format_changed(ctk_gvo); } /* output_data_format_ui_changed() */ diff --git a/src/gtk+-2.x/ctkscreen.c b/src/gtk+-2.x/ctkscreen.c index 190fb2a..8cb5490 100644 --- a/src/gtk+-2.x/ctkscreen.c +++ b/src/gtk+-2.x/ctkscreen.c @@ -39,6 +39,21 @@ #include "ctkutils.h" #include "ctkbanner.h" +static const _CtkStereoMode stereoMode[] = { + { NV_CTRL_STEREO_OFF, "Stereo Disabled" }, + { NV_CTRL_STEREO_DDC, "DDC Stereo" }, + { NV_CTRL_STEREO_BLUELINE, "Blueline Stereo" }, + { NV_CTRL_STEREO_DIN, "Onboard DIN Stereo" }, + { NV_CTRL_STEREO_TWINVIEW, "TwinView clone Stereo" }, + { NV_CTRL_STEREO_VERTICAL_INTERLACED, "Vertical Interlaced Stereo" }, + { NV_CTRL_STEREO_COLOR_INTERLACED, "Color Interleaved Stereo" }, + { NV_CTRL_STEREO_HORIZONTAL_INTERLACED, "Horizontal Interlaced Stereo" }, + { NV_CTRL_STEREO_CHECKERBOARD_PATTERN, "Checkerboard Pattern Stereo" }, + { NV_CTRL_STEREO_INVERSE_CHECKERBOARD_PATTERN, "Inverse Checkerboard Stereo" }, + { NV_CTRL_STEREO_3D_VISION, "NVIDIA 3D Vision Stereo" }, + { -1, NULL}, +}; + void ctk_screen_event_handler(GtkWidget *widget, XRRScreenChangeNotifyEvent *ev, gpointer data); @@ -49,6 +64,17 @@ static void associated_displays_received(GtkObject *object, gpointer arg1, static void info_update_gpu_error(GtkObject *object, gpointer arg1, gpointer user_data); +static const char *get_stereo_mode_string(int stereo_mode) +{ + int i; + for (i = 0; stereoMode[i].name; i++) { + if (stereoMode[i].stereo_mode == stereo_mode) { + return stereoMode[i].name; + } + } + return "Unknown"; +} + GType ctk_screen_get_type( void ) @@ -192,7 +218,7 @@ GtkWidget* ctk_screen_new(NvCtrlAttributeHandle *handle, gchar *gpus; gchar *displays; gint gpu_errors; - + gint stereo_mode; char tmp[16]; @@ -299,6 +325,13 @@ GtkWidget* ctk_screen_new(NvCtrlAttributeHandle *handle, snprintf(tmp, 16, "%d", gpu_errors); + /* get the stereo mode set for this X screen */ + ret = NvCtrlGetDisplayAttribute(handle, 0, NV_CTRL_STEREO, + (int *)&stereo_mode); + if (ret != NvCtrlSuccess) { + stereo_mode = -1; + } + /* now, create the object */ object = g_object_new(CTK_TYPE_SCREEN, NULL); @@ -360,6 +393,8 @@ GtkWidget* ctk_screen_new(NvCtrlAttributeHandle *handle, /* gpu errors */ ctk_screen->gpu_errors = add_table_row(table, 19, 0, 0, "Recovered GPU Errors:", 0, 0, tmp); + add_table_row(table, 20, 0, 0, "Stereo Mode:", 0, 0, + get_stereo_mode_string(stereo_mode)); g_free(screen_number); free(display_name); @@ -446,6 +481,9 @@ GtkTextBuffer *ctk_screen_create_help(GtkTextTagTable *table, "GPU received and the NVIDIA X driver successfully recovered " "from."); + ctk_help_heading(b, &i, "Stereo Mode"); + ctk_help_para(b, &i, "This is the stereo mode set for the X screen."); + ctk_help_finish(b); return b; diff --git a/src/gtk+-2.x/ctkscreen.h b/src/gtk+-2.x/ctkscreen.h index f021346..e5b4a71 100644 --- a/src/gtk+-2.x/ctkscreen.h +++ b/src/gtk+-2.x/ctkscreen.h @@ -69,6 +69,11 @@ struct _CtkScreenClass GtkVBoxClass parent_class; }; +typedef struct { + int stereo_mode; + const char *name; +} _CtkStereoMode; + GType ctk_screen_get_type (void) G_GNUC_CONST; GtkWidget* ctk_screen_new (NvCtrlAttributeHandle *handle, CtkEvent *ctk_event); diff --git a/src/gtk+-2.x/ctkthermal.c b/src/gtk+-2.x/ctkthermal.c index fd4c4bd..e2b3e92 100644 --- a/src/gtk+-2.x/ctkthermal.c +++ b/src/gtk+-2.x/ctkthermal.c @@ -52,6 +52,13 @@ static void reset_button_clicked(GtkWidget *widget, gpointer user_data); static void adjustment_value_changed(GtkAdjustment *adjustment, gpointer user_data); +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, + CtkConfig *ctk_config, const char *help); static const char *__core_threshold_help = "The Core Slowdown Threshold Temperature is the temperature " @@ -74,6 +81,18 @@ static const char *__temp_level_help = "temperature relative to the maximum GPU Core Slowdown " "Threshold temperature."; +static const char *__thermal_sensor_id_help = +"This shows the thermal sensor's index."; + +static const char *__thermal_sensor_target_help = +"This shows what hardware component the thermal sensor is measuring."; + +static const char *__thermal_sensor_provider_help = +"This shows the hardware device that provides the thermal sensor."; + +static const char *__thermal_sensor_reading_help = +"This shows the thermal sensor's current reading."; + static const char * __enable_button_help = "The Enable GPU Fan Settings checkbox enables access to control GPU Fan " "Speed. This option is available after enabling coolbits for GPU Fan control." @@ -292,37 +311,66 @@ static gboolean update_cooler_info(gpointer user_data) static gboolean update_thermal_info(gpointer user_data) { - gint core, ambient; + gint reading, ambient; CtkThermal *ctk_thermal; NvCtrlAttributeHandle *handle; - gint ret; + gint ret, i, core; gchar *s; ctk_thermal = CTK_THERMAL(user_data); - handle = ctk_thermal->attribute_handle; - ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CORE_TEMPERATURE, &core); - if (ret != NvCtrlSuccess) { - /* thermal information no longer available */ - return FALSE; - } + if (!ctk_thermal->thermal_sensor_target_type_supported) { + handle = ctk_thermal->attribute_handle; - s = g_strdup_printf(" %d C ", core); - gtk_label_set_text(GTK_LABEL(ctk_thermal->core_label), s); - g_free(s); - - ctk_gauge_set_current(CTK_GAUGE(ctk_thermal->core_gauge), core); - ctk_gauge_draw(CTK_GAUGE(ctk_thermal->core_gauge)); - - if (ctk_thermal->ambient_label) { - ret = NvCtrlGetAttribute(handle, NV_CTRL_AMBIENT_TEMPERATURE, &ambient); + ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CORE_TEMPERATURE, &core); if (ret != NvCtrlSuccess) { /* thermal information no longer available */ return FALSE; } - s = g_strdup_printf(" %d C ", ambient); - gtk_label_set_text(GTK_LABEL(ctk_thermal->ambient_label), s); + + s = g_strdup_printf(" %d C ", core); + gtk_label_set_text(GTK_LABEL(ctk_thermal->core_label), s); g_free(s); + + ctk_gauge_set_current(CTK_GAUGE(ctk_thermal->core_gauge), core); + ctk_gauge_draw(CTK_GAUGE(ctk_thermal->core_gauge)); + + if (ctk_thermal->ambient_label) { + ret = NvCtrlGetAttribute(handle, NV_CTRL_AMBIENT_TEMPERATURE, + &ambient); + if (ret != NvCtrlSuccess) { + /* thermal information no longer available */ + return FALSE; + } + s = g_strdup_printf(" %d C ", ambient); + gtk_label_set_text(GTK_LABEL(ctk_thermal->ambient_label), s); + g_free(s); + } + } else { + for (i = 0; i < ctk_thermal->sensor_count; i++) { + handle = ctk_thermal->sensor_info[i].handle; + + ret = NvCtrlGetAttribute(handle, NV_CTRL_THERMAL_SENSOR_READING, + &reading); + /* querying THERMAL_SENSOR_READING failed: assume the temperature is 0 */ + if (ret != NvCtrlSuccess) { + reading = 0; + } + + if (ctk_thermal->sensor_info[i].temp_label) { + s = g_strdup_printf(" %d C ", reading); + gtk_label_set_text( + GTK_LABEL(ctk_thermal->sensor_info[i].temp_label), s); + g_free(s); + } + + if (ctk_thermal->sensor_info[i].core_gauge) { + ctk_gauge_set_current( + CTK_GAUGE(ctk_thermal->sensor_info[i].core_gauge), + reading); + ctk_gauge_draw(CTK_GAUGE(ctk_thermal->sensor_info[i].core_gauge)); + } + } } if ( ctk_thermal->cooler_count ) { update_cooler_info(ctk_thermal); @@ -814,6 +862,193 @@ static void cooler_control_checkbox_toggled(GtkWidget *widget, } /* cooler_control_checkbox_toggled() */ +static const nvctrlFormatName targetFormatNames[] = { + + { NV_CTRL_THERMAL_SENSOR_TARGET_NONE, "None" }, + { NV_CTRL_THERMAL_SENSOR_TARGET_GPU, "GPU" }, + { NV_CTRL_THERMAL_SENSOR_TARGET_MEMORY, "MEMORY" }, + { NV_CTRL_THERMAL_SENSOR_TARGET_POWER_SUPPLY, "Power Supply" }, + { NV_CTRL_THERMAL_SENSOR_TARGET_BOARD, "BOARD" }, + { -1, NULL }, +}; + +static const nvctrlFormatName providerFormatNames[] = { + { NV_CTRL_THERMAL_SENSOR_PROVIDER_NONE, "None" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_GPU_INTERNAL, "GPU Internal" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_ADM1032, "ADM1032" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_ADT7461, "ADT7461" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_MAX6649, "MAX6649" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_MAX1617, "MAX1617" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_LM99, "LM99" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_LM89, "LM89" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_LM64, "LM64" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_G781, "G781" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_ADT7473, "ADT7473" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_SBMAX6649, "SBMAX6649" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_VBIOSEVT, "VBIOSEVT" }, + { NV_CTRL_THERMAL_SENSOR_PROVIDER_OS, "OS" }, + { -1, NULL }, +}; + + +/* + * get_nvctrl_format_name() - return the name of the nvcontrol format + */ +static const char *get_nvctrl_format_name(const nvctrlFormatName *nvctrlFormatNames, + const gint format) +{ + gint i; + + for (i = 0; nvctrlFormatNames[i].name; i++) { + if (nvctrlFormatNames[i].format == format) { + return nvctrlFormatNames[i].name; + } + } + + return "Unknown"; + +} /* get_nvctrl_format_name() */ + + +/* + * pack_gauge() - pack gauge gui in hbox + */ +static GtkWidget *pack_gauge(GtkWidget *hbox, gint lower, gint upper, + CtkConfig *ctk_config, const char *help) +{ + GtkWidget *vbox, *frame, *eventbox, *gauge; + + /* GPU Core Temperature Gauge */ + + vbox = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); + + frame = gtk_frame_new("Temperature"); + gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(hbox), FRAME_PADDING); + gtk_container_add(GTK_CONTAINER(frame), hbox); + + gauge = ctk_gauge_new(lower, upper); + eventbox = gtk_event_box_new(); + gtk_container_add(GTK_CONTAINER(eventbox), gauge); + gtk_box_pack_start(GTK_BOX(hbox), eventbox, FALSE, FALSE, 0); + ctk_config_set_tooltip(ctk_config, eventbox, help); + + return gauge; +} /* pack_gauge() */ + + +/***** + * + * draw_sensor_gui() - prints sensor related information + * + */ +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) +{ + GtkWidget *hbox, *hbox1, *hbox2, *vbox, *vbox2, *table; + GtkWidget *frame, *label, *hsep; + GtkWidget *eventbox = NULL; + gchar *s; + + hbox = gtk_hbox_new(FALSE, FRAME_PADDING); + gtk_container_set_border_width(GTK_CONTAINER(hbox), 10); + + hbox1 = gtk_hbox_new(FALSE, FRAME_PADDING); + gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, FALSE, 0); + + vbox2 = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox1), vbox2, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); + + vbox = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); + + /* GPU sensor ID */ + + hbox2 = gtk_hbox_new(FALSE, 0); + s = g_strdup_printf("ID: %d", cur_sensor_idx); + label = gtk_label_new(s); + g_free(s); + gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); + + table = gtk_table_new(4, 4, FALSE); + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); + + gtk_table_set_row_spacings(GTK_TABLE(table), 3); + gtk_table_set_col_spacings(GTK_TABLE(table), 15); + + gtk_container_set_border_width(GTK_CONTAINER(table), 5); + + /* sensor target type */ + if (target) { + add_table_row_with_help_text(table, ctk_thermal->ctk_config, + __thermal_sensor_target_help, + 0, 0, 0, 0.5, + "Target:", 0, 0.5, + get_nvctrl_format_name(targetFormatNames, target)); + ctk_thermal->sensor_info[cur_sensor_idx].target_type = label; + } else { + ctk_thermal->sensor_info[cur_sensor_idx].target_type = NULL; + } + + /* sensor provider type */ + if (provider) { + add_table_row_with_help_text(table, ctk_thermal->ctk_config, + __thermal_sensor_provider_help, + 1, 0, 0, 0.5, + "Provider:", 0, 0.5, + get_nvctrl_format_name(providerFormatNames, provider)); + ctk_thermal->sensor_info[cur_sensor_idx].provider_type = label; + } else { + ctk_thermal->sensor_info[cur_sensor_idx].provider_type = NULL; + } + + /* thermal sensor reading */ + if (reading) { + hbox2 = gtk_hbox_new(FALSE, 0); + gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 3, 4, + GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0); + + label = gtk_label_new("Temperature:"); + gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); + + frame = gtk_frame_new(NULL); + eventbox = gtk_event_box_new(); + gtk_container_add(GTK_CONTAINER(eventbox), frame); + gtk_table_attach(GTK_TABLE(table), eventbox, 1, 2, 3, 4, + GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0); + + label = gtk_label_new(NULL); + gtk_container_add(GTK_CONTAINER(frame), label); + ctk_thermal->sensor_info[cur_sensor_idx].temp_label = label; + ctk_config_set_tooltip(ctk_thermal->ctk_config, eventbox, + __thermal_sensor_reading_help); + } else { + ctk_thermal->sensor_info[cur_sensor_idx].temp_label = NULL; + } + + /* GPU Core Temperature Gauge */ + ctk_thermal->sensor_info[cur_sensor_idx].core_gauge = + pack_gauge(hbox, lower, upper, + ctk_thermal->ctk_config, __temp_level_help); + + /* add horizontal bar between sensors */ + if (cur_sensor_idx+1 != ctk_thermal->sensor_count) { + hbox1 = gtk_hbox_new(FALSE, 0); + hsep = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(vbox2), hbox1, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox1), hsep, TRUE, TRUE, 10); + } + +} /* draw_sensor_gui() */ + GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle, @@ -824,20 +1059,22 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle, CtkThermal *ctk_thermal; CtrlHandles *h; GtkObject *adjustment; - GtkWidget *gauge; - GtkWidget *hbox, *hbox2, *vbox, *table; + GtkWidget *hbox = NULL, *hbox1, *hbox2, *table, *vbox; GtkWidget *frame, *banner, *label; GtkWidget *vbox1; - GtkWidget *eventbox, *entry; + GtkWidget *eventbox = NULL, *entry; GtkWidget *fan_control_frame; GtkWidget *hsep; GtkWidget *scale; GtkWidget *alignment; ReturnStatus ret; + ReturnStatus ret1; NvCtrlAttributeHandle *cooler_handle; + NvCtrlAttributeHandle *sensor_handle; NVCTRLAttributeValidValuesRec cooler_range; - gint trigger, ambient; - gint core, upper; + NVCTRLAttributeValidValuesRec sensor_range; + gint trigger, core, ambient; + gint upper; gchar *s; gint i, j; gint cooler_level; @@ -845,31 +1082,61 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle, gchar *name = NULL; int *pData; int len, value; + int major = 0, minor = 0; Bool can_access_cooler_level; Bool cooler_control_enabled; int cur_cooler_idx = 0; + int cur_sensor_idx = 0; + Bool thermal_sensor_target_type_supported = FALSE; /* make sure we have a handle */ g_return_val_if_fail(handle != NULL, NULL); - - /* check if this screen supports thermal querying */ - ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CORE_TEMPERATURE, &core); - if (ret != NvCtrlSuccess) { - /* thermal information unavailable */ - return NULL; + /* + * Check for NV-CONTROL protocol version. + * In version 1.23 we added support for querying per sensor information + * This used for backward compatibility between new nvidia-settings + * and older X driver + */ + ret = NvCtrlGetAttribute(handle, + NV_CTRL_ATTR_NV_MAJOR_VERSION, &major); + ret1 = NvCtrlGetAttribute(handle, + NV_CTRL_ATTR_NV_MINOR_VERSION, &minor); + + if ((ret == NvCtrlSuccess) && (ret1 == NvCtrlSuccess) && + ((major > 1) || ((major == 1) && (minor > 22)))) { + thermal_sensor_target_type_supported = TRUE; } - ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_MAX_CORE_THRESHOLD, &upper); - if (ret != NvCtrlSuccess) { - /* thermal information unavailable */ - return NULL; + if (!thermal_sensor_target_type_supported) { + /* check if this screen supports thermal querying */ + + ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CORE_TEMPERATURE, &core); + if (ret != NvCtrlSuccess) { + /* thermal information unavailable */ + return NULL; + } + + ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_MAX_CORE_THRESHOLD, &upper); + if (ret != NvCtrlSuccess) { + /* thermal information unavailable */ + return NULL; + } + + ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CORE_THRESHOLD, &trigger); + if (ret != NvCtrlSuccess) { + /* thermal information unavailable */ + return NULL; + } } + /* Retrieve CtrlHandles from ctk_config */ - ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_CORE_THRESHOLD, &trigger); - if (ret != NvCtrlSuccess) { - /* thermal information unavailable */ + h = ctk_config->pCtrlHandles; + + /* return if sensor and Fan information not available */ + if ((h->targets[THERMAL_SENSOR_TARGET].n == 0) && + (h->targets[COOLER_TARGET].n == 0)) { return NULL; } @@ -883,6 +1150,7 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle, ctk_thermal->settings_changed = FALSE; ctk_thermal->show_fan_control_frame = TRUE; ctk_thermal->cooler_count = 0; + ctk_thermal->thermal_sensor_target_type_supported = thermal_sensor_target_type_supported; /* set container properties for the CtkThermal widget */ @@ -914,118 +1182,174 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle, /* Thermal Information */ - hbox = gtk_hbox_new(FALSE, FRAME_PADDING); - gtk_box_pack_start(GTK_BOX(object), hbox, FALSE, FALSE, FRAME_PADDING); - vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); - - - /* GPU Core Treshold Temperature */ + gtk_box_pack_start(GTK_BOX(object), vbox, FALSE, FALSE, 0); + + if (thermal_sensor_target_type_supported) { + if ( h->targets[THERMAL_SENSOR_TARGET].n == 0 ) { + goto sensor_end; + } + hbox1 = gtk_hbox_new(FALSE, FRAME_PADDING); + gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 0); + label = gtk_label_new("Thermal Sensor Information"); + gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0); - frame = gtk_frame_new("Slowdown Threshold"); - gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); + hsep = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(hbox1), hsep, TRUE, TRUE, 0); + + /* Query the list of sensors attached to this GPU */ + + ret = NvCtrlGetBinaryAttribute(handle, 0, + NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU, + (unsigned char **)(&pData), &len); + if ( ret == NvCtrlSuccess ) { + ctk_thermal->sensor_count = pData[0]; + } else { + ctk_thermal->sensor_count = 0; + } - hbox2 = gtk_hbox_new(FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(hbox2), FRAME_PADDING); - gtk_container_add(GTK_CONTAINER(frame), hbox2); + if (ctk_thermal->sensor_count > 0) { + ctk_thermal->sensor_info = (SensorInfoPtr) + malloc(pData[0] * sizeof(SensorInfoRec)); + } - label = gtk_label_new("Degrees: "); - gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); + for (j = 1; j <= ctk_thermal->sensor_count; j++) { + gint reading, target, provider; + sensor_handle = h->targets[THERMAL_SENSOR_TARGET].t[pData[j]].h; - eventbox = gtk_event_box_new(); - gtk_box_pack_start(GTK_BOX(hbox2), eventbox, FALSE, FALSE, 0); + if ( !sensor_handle ) { + continue; + } - entry = gtk_entry_new_with_max_length(5); - gtk_container_add(GTK_CONTAINER(eventbox), entry); - gtk_widget_set_sensitive(entry, FALSE); - gtk_entry_set_width_chars(GTK_ENTRY(entry), 5); + ctk_thermal->sensor_info[cur_sensor_idx].handle = sensor_handle; - s = g_strdup_printf(" %d ", trigger); - gtk_entry_set_text(GTK_ENTRY(entry), s); - g_free(s); + /* check if this screen supports thermal querying */ - ctk_config_set_tooltip(ctk_config, eventbox, __core_threshold_help); + ret = NvCtrlGetAttribute(sensor_handle, NV_CTRL_THERMAL_SENSOR_READING, + &reading); + if (ret != NvCtrlSuccess) { + /* sensor information unavailable */ + reading = 0; + } - label = gtk_label_new(" C"); - gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); + ret = NvCtrlGetValidAttributeValues(sensor_handle, + 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, + &target); + if (ret != NvCtrlSuccess) { + /* sensor information unavailable */ + target = 0; + } - /* GPU Core Temperature */ + ret = NvCtrlGetAttribute(sensor_handle, NV_CTRL_THERMAL_SENSOR_PROVIDER, + &provider); + if (ret != NvCtrlSuccess) { + /* sensor information unavailable */ + provider = 0; + } + /* print sensor related information */ + draw_sensor_gui(vbox, ctk_thermal, thermal_sensor_target_type_supported, + cur_sensor_idx, sensor_handle, + reading, sensor_range.u.range.min, + sensor_range.u.range.max, target, provider); + cur_sensor_idx++; + } + XFree(pData); + pData = NULL; + } else { + /* GPU Core Treshold Temperature */ - table = gtk_table_new(2, 2, FALSE); - gtk_box_pack_end(GTK_BOX(vbox), table, FALSE, FALSE, 0); + frame = gtk_frame_new("Slowdown Threshold"); + gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); - hbox2 = gtk_hbox_new(FALSE, 0); - gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 0, 1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + hbox2 = gtk_hbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(hbox2), FRAME_PADDING); + gtk_container_add(GTK_CONTAINER(frame), hbox2); - label = gtk_label_new("Core Temperature:"); - gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); + label = gtk_label_new("Degrees: "); + gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); - frame = gtk_frame_new(NULL); - eventbox = gtk_event_box_new(); - gtk_container_add(GTK_CONTAINER(eventbox), frame); - gtk_table_attach(GTK_TABLE(table), eventbox, 1, 2, 0, 1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0); + eventbox = gtk_event_box_new(); + gtk_box_pack_start(GTK_BOX(hbox2), eventbox, FALSE, FALSE, 0); - label = gtk_label_new(NULL); - gtk_container_add(GTK_CONTAINER(frame), label); - ctk_thermal->core_label = label; + entry = gtk_entry_new_with_max_length(5); + gtk_container_add(GTK_CONTAINER(eventbox), entry); + gtk_widget_set_sensitive(entry, FALSE); + gtk_entry_set_width_chars(GTK_ENTRY(entry), 5); - ctk_config_set_tooltip(ctk_config, eventbox, __core_temp_help); + s = g_strdup_printf(" %d ", trigger); + gtk_entry_set_text(GTK_ENTRY(entry), s); + g_free(s); + ctk_config_set_tooltip(ctk_config, eventbox, __core_threshold_help); + label = gtk_label_new(" C"); + gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); - /* Ambient Temperature */ + /* GPU Core Temperature */ - ret = NvCtrlGetAttribute(handle, NV_CTRL_AMBIENT_TEMPERATURE, &ambient); + table = gtk_table_new(2, 2, FALSE); + gtk_box_pack_end(GTK_BOX(vbox), table, FALSE, FALSE, 0); - if (ret == NvCtrlSuccess) { hbox2 = gtk_hbox_new(FALSE, 0); - gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 1, 2, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - - label = gtk_label_new("Ambient Temperature:"); + gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + + label = gtk_label_new("Core Temperature:"); gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); - + frame = gtk_frame_new(NULL); eventbox = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(eventbox), frame); - gtk_table_attach(GTK_TABLE(table), eventbox, 1, 2, 1, 2, - GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0); - + gtk_table_attach(GTK_TABLE(table), eventbox, 1, 2, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0); + label = gtk_label_new(NULL); gtk_container_add(GTK_CONTAINER(frame), label); - ctk_thermal->ambient_label = label; - - ctk_config_set_tooltip(ctk_config, eventbox, __ambient_temp_help); - } else { - ctk_thermal->ambient_label = NULL; - } + ctk_thermal->core_label = label; - /* GPU Core Temperature Gauge */ + ctk_config_set_tooltip(ctk_config, eventbox, __core_temp_help); - vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); + /* Ambient Temperature */ - frame = gtk_frame_new("Level"); - gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); + ret = NvCtrlGetAttribute(handle, NV_CTRL_AMBIENT_TEMPERATURE, &ambient); - hbox = gtk_hbox_new(FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(hbox), FRAME_PADDING); - gtk_container_add(GTK_CONTAINER(frame), hbox); + if (ret == NvCtrlSuccess) { + hbox2 = gtk_hbox_new(FALSE, 0); + gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 1, 2, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - gauge = ctk_gauge_new(25, upper); - eventbox = gtk_event_box_new(); - gtk_container_add(GTK_CONTAINER(eventbox), gauge); - gtk_box_pack_start(GTK_BOX(hbox), eventbox, FALSE, FALSE, 0); - ctk_thermal->core_gauge = gauge; + label = gtk_label_new("Ambient Temperature:"); + gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); - ctk_config_set_tooltip(ctk_config, eventbox, __temp_level_help); + frame = gtk_frame_new(NULL); + eventbox = gtk_event_box_new(); + gtk_container_add(GTK_CONTAINER(eventbox), frame); + gtk_table_attach(GTK_TABLE(table), eventbox, 1, 2, 1, 2, + GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0); - /* Retrieve CtrlHandles from ctk_config */ + label = gtk_label_new(NULL); + gtk_container_add(GTK_CONTAINER(frame), label); + ctk_thermal->ambient_label = label; - h = ctk_config->pCtrlHandles; + ctk_config_set_tooltip(ctk_config, eventbox, __ambient_temp_help); + } else { + ctk_thermal->ambient_label = NULL; + } + + /* GPU Core Temperature Gauge */ + + ctk_thermal->core_gauge = pack_gauge(hbox, 25, upper, + ctk_config, __temp_level_help); + } +sensor_end: + + /* Check for if Fans present on GPU */ if ( h->targets[COOLER_TARGET].n == 0 ) { goto end; @@ -1285,17 +1609,46 @@ GtkTextBuffer *ctk_thermal_create_help(GtkTextTagTable *table, gtk_text_buffer_get_iter_at_offset(b, &i, 0); - ctk_help_title(b, &i, "Thermal Monitor Help"); - - ctk_help_heading(b, &i, "Slowdown Threshold"); - ctk_help_para(b, &i, __core_threshold_help); + ctk_help_title(b, &i, "Thermal Settings Help"); + + /* if sensor not available skip online help */ + if (!ctk_thermal->sensor_count) { + goto next_help; + } + + if (!ctk_thermal->thermal_sensor_target_type_supported) { + ctk_help_heading(b, &i, "Slowdown Threshold"); + ctk_help_para(b, &i, __core_threshold_help); + + ctk_help_heading(b, &i, "Core Temperature"); + ctk_help_para(b, &i, __core_temp_help); + + if (ctk_thermal->ambient_label) { + ctk_help_heading(b, &i, "Ambient Temperature"); + ctk_help_para(b, &i, __ambient_temp_help); + } + } else { + ctk_help_title(b, &i, "Thermal Sensor Information Help"); + + ctk_help_heading(b, &i, "ID"); + ctk_help_para(b, &i, __thermal_sensor_id_help); - ctk_help_heading(b, &i, "Core Temperature"); - ctk_help_para(b, &i, __core_temp_help); + ctk_help_heading(b, &i, "Temperature"); + ctk_help_para(b, &i, __thermal_sensor_reading_help); + + ctk_help_heading(b, &i, "Target"); + ctk_help_para(b, &i, __thermal_sensor_target_help); + + ctk_help_heading(b, &i, "Provider"); + ctk_help_para(b, &i, __thermal_sensor_provider_help); + } + ctk_help_heading(b, &i, "Level"); + ctk_help_para(b, &i, __temp_level_help); - if (ctk_thermal->ambient_label) { - ctk_help_heading(b, &i, "Ambient Temperature"); - ctk_help_para(b, &i, __ambient_temp_help); +next_help: + /* if Fan not available skip online help */ + if (!ctk_thermal->cooler_count) { + goto done; } ctk_help_title(b, &i, "GPU Fan Settings Help"); @@ -1322,6 +1675,7 @@ GtkTextBuffer *ctk_thermal_create_help(GtkTextTagTable *table, ctk_help_heading(b, &i, "Enable GPU Fan Settings"); ctk_help_para(b, &i, __reset_button_help); } +done: ctk_help_finish(b); return b; diff --git a/src/gtk+-2.x/ctkthermal.h b/src/gtk+-2.x/ctkthermal.h index 37a27f8..2bf2f4b 100644 --- a/src/gtk+-2.x/ctkthermal.h +++ b/src/gtk+-2.x/ctkthermal.h @@ -63,6 +63,23 @@ typedef struct _CoolerControl { CtkEvent *event; /* Receive NV_CONTROL events */ } CoolerControlRec, *CoolerControlPtr; +typedef struct { + int format; + const char *name; +} nvctrlFormatName; + +typedef struct _SensorInfo { + NvCtrlAttributeHandle *handle; + int currentTemp; + int minTemp; + int maxTemp; + + GtkWidget *target_type; + GtkWidget *provider_type; + GtkWidget *temp_label; + GtkWidget *core_gauge; +} SensorInfoRec, *SensorInfoPtr; + struct _CtkThermal { GtkVBox parent; @@ -91,7 +108,10 @@ struct _CtkThermal gboolean show_fan_control_frame; gboolean enable_reset_button; CoolerControlPtr cooler_control; + SensorInfoPtr sensor_info; int cooler_count; + int sensor_count; + gboolean thermal_sensor_target_type_supported; }; struct _CtkThermalClass diff --git a/src/gtk+-2.x/ctkutils.c b/src/gtk+-2.x/ctkutils.c index 09665f4..0c6b6b3 100644 --- a/src/gtk+-2.x/ctkutils.c +++ b/src/gtk+-2.x/ctkutils.c @@ -29,6 +29,30 @@ +/* + * Used to check if current display enabled or disabled. + */ +void update_display_enabled_flag(NvCtrlAttributeHandle *handle, + gboolean *display_enabled, + unsigned int display_device_mask) +{ + ReturnStatus ret; + unsigned int enabled_displays; + + /* Is display enabled? */ + + ret = NvCtrlGetAttribute(handle, + NV_CTRL_ENABLED_DISPLAYS, + (int *)&enabled_displays); + + *display_enabled = + (ret == NvCtrlSuccess && + (enabled_displays & (display_device_mask))); + +} /* update_display_enabled_flag() */ + + + gchar* create_gpu_name_string(NvCtrlAttributeHandle *gpu_handle) { gchar *gpu_name; @@ -52,21 +76,26 @@ gchar* create_gpu_name_string(NvCtrlAttributeHandle *gpu_handle) } -GtkWidget *add_table_row(GtkWidget *table, - const gint row, - const gfloat name_xalign, // 0 = left, 1 = right - const gfloat name_yalign, // 0 = top, 1 = bottom - const gchar *name, - const gfloat value_xalign, - const gfloat value_yalign, - const gchar *value) +GtkWidget *add_table_row_with_help_text(GtkWidget *table, + CtkConfig *ctk_config, + const char *help, + const gint row, + const gint col, + // 0 = left, 1 = right + const gfloat name_xalign, + // 0 = top, 1 = bottom + const gfloat name_yalign, + const gchar *name, + const gfloat value_xalign, + const gfloat value_yalign, + const gchar *value) { - GtkWidget *label; + GtkWidget *label, *eventbox; label = gtk_label_new(name); gtk_label_set_selectable(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), name_xalign, name_yalign); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, + gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row + 1, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); if (value == NULL) @@ -74,14 +103,42 @@ GtkWidget *add_table_row(GtkWidget *table, else label = gtk_label_new(value); gtk_label_set_selectable(GTK_LABEL(label), TRUE); + eventbox = gtk_event_box_new(); gtk_misc_set_alignment(GTK_MISC(label), value_xalign, value_yalign); - gtk_table_attach(GTK_TABLE(table), label, 1, 2, row, row + 1, + gtk_container_add(GTK_CONTAINER(eventbox), label); + gtk_table_attach(GTK_TABLE(table), eventbox, col+1, col+2, row, row + 1, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + if ((help != NULL) || (ctk_config != NULL)) { + ctk_config_set_tooltip(ctk_config, eventbox, help); + } return label; } +GtkWidget *add_table_row(GtkWidget *table, + const gint row, + const gfloat name_xalign, // 0 = left, 1 = right + const gfloat name_yalign, // 0 = top, 1 = bottom + const gchar *name, + const gfloat value_xalign, + const gfloat value_yalign, + const gchar *value) +{ + return add_table_row_with_help_text(table, + NULL, /* ctk_config */ + NULL, /* help */ + row, + 0, /* col */ + name_xalign, + name_yalign, + name, + value_xalign, + value_yalign, + value); +} + + /** ctk_get_parent_window() ****************************************** * diff --git a/src/gtk+-2.x/ctkutils.h b/src/gtk+-2.x/ctkutils.h index e052abe..52ea46f 100644 --- a/src/gtk+-2.x/ctkutils.h +++ b/src/gtk+-2.x/ctkutils.h @@ -28,10 +28,27 @@ #include <gtk/gtk.h> #include <NvCtrlAttributes.h> +#include "ctkconfig.h" + G_BEGIN_DECLS gchar* create_gpu_name_string(NvCtrlAttributeHandle *gpu_handle); + +GtkWidget *add_table_row_with_help_text(GtkWidget *table, + CtkConfig *ctk_config, + const char *help, + const gint row, + const gint col, + // 0 = left, 1 = right + const gfloat name_xalign, + // 0 = top, 1 = bottom + const gfloat name_yalign, + const gchar *name, + const gfloat value_xalign, + const gfloat value_yalign, + const gchar *value); + GtkWidget *add_table_row(GtkWidget *, const gint, const gfloat, const gfloat, const gchar *, const gfloat, const gfloat, const gchar *); @@ -44,6 +61,10 @@ void ctk_display_warning_msg(GtkWidget *parent, gchar *msg); void ctk_empty_container(GtkWidget *); +void update_display_enabled_flag(NvCtrlAttributeHandle *handle, + gboolean *display_enabled, + unsigned int display_device_mask); + G_END_DECLS #endif /* __CTK_UTILS_H__ */ diff --git a/src/gtk+-2.x/src.mk b/src/gtk+-2.x/src.mk new file mode 100644 index 0000000..7461b94 --- /dev/null +++ b/src/gtk+-2.x/src.mk @@ -0,0 +1,95 @@ +# +# files in the src/gtk+-2.x directory of nvidia-settings +# + +GTK_SRC += ctkxvideo.c +GTK_SRC += ctkcursorshadow.c +GTK_SRC += ctkui.c +GTK_SRC += ctkframelock.c +GTK_SRC += ctkgauge.c +GTK_SRC += ctkcurve.c +GTK_SRC += ctkcolorcorrection.c +GTK_SRC += ctkscale.c +GTK_SRC += ctkmultisample.c +GTK_SRC += ctkconfig.c +GTK_SRC += ctkevent.c +GTK_SRC += ctkwindow.c +GTK_SRC += ctkopengl.c +GTK_SRC += ctkglx.c +GTK_SRC += ctkhelp.c +GTK_SRC += ctkimagesliders.c +GTK_SRC += ctkdisplaydevice-crt.c +GTK_SRC += ctkdisplaydevice-tv.c +GTK_SRC += ctkdisplaydevice-dfp.c +GTK_SRC += ctkditheringcontrols.c +GTK_SRC += ctkthermal.c +GTK_SRC += ctkpowermizer.c +GTK_SRC += ctkgvo.c +GTK_SRC += ctkgvo-csc.c +GTK_SRC += ctkdropdownmenu.c +GTK_SRC += ctkrandr.c +GTK_SRC += ctkclocks.c +GTK_SRC += ctkutils.c +GTK_SRC += ctkedid.c +GTK_SRC += ctkserver.c +GTK_SRC += ctkdisplaylayout.c +GTK_SRC += ctkdisplayconfig.c +GTK_SRC += ctkscreen.c +GTK_SRC += ctkslimm.c +GTK_SRC += ctkgpu.c +GTK_SRC += ctkbanner.c +GTK_SRC += ctkvcs.c +GTK_SRC += ctkdisplayconfig-utils.c +GTK_SRC += ctkgvo-banner.c +GTK_SRC += ctkgvo-sync.c +GTK_SRC += ctkpowersavings.c +GTK_SRC += ctkgvi.c +GTK_SRC += ctklicense.c +GTK_SRC += ctkecc.c + +GTK_EXTRA_DIST += ctkxvideo.h +GTK_EXTRA_DIST += ctkcursorshadow.h +GTK_EXTRA_DIST += ctkui.h +GTK_EXTRA_DIST += ctkframelock.h +GTK_EXTRA_DIST += ctkgauge.h +GTK_EXTRA_DIST += ctkcurve.h +GTK_EXTRA_DIST += ctkcolorcorrection.h +GTK_EXTRA_DIST += ctkscale.h +GTK_EXTRA_DIST += ctkmultisample.h +GTK_EXTRA_DIST += ctkconfig.h +GTK_EXTRA_DIST += ctkevent.h +GTK_EXTRA_DIST += ctkwindow.h +GTK_EXTRA_DIST += ctkopengl.h +GTK_EXTRA_DIST += ctkglx.h +GTK_EXTRA_DIST += ctkhelp.h +GTK_EXTRA_DIST += ctkimagesliders.h +GTK_EXTRA_DIST += ctkdisplaydevice-crt.h +GTK_EXTRA_DIST += ctkdisplaydevice-tv.h +GTK_EXTRA_DIST += ctkdisplaydevice-dfp.h +GTK_EXTRA_DIST += ctkditheringcontrols.h +GTK_EXTRA_DIST += ctkconstants.h +GTK_EXTRA_DIST += ctkthermal.h +GTK_EXTRA_DIST += ctkpowermizer.h +GTK_EXTRA_DIST += ctkgvo.h +GTK_EXTRA_DIST += ctkgvo-csc.h +GTK_EXTRA_DIST += ctkdropdownmenu.h +GTK_EXTRA_DIST += ctkrandr.h +GTK_EXTRA_DIST += ctkclocks.h +GTK_EXTRA_DIST += ctkutils.h +GTK_EXTRA_DIST += ctkedid.h +GTK_EXTRA_DIST += ctkserver.h +GTK_EXTRA_DIST += ctkdisplaylayout.h +GTK_EXTRA_DIST += ctkdisplayconfig.h +GTK_EXTRA_DIST += ctkscreen.h +GTK_EXTRA_DIST += ctkslimm.h +GTK_EXTRA_DIST += ctkgpu.h +GTK_EXTRA_DIST += ctkbanner.h +GTK_EXTRA_DIST += ctkvcs.h +GTK_EXTRA_DIST += ctkdisplayconfig-utils.h +GTK_EXTRA_DIST += ctkpowersavings.h +GTK_EXTRA_DIST += ctkgvo-banner.h +GTK_EXTRA_DIST += ctkgvo-sync.h +GTK_EXTRA_DIST += ctkgvi.h +GTK_EXTRA_DIST += ctklicense.h +GTK_EXTRA_DIST += ctkecc.h +GTK_EXTRA_DIST += src.mk diff --git a/src/image_data/Makefile.inc b/src/image_data/Makefile.inc deleted file mode 100644 index 32b1dc2..0000000 --- a/src/image_data/Makefile.inc +++ /dev/null @@ -1,79 +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 of Version 2 of the GNU General Public -# License 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 Version 2 -# of the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the: -# -# Free Software Foundation, Inc. -# 59 Temple Place - Suite 330 -# Boston, MA 02111-1307, USA -# - -# -# image data sources and extra files to be included in the -# distribution -# - -EXTRA_DIST += \ - antialias_pixdata.h \ - background_pixdata.h \ - background_tall_pixdata.h \ - bnc_cable_pixdata.h \ - bsd_pixdata.h \ - clock_pixdata.h \ - color_pixdata.h \ - config_pixdata.h \ - crt_pixdata.h \ - cursor_shadow_pixdata.h \ - dfp_pixdata.h \ - display_config_pixdata.h \ - framelock_pixdata.h \ - glx_pixdata.h \ - gpu_pixdata.h \ - help_pixdata.h \ - HOWTO-ADD-IMAGES \ - led_green_pixdata.h \ - led_grey_pixdata.h \ - led_red_pixdata.h \ - logo_pixdata.h \ - logo_tall_pixdata.h \ - Makefile.inc \ - nvidia_icon_pixdata.h \ - opengl_pixdata.h \ - penguin_pixdata.h \ - png_to_c_header.sh \ - gvi_pixdata.h \ - rj45_input_pixdata.h \ - rj45_output_pixdata.h \ - rj45_unused_pixdata.h \ - rotate_left_off_pixdata.h \ - rotate_left_on_pixdata.h \ - rotate_right_off_pixdata.h \ - rotate_right_on_pixdata.h \ - rotation_orientation_horz_pixdata.h \ - rotation_orientation_vert_pixdata.h \ - rotation_pixdata.h \ - sdi_pixdata.h \ - sdi_shared_sync_bnc_pixdata.h \ - slimm_pixdata.h \ - solaris_pixdata.h \ - thermal_pixdata.h \ - tv_pixdata.h \ - vcs_pixdata.h \ - x_pixdata.h \ - xvideo_pixdata.h - -dist_list:: - @ echo $(SRC) $(EXTRA_DIST) diff --git a/src/image_data/antialias.png b/src/image_data/antialias.png Binary files differnew file mode 100644 index 0000000..401976a --- /dev/null +++ b/src/image_data/antialias.png diff --git a/src/image_data/background.png b/src/image_data/background.png Binary files differnew file mode 100644 index 0000000..4f6245f --- /dev/null +++ b/src/image_data/background.png diff --git a/src/image_data/background_tall.png b/src/image_data/background_tall.png Binary files differnew file mode 100644 index 0000000..93e1030 --- /dev/null +++ b/src/image_data/background_tall.png diff --git a/src/image_data/bnc_cable.png b/src/image_data/bnc_cable.png Binary files differnew file mode 100644 index 0000000..8f7b9a2 --- /dev/null +++ b/src/image_data/bnc_cable.png diff --git a/src/image_data/bsd.png b/src/image_data/bsd.png Binary files differnew file mode 100644 index 0000000..5a01458 --- /dev/null +++ b/src/image_data/bsd.png diff --git a/src/image_data/clock.png b/src/image_data/clock.png Binary files differnew file mode 100644 index 0000000..acf5265 --- /dev/null +++ b/src/image_data/clock.png diff --git a/src/image_data/color.png b/src/image_data/color.png Binary files differnew file mode 100644 index 0000000..b956adc --- /dev/null +++ b/src/image_data/color.png diff --git a/src/image_data/config.png b/src/image_data/config.png Binary files differnew file mode 100644 index 0000000..570efd8 --- /dev/null +++ b/src/image_data/config.png diff --git a/src/image_data/crt.png b/src/image_data/crt.png Binary files differnew file mode 100644 index 0000000..6b1e559 --- /dev/null +++ b/src/image_data/crt.png diff --git a/src/image_data/cursor_shadow.png b/src/image_data/cursor_shadow.png Binary files differnew file mode 100644 index 0000000..0ddf799 --- /dev/null +++ b/src/image_data/cursor_shadow.png diff --git a/src/image_data/dfp.png b/src/image_data/dfp.png Binary files differnew file mode 100644 index 0000000..1a661a5 --- /dev/null +++ b/src/image_data/dfp.png diff --git a/src/image_data/display_config.png b/src/image_data/display_config.png Binary files differnew file mode 100644 index 0000000..6f36ea3 --- /dev/null +++ b/src/image_data/display_config.png diff --git a/src/image_data/framelock.png b/src/image_data/framelock.png Binary files differnew file mode 100644 index 0000000..842cbd6 --- /dev/null +++ b/src/image_data/framelock.png diff --git a/src/image_data/glx.png b/src/image_data/glx.png Binary files differnew file mode 100644 index 0000000..710a5ae --- /dev/null +++ b/src/image_data/glx.png diff --git a/src/image_data/gpu.png b/src/image_data/gpu.png Binary files differnew file mode 100644 index 0000000..adc3782 --- /dev/null +++ b/src/image_data/gpu.png diff --git a/src/image_data/gvi.png b/src/image_data/gvi.png Binary files differnew file mode 100644 index 0000000..d025cd5 --- /dev/null +++ b/src/image_data/gvi.png diff --git a/src/image_data/help.png b/src/image_data/help.png Binary files differnew file mode 100644 index 0000000..05002cf --- /dev/null +++ b/src/image_data/help.png diff --git a/src/image_data/led_green.png b/src/image_data/led_green.png Binary files differnew file mode 100644 index 0000000..4e1a204 --- /dev/null +++ b/src/image_data/led_green.png diff --git a/src/image_data/led_grey.png b/src/image_data/led_grey.png Binary files differnew file mode 100644 index 0000000..f140b10 --- /dev/null +++ b/src/image_data/led_grey.png diff --git a/src/image_data/led_red.png b/src/image_data/led_red.png Binary files differnew file mode 100644 index 0000000..2dec661 --- /dev/null +++ b/src/image_data/led_red.png diff --git a/src/image_data/logo.png b/src/image_data/logo.png Binary files differnew file mode 100644 index 0000000..1b073b1 --- /dev/null +++ b/src/image_data/logo.png diff --git a/src/image_data/logo_tall.png b/src/image_data/logo_tall.png Binary files differnew file mode 100644 index 0000000..b27b470 --- /dev/null +++ b/src/image_data/logo_tall.png diff --git a/src/image_data/nvidia_icon.png b/src/image_data/nvidia_icon.png Binary files differnew file mode 100755 index 0000000..7a2b508 --- /dev/null +++ b/src/image_data/nvidia_icon.png diff --git a/src/image_data/nvidia_icon_pixdata.h b/src/image_data/nvidia_icon_pixdata.h index 4555b18..4555b18 100644..100755 --- a/src/image_data/nvidia_icon_pixdata.h +++ b/src/image_data/nvidia_icon_pixdata.h diff --git a/src/image_data/opengl.png b/src/image_data/opengl.png Binary files differnew file mode 100644 index 0000000..e69fa24 --- /dev/null +++ b/src/image_data/opengl.png diff --git a/src/image_data/penguin.png b/src/image_data/penguin.png Binary files differnew file mode 100644 index 0000000..6391c58 --- /dev/null +++ b/src/image_data/penguin.png diff --git a/src/image_data/png_to_c_header.sh b/src/image_data/png_to_c_header.sh index 65f7c26..65f7c26 100644..100755 --- a/src/image_data/png_to_c_header.sh +++ b/src/image_data/png_to_c_header.sh diff --git a/src/image_data/rj45_input.png b/src/image_data/rj45_input.png Binary files differnew file mode 100644 index 0000000..c90313f --- /dev/null +++ b/src/image_data/rj45_input.png diff --git a/src/image_data/rj45_output.png b/src/image_data/rj45_output.png Binary files differnew file mode 100644 index 0000000..6959ab4 --- /dev/null +++ b/src/image_data/rj45_output.png diff --git a/src/image_data/rj45_unused.png b/src/image_data/rj45_unused.png Binary files differnew file mode 100644 index 0000000..b41ac15 --- /dev/null +++ b/src/image_data/rj45_unused.png diff --git a/src/image_data/rotate_left_off.png b/src/image_data/rotate_left_off.png Binary files differnew file mode 100644 index 0000000..3b609a3 --- /dev/null +++ b/src/image_data/rotate_left_off.png diff --git a/src/image_data/rotate_left_on.png b/src/image_data/rotate_left_on.png Binary files differnew file mode 100644 index 0000000..4adb3e9 --- /dev/null +++ b/src/image_data/rotate_left_on.png diff --git a/src/image_data/rotate_right_off.png b/src/image_data/rotate_right_off.png Binary files differnew file mode 100644 index 0000000..3bd9413 --- /dev/null +++ b/src/image_data/rotate_right_off.png diff --git a/src/image_data/rotate_right_on.png b/src/image_data/rotate_right_on.png Binary files differnew file mode 100644 index 0000000..5a99d55 --- /dev/null +++ b/src/image_data/rotate_right_on.png diff --git a/src/image_data/rotation.png b/src/image_data/rotation.png Binary files differnew file mode 100644 index 0000000..466812a --- /dev/null +++ b/src/image_data/rotation.png diff --git a/src/image_data/rotation_orientation_horz.png b/src/image_data/rotation_orientation_horz.png Binary files differnew file mode 100644 index 0000000..8280377 --- /dev/null +++ b/src/image_data/rotation_orientation_horz.png diff --git a/src/image_data/rotation_orientation_vert.png b/src/image_data/rotation_orientation_vert.png Binary files differnew file mode 100644 index 0000000..11c163d --- /dev/null +++ b/src/image_data/rotation_orientation_vert.png diff --git a/src/image_data/sdi.png b/src/image_data/sdi.png Binary files differnew file mode 100644 index 0000000..abf06ad --- /dev/null +++ b/src/image_data/sdi.png diff --git a/src/image_data/sdi_shared_sync_bnc.png b/src/image_data/sdi_shared_sync_bnc.png Binary files differnew file mode 100644 index 0000000..f4b7455 --- /dev/null +++ b/src/image_data/sdi_shared_sync_bnc.png diff --git a/src/image_data/slimm.png b/src/image_data/slimm.png Binary files differnew file mode 100644 index 0000000..8c1e654 --- /dev/null +++ b/src/image_data/slimm.png diff --git a/src/image_data/solaris.png b/src/image_data/solaris.png Binary files differnew file mode 100644 index 0000000..59f4037 --- /dev/null +++ b/src/image_data/solaris.png diff --git a/src/image_data/src.mk b/src/image_data/src.mk new file mode 100644 index 0000000..6cef856 --- /dev/null +++ b/src/image_data/src.mk @@ -0,0 +1,97 @@ +# +# files in the src/image_data directory of nvidia-settings +# + +IMAGE_DATA_SRC += + +IMAGE_DATA_EXTRA_DIST += HOWTO-ADD-IMAGES +IMAGE_DATA_EXTRA_DIST += antialias.png +IMAGE_DATA_EXTRA_DIST += antialias_pixdata.h +IMAGE_DATA_EXTRA_DIST += background.png +IMAGE_DATA_EXTRA_DIST += background_pixdata.h +IMAGE_DATA_EXTRA_DIST += background_tall.png +IMAGE_DATA_EXTRA_DIST += background_tall_pixdata.h +IMAGE_DATA_EXTRA_DIST += bnc_cable.png +IMAGE_DATA_EXTRA_DIST += bnc_cable_pixdata.h +IMAGE_DATA_EXTRA_DIST += bsd.png +IMAGE_DATA_EXTRA_DIST += bsd_pixdata.h +IMAGE_DATA_EXTRA_DIST += clock.png +IMAGE_DATA_EXTRA_DIST += clock_pixdata.h +IMAGE_DATA_EXTRA_DIST += color.png +IMAGE_DATA_EXTRA_DIST += color_pixdata.h +IMAGE_DATA_EXTRA_DIST += config.png +IMAGE_DATA_EXTRA_DIST += config_pixdata.h +IMAGE_DATA_EXTRA_DIST += crt.png +IMAGE_DATA_EXTRA_DIST += crt_pixdata.h +IMAGE_DATA_EXTRA_DIST += cursor_shadow.png +IMAGE_DATA_EXTRA_DIST += cursor_shadow_pixdata.h +IMAGE_DATA_EXTRA_DIST += dfp.png +IMAGE_DATA_EXTRA_DIST += dfp_pixdata.h +IMAGE_DATA_EXTRA_DIST += display_config.png +IMAGE_DATA_EXTRA_DIST += display_config_pixdata.h +IMAGE_DATA_EXTRA_DIST += framelock.png +IMAGE_DATA_EXTRA_DIST += framelock_pixdata.h +IMAGE_DATA_EXTRA_DIST += glx.png +IMAGE_DATA_EXTRA_DIST += glx_pixdata.h +IMAGE_DATA_EXTRA_DIST += gpu.png +IMAGE_DATA_EXTRA_DIST += gpu_pixdata.h +IMAGE_DATA_EXTRA_DIST += gvi.png +IMAGE_DATA_EXTRA_DIST += gvi_pixdata.h +IMAGE_DATA_EXTRA_DIST += help.png +IMAGE_DATA_EXTRA_DIST += help_pixdata.h +IMAGE_DATA_EXTRA_DIST += led_green.png +IMAGE_DATA_EXTRA_DIST += led_green_pixdata.h +IMAGE_DATA_EXTRA_DIST += led_grey.png +IMAGE_DATA_EXTRA_DIST += led_grey_pixdata.h +IMAGE_DATA_EXTRA_DIST += led_red.png +IMAGE_DATA_EXTRA_DIST += led_red_pixdata.h +IMAGE_DATA_EXTRA_DIST += logo.png +IMAGE_DATA_EXTRA_DIST += logo_pixdata.h +IMAGE_DATA_EXTRA_DIST += logo_tall.png +IMAGE_DATA_EXTRA_DIST += logo_tall_pixdata.h +IMAGE_DATA_EXTRA_DIST += nvidia_icon.png +IMAGE_DATA_EXTRA_DIST += nvidia_icon_pixdata.h +IMAGE_DATA_EXTRA_DIST += opengl.png +IMAGE_DATA_EXTRA_DIST += opengl_pixdata.h +IMAGE_DATA_EXTRA_DIST += penguin.png +IMAGE_DATA_EXTRA_DIST += penguin_pixdata.h +IMAGE_DATA_EXTRA_DIST += png_to_c_header.sh +IMAGE_DATA_EXTRA_DIST += rj45_input.png +IMAGE_DATA_EXTRA_DIST += rj45_input_pixdata.h +IMAGE_DATA_EXTRA_DIST += rj45_output.png +IMAGE_DATA_EXTRA_DIST += rj45_output_pixdata.h +IMAGE_DATA_EXTRA_DIST += rj45_unused.png +IMAGE_DATA_EXTRA_DIST += rj45_unused_pixdata.h +IMAGE_DATA_EXTRA_DIST += rotate_left_off.png +IMAGE_DATA_EXTRA_DIST += rotate_left_off_pixdata.h +IMAGE_DATA_EXTRA_DIST += rotate_left_on.png +IMAGE_DATA_EXTRA_DIST += rotate_left_on_pixdata.h +IMAGE_DATA_EXTRA_DIST += rotate_right_off.png +IMAGE_DATA_EXTRA_DIST += rotate_right_off_pixdata.h +IMAGE_DATA_EXTRA_DIST += rotate_right_on.png +IMAGE_DATA_EXTRA_DIST += rotate_right_on_pixdata.h +IMAGE_DATA_EXTRA_DIST += rotation.png +IMAGE_DATA_EXTRA_DIST += rotation_orientation_horz.png +IMAGE_DATA_EXTRA_DIST += rotation_orientation_horz_pixdata.h +IMAGE_DATA_EXTRA_DIST += rotation_orientation_vert.png +IMAGE_DATA_EXTRA_DIST += rotation_orientation_vert_pixdata.h +IMAGE_DATA_EXTRA_DIST += rotation_pixdata.h +IMAGE_DATA_EXTRA_DIST += sdi.png +IMAGE_DATA_EXTRA_DIST += sdi_pixdata.h +IMAGE_DATA_EXTRA_DIST += sdi_shared_sync_bnc.png +IMAGE_DATA_EXTRA_DIST += sdi_shared_sync_bnc_pixdata.h +IMAGE_DATA_EXTRA_DIST += slimm.png +IMAGE_DATA_EXTRA_DIST += slimm_pixdata.h +IMAGE_DATA_EXTRA_DIST += solaris.png +IMAGE_DATA_EXTRA_DIST += solaris_pixdata.h +IMAGE_DATA_EXTRA_DIST += src.mk +IMAGE_DATA_EXTRA_DIST += thermal.png +IMAGE_DATA_EXTRA_DIST += thermal_pixdata.h +IMAGE_DATA_EXTRA_DIST += tv.png +IMAGE_DATA_EXTRA_DIST += tv_pixdata.h +IMAGE_DATA_EXTRA_DIST += vcs.png +IMAGE_DATA_EXTRA_DIST += vcs_pixdata.h +IMAGE_DATA_EXTRA_DIST += x.png +IMAGE_DATA_EXTRA_DIST += x_pixdata.h +IMAGE_DATA_EXTRA_DIST += xvideo.png +IMAGE_DATA_EXTRA_DIST += xvideo_pixdata.h diff --git a/src/image_data/thermal.png b/src/image_data/thermal.png Binary files differnew file mode 100644 index 0000000..bb40385 --- /dev/null +++ b/src/image_data/thermal.png diff --git a/src/image_data/tv.png b/src/image_data/tv.png Binary files differnew file mode 100644 index 0000000..d8ea6b7 --- /dev/null +++ b/src/image_data/tv.png diff --git a/src/image_data/vcs.png b/src/image_data/vcs.png Binary files differnew file mode 100644 index 0000000..8fe7289 --- /dev/null +++ b/src/image_data/vcs.png diff --git a/src/image_data/x.png b/src/image_data/x.png Binary files differnew file mode 100644 index 0000000..2a94e42 --- /dev/null +++ b/src/image_data/x.png diff --git a/src/image_data/xvideo.png b/src/image_data/xvideo.png Binary files differnew file mode 100644 index 0000000..9b79903 --- /dev/null +++ b/src/image_data/xvideo.png diff --git a/src/libXNVCtrl/Makefile.inc b/src/libXNVCtrl/Makefile.inc deleted file mode 100644 index 0f42108..0000000 --- a/src/libXNVCtrl/Makefile.inc +++ /dev/null @@ -1,37 +0,0 @@ -# -# libXNVCtrl: A library for configuring the NVIDIA X driver on Unix and Linux -# systems using the NV-CONTROL X11 protocol extension. -# -# Copyright (c) 2004-2008 NVIDIA, Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -EXTRA_DIST += \ - Makefile \ - Makefile.inc \ - NVCtrl.h \ - NVCtrlLib.h \ - libXNVCtrl.a \ - NVCtrl.c \ - nv_control.h - -dist_list:: - @ echo $(SRC) $(EXTRA_DIST) diff --git a/src/libXNVCtrl/NVCtrl.c b/src/libXNVCtrl/NVCtrl.c index 097909c..c9276c1 100644 --- a/src/libXNVCtrl/NVCtrl.c +++ b/src/libXNVCtrl/NVCtrl.c @@ -33,6 +33,7 @@ #define NEED_EVENTS #define NEED_REPLIES +#include <stdint.h> #include <stdlib.h> #include <X11/Xlibint.h> #include <X11/Xutil.h> @@ -41,9 +42,10 @@ #include "NVCtrlLib.h" #include "nv_control.h" -#define NVCTRL_EXT_NEED_CHECK (XPointer)(~0) -#define NVCTRL_EXT_NEED_NOTHING (XPointer)(0) -#define NVCTRL_EXT_NEED_TARGET_SWAP (XPointer)(1) +#define NVCTRL_EXT_EXISTS 1 +#define NVCTRL_EXT_NEED_TARGET_SWAP 2 +#define NVCTRL_EXT_64_BIT_ATTRIBUTES 4 +#define NVCTRL_EXT_NEED_CHECK (1 << (sizeof(XPointer) - 1)) static XExtensionInfo _nvctrl_ext_info_data; static XExtensionInfo *nvctrl_ext_info = &_nvctrl_ext_info_data; @@ -55,6 +57,7 @@ static /* const */ char *nvctrl_extension_name = NV_CONTROL_NAME; XextSimpleCheckExtension (dpy, i, nvctrl_extension_name) static int close_display(); +static uintptr_t version_flags(Display *dpy, XExtDisplayInfo *info); static Bool wire_to_event(); static /* const */ XExtensionHooks nvctrl_extension_hooks = { NULL, /* create_gc */ @@ -71,9 +74,10 @@ static /* const */ XExtensionHooks nvctrl_extension_hooks = { }; static XEXT_GENERATE_FIND_DISPLAY (find_display, nvctrl_ext_info, - nvctrl_extension_name, + nvctrl_extension_name, &nvctrl_extension_hooks, - NV_CONTROL_EVENTS, NVCTRL_EXT_NEED_CHECK) + NV_CONTROL_EVENTS, + (XPointer)NVCTRL_EXT_NEED_CHECK) static XEXT_GENERATE_CLOSE_DISPLAY (close_display, nvctrl_ext_info) @@ -82,29 +86,14 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, nvctrl_ext_info) * fields in reversed order. In order to talk to one of these servers, * we need to swap these fields. */ + static void XNVCTRLCheckTargetData(Display *dpy, XExtDisplayInfo *info, int *target_type, int *target_id) { - /* Find out what the server's NV-CONTROL version is and - * setup for swapping if we need to. - */ - if (info->data == NVCTRL_EXT_NEED_CHECK) { - int major, minor; - - if (XNVCTRLQueryVersion(dpy, &major, &minor)) { - if (major == 1 && - (minor == 8 || minor == 9)) { - info->data = NVCTRL_EXT_NEED_TARGET_SWAP; - } else { - info->data = NVCTRL_EXT_NEED_NOTHING; - } - } else { - info->data = NVCTRL_EXT_NEED_NOTHING; - } - } + uintptr_t flags = version_flags(dpy, info); /* We need to swap the target_type and target_id */ - if (info->data == NVCTRL_EXT_NEED_TARGET_SWAP) { + if (flags & NVCTRL_EXT_NEED_TARGET_SWAP) { int tmp; tmp = *target_type; *target_type = *target_id; @@ -129,6 +118,34 @@ Bool XNVCTRLQueryExtension ( } } +/* + * Retrieve any cached flags that depend on the version of the NV-CONTROL + * extension. + */ + +static uintptr_t version_flags(Display *dpy, XExtDisplayInfo *info) +{ + uintptr_t data = (uintptr_t)info->data; + + /* If necessary, determine the NV-CONTROL version */ + if (data & NVCTRL_EXT_NEED_CHECK) { + int major, minor; + data = 0; + if (XNVCTRLQueryVersion(dpy, &major, &minor)) { + data |= NVCTRL_EXT_EXISTS; + if (major == 1 && (minor == 8 || minor == 9)) { + data |= NVCTRL_EXT_NEED_TARGET_SWAP; + } + if ((major > 1) || ((major == 1) && (minor > 20))) { + data |= NVCTRL_EXT_64_BIT_ATTRIBUTES; + } + } + + info->data = (XPointer)data; + } + + return data; +} Bool XNVCTRLQueryVersion ( Display *dpy, @@ -676,7 +693,7 @@ Bool XNVCTRLQueryValidTargetAttributeValues ( ){ XExtDisplayInfo *info = find_display(dpy); Bool exists; - int major, minor; + uintptr_t flags; if (!values) return False; @@ -686,10 +703,12 @@ Bool XNVCTRLQueryValidTargetAttributeValues ( XNVCTRLCheckExtension(dpy, info, False); XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id); - if (!XNVCTRLQueryVersion(dpy, &major, &minor)) + flags = version_flags(dpy,info); + + if (!(flags & NVCTRL_EXT_EXISTS)) return False; - if ((major > 1) || ((major == 1) && (minor > 20))) { + if (flags & NVCTRL_EXT_64_BIT_ATTRIBUTES) { exists = XNVCTRLQueryValidTargetAttributeValues64(dpy, info, target_type, target_id, @@ -712,7 +731,7 @@ Bool XNVCTRLQueryValidAttributeValues ( Display *dpy, int screen, unsigned int display_mask, - unsigned int attribute, + unsigned int attribute, NVCTRLAttributeValidValuesRec *values ){ return XNVCTRLQueryValidTargetAttributeValues(dpy, @@ -775,7 +794,7 @@ Bool XNVCTRLQueryGvoColorConversion ( XExtDisplayInfo *info = find_display (dpy); xnvCtrlQueryGvoColorConversionReply rep; xnvCtrlQueryGvoColorConversionReq *req; - + if(!XextHasExtension(info)) return False; @@ -1130,7 +1149,7 @@ static Bool wire_to_event (Display *dpy, XEvent *host, xEvent *wire) default: return False; } - + return True; } diff --git a/src/libXNVCtrl/NVCtrl.h b/src/libXNVCtrl/NVCtrl.h index d7cfe4c..fa97d2f 100644 --- a/src/libXNVCtrl/NVCtrl.h +++ b/src/libXNVCtrl/NVCtrl.h @@ -39,12 +39,13 @@ * Here are the supported target types: */ -#define NV_CTRL_TARGET_TYPE_X_SCREEN 0 -#define NV_CTRL_TARGET_TYPE_GPU 1 -#define NV_CTRL_TARGET_TYPE_FRAMELOCK 2 -#define NV_CTRL_TARGET_TYPE_VCSC 3 /* Visual Computing System */ -#define NV_CTRL_TARGET_TYPE_GVI 4 -#define NV_CTRL_TARGET_TYPE_COOLER 5 /* e.g., fan */ +#define NV_CTRL_TARGET_TYPE_X_SCREEN 0 +#define NV_CTRL_TARGET_TYPE_GPU 1 +#define NV_CTRL_TARGET_TYPE_FRAMELOCK 2 +#define NV_CTRL_TARGET_TYPE_VCSC 3 /* Visual Computing System */ +#define NV_CTRL_TARGET_TYPE_GVI 4 +#define NV_CTRL_TARGET_TYPE_COOLER 5 /* e.g., fan */ +#define NV_CTRL_TARGET_TYPE_THERMAL_SENSOR 6 /**************************************************************************/ @@ -99,6 +100,9 @@ * C: The attribute may be queried using an NV_CTRL_TARGET_TYPE_COOLER target * type via XNVCTRLQueryTargetAttribute(). * + * S: The attribute may be queried using an NV_CTRL_TARGET_TYPE_THERMAL_SENSOR + * target type via XNVCTRLQueryTargetAttribute(). + * * NOTE: Unless mentioned otherwise, all attributes may be queried using * an NV_CTRL_TARGET_TYPE_X_SCREEN target type via * XNVCTRLQueryTargetAttribute(). @@ -151,17 +155,13 @@ * NV_CTRL_FLATPANEL_DITHERING - the current flat panel dithering * state; possible values are: * - * 0: default (the driver will decide when to dither) + * 0: disabled (the driver will never dither) * 1: enabled (the driver will always dither when possible) - * 2: disabled (the driver will never dither) - * - * USAGE NOTE: This attribute had been deprecated. */ #define NV_CTRL_FLATPANEL_DITHERING 3 /* RWDG */ -#define NV_CTRL_FLATPANEL_DITHERING_DEFAULT 0 +#define NV_CTRL_FLATPANEL_DITHERING_DISABLED 0 #define NV_CTRL_FLATPANEL_DITHERING_ENABLED 1 -#define NV_CTRL_FLATPANEL_DITHERING_DISABLED 2 /* @@ -320,7 +320,12 @@ #define NV_CTRL_STEREO_BLUELINE 2 #define NV_CTRL_STEREO_DIN 3 #define NV_CTRL_STEREO_TWINVIEW 4 - +#define NV_CTRL_STEREO_VERTICAL_INTERLACED 5 +#define NV_CTRL_STEREO_COLOR_INTERLACED 6 +#define NV_CTRL_STEREO_HORIZONTAL_INTERLACED 7 +#define NV_CTRL_STEREO_CHECKERBOARD_PATTERN 8 +#define NV_CTRL_STEREO_INVERSE_CHECKERBOARD_PATTERN 9 +#define NV_CTRL_STEREO_3D_VISION 10 /* * NV_CTRL_EMULATE - controls OpenGL software emulation of future @@ -995,6 +1000,12 @@ * of the 32-63 VIDEO_FORMATS are valid, and query the ValidValues of * NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 to check which of the 64-95 * VIDEO_FORMATS are valid. + * + * Note: Setting this attribute on a GVI device may also result in the + * following NV-CONTROL attributes being reset on that device (to + * ensure the configuration remains valid): + * NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT + * NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING */ #define NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT 70 /* RW--I */ @@ -1763,8 +1774,9 @@ * NV_CTRL_INITIAL_PIXMAP_PLACEMENT - Controls where X pixmaps are initially * created. * - * NV_CTRL_INITIAL_PIXMAP_PLACEMENT_FORCE_SYSMEM causes to pixmaps to stay in - * system memory. + * NV_CTRL_INITIAL_PIXMAP_PLACEMENT_FORCE_SYSMEM causes pixmaps to stay in + * system memory. These pixmaps can't be accelerated by the NVIDIA driver; this + * will cause blank windows if used with an OpenGL compositing manager. * NV_CTRL_INITIAL_PIXMAP_PLACEMENT_SYSMEM creates pixmaps in system memory * initially, but allows them to migrate to video memory. * NV_CTRL_INITIAL_PIXMAP_PLACEMENT_VIDMEM creates pixmaps in video memory @@ -2492,6 +2504,11 @@ * NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT - Specify the number of * bits per component (BPC) of data for the captured stream. * The stream number should be specified in the "display_mask" parameter. + * + * Note: Setting this attribute may also result in the following + * NV-CONTROL attributes being reset on the GVI device (to ensure + * the configuration remains valid): + * NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING */ #define NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT 310 /* RW-I */ @@ -2526,7 +2543,8 @@ /* * NV_CTRL_GVI_CHROMA_EXPAND - Enable or disable 4:2:2 -> 4:4:4 chroma * expansion for the captured stream. This value is ignored when a - * COMPONENT_SAMPLING format is selected that does not use chroma subsampling. + * COMPONENT_SAMPLING format is selected that does not use chroma subsampling, + * or if a BITS_PER_COMPONENT value is selected that is not supported. * The stream number should be specified in the "display_mask" parameter. */ @@ -2806,7 +2824,6 @@ */ #define NV_CTRL_GVI_BOUND_GPU 342 /* R--I */ - /* * NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 - this attribute is only * intended to be used to query the ValidValues for @@ -2816,7 +2833,6 @@ #define NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 343 /* ---GI */ - /* * NV_CTRL_ACCELERATE_TRAPEZOIDS - Toggles RENDER Trapezoid acceleration */ @@ -2825,7 +2841,6 @@ #define NV_CTRL_ACCELERATE_TRAPEZOIDS_DISABLE 0 #define NV_CTRL_ACCELERATE_TRAPEZOIDS_ENABLE 1 - /* * NV_CTRL_GPU_CORES - Returns number of GPU cores supported by the graphics * pipeline. @@ -2833,7 +2848,6 @@ #define NV_CTRL_GPU_CORES 345 /* R--G */ - /* * NV_CTRL_GPU_MEMORY_BUS_WIDTH - Returns memory bus bandwidth on the associated * subdevice. @@ -2841,7 +2855,6 @@ #define NV_CTRL_GPU_MEMORY_BUS_WIDTH 346 /* R--G */ - /* * NV_CTRL_GVI_TEST_MODE - This attribute controls the GVI test mode. When * enabled, the GVI device will generate fake data as quickly as possible. All @@ -2855,7 +2868,87 @@ #define NV_CTRL_GVI_TEST_MODE_ENABLE 1 -#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_GVI_TEST_MODE +/* + * NV_CTRL_GPU_SCALING_DEFAULT_TARGET - Returns the default scaling target + * for the specified display device. + * + * NV_CTRL_GPU_SCALING_DEFAULT_METHOD - Returns the default scaling method + * for the specified display device. + * + * The values returned by these attributes are one of the target or method + * values defined for the attribute NV_CTRL_GPU_SCALING. + */ +#define NV_CTRL_GPU_SCALING_DEFAULT_TARGET 350 /* R-DG */ +#define NV_CTRL_GPU_SCALING_DEFAULT_METHOD 351 /* R-DG */ + +/* + * NV_CTRL_FLATPANEL_DITHERING_MODE - Controls the dithering mode used for + * the flatpanel, when NV_CTRL_FLATPANEL_DITHERING is set to ENABLED. + * + * DYNAMIC_2X2: use a 2x2 matrix to dither from the GPU's pixel + * pipeline to the bit depth of the flatpanel. The matrix values + * are changed from frame to frame. + * + * STATIC_2X2: use a 2x2 matrix to dither from the GPU's pixel + * pipeline to the bit depth of the flatpanel. The matrix values + * do not change from frame to frame. + */ +#define NV_CTRL_FLATPANEL_DITHERING_MODE 352 /* RWDG */ +#define NV_CTRL_FLATPANEL_DITHERING_MODE_DYNAMIC_2X2 0 +#define NV_CTRL_FLATPANEL_DITHERING_MODE_STATIC_2X2 1 + +/* + * NV_CTRL_FLATPANEL_DEFAULT_DITHERING - Returns the default dithering + * configuration for the flatpanel. Values returned are those described + * for NV_CTRL_FLATPANEL_DITHERING. + * + * NV_CTRL_FLATPANEL_DEFAULT_DITHERING_MODE - Returns the default dithering + * mode for the flatpanel. Values returned are those described for + * NV_CTRL_FLATPANEL_DITHERING_MODE. + */ +#define NV_CTRL_FLATPANEL_DEFAULT_DITHERING 353 /* R-DG */ +#define NV_CTRL_FLATPANEL_DEFAULT_DITHERING_MODE 354 /* R-DG */ + +/* + * NV_CTRL_THERMAL_SENSOR_READING - Returns the thermal sensor's current + * reading. + */ +#define NV_CTRL_THERMAL_SENSOR_READING 355 /* R--S */ + +/* + * NV_CTRL_THERMAL_SENSOR_PROVIDER - Returns the hardware device that + * provides the thermal sensor. + */ +#define NV_CTRL_THERMAL_SENSOR_PROVIDER 356 /* R--S */ +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_NONE 0 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_GPU_INTERNAL 1 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_ADM1032 2 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_ADT7461 3 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_MAX6649 4 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_MAX1617 5 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_LM99 6 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_LM89 7 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_LM64 8 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_G781 9 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_ADT7473 10 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_SBMAX6649 11 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_VBIOSEVT 12 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_OS 13 +#define NV_CTRL_THERMAL_SENSOR_PROVIDER_UNKNOWN 0xFFFFFFFF + +/* + * NV_CTRL_THERMAL_SENSOR_TARGET - Returns what hardware component + * the thermal sensor is measuring. + */ +#define NV_CTRL_THERMAL_SENSOR_TARGET 357 /* R--S */ +#define NV_CTRL_THERMAL_SENSOR_TARGET_NONE 0 +#define NV_CTRL_THERMAL_SENSOR_TARGET_GPU 1 +#define NV_CTRL_THERMAL_SENSOR_TARGET_MEMORY 2 +#define NV_CTRL_THERMAL_SENSOR_TARGET_POWER_SUPPLY 4 +#define NV_CTRL_THERMAL_SENSOR_TARGET_BOARD 8 +#define NV_CTRL_THERMAL_SENSOR_TARGET_UNKNOWN 0xFFFFFFFF + +#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_THERMAL_SENSOR_TARGET /**************************************************************************/ @@ -3626,8 +3719,24 @@ #define NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN 11 /* R--- */ +/* + * NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU - Returns the sensors that + * are attached to the given GPU. + * + * The format of the returned data is: + * + * 4 CARD32 number of SENSOR + * 4 * n CARD32 SENSOR indices + * + * This attribute can only be queried through XNVCTRLQueryTargetBinaryData() + * using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be + * queried using a NV_CTRL_TARGET_TYPE_X_SCREEN + */ + +#define NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU 12 /* R--G */ + #define NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE \ - NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN + NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU /**************************************************************************/ @@ -3806,6 +3915,13 @@ * Upon successful configuration or querying of this attribute, a string * representing the current topology for all known streams on the device * will be returned. On failure, NULL is returned. + * + * Note: Setting this attribute may also result in the following + * NV-CONTROL attributes being reset on the GVI device (to ensure + * the configuration remains valid): + * NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT + * NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT + * NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING */ #define NV_CTRL_STRING_OPERATION_GVI_CONFIGURE_STREAMS 4 /* RW-I */ @@ -3887,6 +4003,7 @@ #define ATTRIBUTE_TYPE_VCSC 0x080 #define ATTRIBUTE_TYPE_GVI 0x100 #define ATTRIBUTE_TYPE_COOLER 0x200 +#define ATTRIBUTE_TYPE_THERMAL_SENSOR 0x400 typedef struct _NVCTRLAttributeValidValues { int type; diff --git a/src/libXNVCtrl/nv_control.h b/src/libXNVCtrl/nv_control.h index 2755387..97229f9 100644 --- a/src/libXNVCtrl/nv_control.h +++ b/src/libXNVCtrl/nv_control.h @@ -47,6 +47,7 @@ * 1.21 Added initial 64-bit integer attribute support (read-only) * 1.22 Added X_nvCtrlQueryValidStringAttributeValues to check * string attribute permissions. + * 1.23 Added SENSOR TargetType */ #ifndef __NVCONTROL_H @@ -57,7 +58,7 @@ #define NV_CONTROL_NAME "NV-CONTROL" #define NV_CONTROL_MAJOR 1 -#define NV_CONTROL_MINOR 22 +#define NV_CONTROL_MINOR 23 #define X_nvCtrlQueryExtension 0 #define X_nvCtrlIsNv 1 @@ -66,8 +67,8 @@ #define X_nvCtrlQueryStringAttribute 4 #define X_nvCtrlQueryValidAttributeValues 5 #define X_nvCtrlSelectNotify 6 -#define X_nvCtrlSetGvoColorConversion_deprecated 7 -#define X_nvCtrlQueryGvoColorConversion_deprecated 8 +#define X_nvCtrlSetGvoColorConversionDeprecated 7 +#define X_nvCtrlQueryGvoColorConversionDeprecated 8 #define X_nvCtrlSetStringAttribute 9 /* STUB X_nvCtrlQueryDDCCILutSize 10 */ /* STUB X_nvCtrlQueryDDCCISinglePointLutOperation 11 */ diff --git a/src/libXNVCtrlAttributes/Makefile.inc b/src/libXNVCtrlAttributes/Makefile.inc deleted file mode 100644 index 7c2a87c..0000000 --- a/src/libXNVCtrlAttributes/Makefile.inc +++ /dev/null @@ -1,42 +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 of Version 2 of the GNU General Public -# License 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 Version 2 -# of the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the: -# -# Free Software Foundation, Inc. -# 59 Temple Place - Suite 330 -# Boston, MA 02111-1307, USA -# - -# -# libXNVCtrlAttributes files -# - -SRC += \ - NvCtrlAttributes.c \ - NvCtrlAttributesNvControl.c \ - NvCtrlAttributesVidMode.c \ - NvCtrlAttributesXv.c \ - NvCtrlAttributesGlx.c \ - NvCtrlAttributesXrandr.c - -EXTRA_DIST += \ - Makefile.inc \ - NvCtrlAttributes.h \ - NvCtrlAttributesPrivate.h - -dist_list:: - @ echo $(SRC) $(EXTRA_DIST) diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c b/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c index 470ab44..0f38ba7 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c @@ -629,8 +629,8 @@ NvCtrlGlxGetVoidAttribute (NvCtrlAttributePrivateHandle *h, * OpenGL/GLX function. * * - * But first, the following macros are used to setup a rendering context - * such that valid information may be retrieved. (Having a context is + * But first, the following helper function may be used to set up a rendering + * context such that valid information may be retrieved. (Having a context is * required for getting OpenGL and 'Direct rendering' information.) * * NOTE: A seperate display connection is used to avoid the dependence on @@ -640,35 +640,14 @@ NvCtrlGlxGetVoidAttribute (NvCtrlAttributePrivateHandle *h, * ****/ -/* Macros to set up/tear down a rendering context */ - -#define GET_CONTEXT() \ - root = RootWindow(h->dpy, h->target_id); \ - visinfo = __libGL->glXChooseVisual(h->dpy, h->target_id, \ - &(attribListSgl[0])); \ - win_attr.background_pixel = 0; \ - win_attr.border_pixel = 0; \ - win_attr.colormap = XCreateColormap(h->dpy, root, \ - visinfo->visual, AllocNone); \ - win_attr.event_mask = 0; \ - mask = CWBackPixel | CWBorderPixel | CWColormap | \ - CWEventMask; \ - win = XCreateWindow(h->dpy, root, 0, 0, width, height, \ - 0, visinfo->depth, InputOutput, \ - visinfo->visual, mask, &win_attr); \ - ctx = __libGL->glXCreateContext(h->dpy, visinfo, NULL, True ); \ - if ( ctx ) { __libGL->glXMakeCurrent(h->dpy, win, ctx); } - -#define CLEAN_CONTEXT() \ - if ( visinfo ) { XFree(visinfo); } \ - if ( ctx ) { __libGL->glXDestroyContext(h->dpy, ctx); } \ - if ( win ) { XDestroyWindow(h->dpy, win); } - - -ReturnStatus -NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *h, - unsigned int display_mask, - int attr, char **ptr) +/* + * Helper function for NvCtrlGlxGetStringAttribute for queries that require a + * current context. If getDirect is true, then check if we can create a direct + * 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, + Bool getDirect, GLenum prop) { const char *str = NULL; @@ -687,7 +666,53 @@ NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *h, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None }; - + root = RootWindow(h->dpy, h->target_id); + visinfo = __libGL->glXChooseVisual(h->dpy, h->target_id, + &(attribListSgl[0])); + if (!visinfo) { + return NULL; + } + win_attr.background_pixel = 0; + win_attr.border_pixel = 0; + win_attr.colormap = XCreateColormap(h->dpy, root, + visinfo->visual, AllocNone); + win_attr.event_mask = 0; + mask = CWBackPixel | CWBorderPixel | CWColormap | + CWEventMask; + win = XCreateWindow(h->dpy, root, 0, 0, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &win_attr); + ctx = __libGL->glXCreateContext(h->dpy, visinfo, NULL, True ); + if ( ctx ) { + __libGL->glXMakeCurrent(h->dpy, win, ctx); + } + + if (getDirect) { + str = ((*(__libGL->glXIsDirect))(h->dpy, ctx)) ? "Yes" : "No"; + } else { + str = (const char *) (* (__libGL->glGetString))(prop); + } + + if (visinfo) { + XFree(visinfo); + } + if (ctx) { + __libGL->glXDestroyContext(h->dpy, ctx); + } + if (win) { + XDestroyWindow(h->dpy, win); + } + + return str; +} + +ReturnStatus +NvCtrlGlxGetStringAttribute (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 ) { return NvCtrlBadHandle; @@ -704,9 +729,7 @@ NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *h, switch (attr) { case NV_CTRL_STRING_GLX_DIRECT_RENDERING: - GET_CONTEXT(); - str = ( (* (__libGL->glXIsDirect))(h->dpy, ctx) ) ? "Yes" : "No"; - CLEAN_CONTEXT(); + str = getString(h, True, 0); break; case NV_CTRL_STRING_GLX_GLX_EXTENSIONS: str = (* (__libGL->glXQueryExtensionsString))(h->dpy, h->target_id); @@ -733,24 +756,16 @@ NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *h, str = (* (__libGL->glXGetClientString))(h->dpy, GLX_EXTENSIONS); break; case NV_CTRL_STRING_GLX_OPENGL_VENDOR: - GET_CONTEXT(); - str = (const char *) (* (__libGL->glGetString))(GL_VENDOR); - CLEAN_CONTEXT(); + str = getString(h, False, GL_VENDOR); break; case NV_CTRL_STRING_GLX_OPENGL_RENDERER: - GET_CONTEXT(); - str = (const char *) (* (__libGL->glGetString))(GL_RENDERER); - CLEAN_CONTEXT(); + str = getString(h, False, GL_RENDERER); break; case NV_CTRL_STRING_GLX_OPENGL_VERSION: - GET_CONTEXT(); - str = (const char *) (* (__libGL->glGetString))(GL_VERSION); - CLEAN_CONTEXT(); + str = getString(h, False, GL_VERSION); break; case NV_CTRL_STRING_GLX_OPENGL_EXTENSIONS: - GET_CONTEXT(); - str = (const char *) (* (__libGL->glGetString))(GL_EXTENSIONS); - CLEAN_CONTEXT(); + str = getString(h, False, GL_EXTENSIONS); break; default: diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h b/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h index f82089e..ea4a38d 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h @@ -136,8 +136,8 @@ struct __NvCtrlXvBlitterAttributes { }; struct __NvCtrlXvAttributes { - int major_version; - int minor_version; + unsigned int major_version; + unsigned int minor_version; NvCtrlXvOverlayAttributes *overlay; /* XVideo info (overlay) */ NvCtrlXvTextureAttributes *texture; /* XVideo info (texture) */ NvCtrlXvBlitterAttributes *blitter; /* XVideo info (blitter) */ diff --git a/src/libXNVCtrlAttributes/src.mk b/src/libXNVCtrlAttributes/src.mk new file mode 100644 index 0000000..e8f9609 --- /dev/null +++ b/src/libXNVCtrlAttributes/src.mk @@ -0,0 +1,14 @@ +# +# files in the src/libXNVCtrlAttributes directory of nvidia-settings +# + +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributes.c +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributesNvControl.c +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributesVidMode.c +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributesXv.c +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributesGlx.c +LIB_XNVCTRL_ATTRIBUTES_SRC += NvCtrlAttributesXrandr.c + +LIB_XNVCTRL_ATTRIBUTES_EXTRA_DIST += NvCtrlAttributes.h +LIB_XNVCTRL_ATTRIBUTES_EXTRA_DIST += NvCtrlAttributesPrivate.h +LIB_XNVCTRL_ATTRIBUTES_EXTRA_DIST += src.mk diff --git a/src/parse.c b/src/parse.c index 1fd1912..338b512 100644 --- a/src/parse.c +++ b/src/parse.c @@ -153,7 +153,7 @@ AttributeTableEntry attributeTable[] = { { "PCIDevice", NV_CTRL_PCI_DEVICE, N, "Returns the PCI device number for the specified device." }, { "PCIFunc", NV_CTRL_PCI_FUNCTION, N, "Returns the PCI function number for the specified device." }, { "PCIID", NV_CTRL_PCI_ID, N|P, "Returns the PCI vendor and device ID of the specified device." }, - { "PCIEGen", NV_CTRL_GPU_PCIE_GENERATION, N, "Returns the current PCI-E Bus Generation." }, + { "PCIEGen", NV_CTRL_GPU_PCIE_GENERATION, N, "Returns the current PCI-E Bus Generation." }, { "GPUErrors", NV_CTRL_NUM_GPU_ERRORS_RECOVERED, N, "Returns the number of GPU errors occurred." }, { "GPUPowerSource", NV_CTRL_GPU_POWER_SOURCE, N, "Reports the type of power source of the GPU." }, { "GPUCurrentPerfMode", NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE, N, "Reports the current performance mode of the GPU driving the X screen. Running a 3D app, for example, will change this performance mode if Adaptive Clocking is enabled." }, @@ -173,7 +173,9 @@ AttributeTableEntry attributeTable[] = { { "GPUResetFanSpeed", NV_CTRL_THERMAL_COOLER_LEVEL_SET_DEFAULT, N, "Resets the GPU fan's speed to its default." }, { "GPUFanControlType", NV_CTRL_THERMAL_COOLER_CONTROL_TYPE, N, "Returns how the GPU fan is controlled. '1' means the fan can only be toggled on and off; '2' means the fan has variable speed. '0' means the fan is restricted and cannot be adjusted under end user control." }, { "GPUFanTarget", NV_CTRL_THERMAL_COOLER_TARGET, N, "Returns the objects the fan cools. '1' means the GPU, '2' means video memory, '4' means the power supply, and '7' means all of the above." }, - + { "ThermalSensorReading", NV_CTRL_THERMAL_SENSOR_READING, N, "Returns the thermal sensor's current reading." }, + { "ThermalSensorProvider", NV_CTRL_THERMAL_SENSOR_PROVIDER, N, "Returns the hardware device that provides the thermal sensor." }, + { "ThermalSensorTarget", NV_CTRL_THERMAL_SENSOR_TARGET, N, "Returns what hardware component the thermal sensor is measuring." }, /* Framelock */ { "FrameLockAvailable", NV_CTRL_FRAMELOCK, N|F|G, "Returns whether the underlying GPU supports Frame Lock. All of the other frame lock attributes are only applicable if this attribute is enabled (Supported)." }, { "FrameLockMaster", NV_CTRL_FRAMELOCK_MASTER, N|F|G|D, "Get/set which display device to use as the frame lock master for the entire sync group. Note that only one node in the sync group should be configured as the master." }, @@ -267,7 +269,8 @@ AttributeTableEntry attributeTable[] = { { "RedGamma", GAMMA_VALUE|RED_CHANNEL, C|G, "Controls the gamma of the color red in the display." }, { "GreenGamma", GAMMA_VALUE|GREEN_CHANNEL, C|G, "Controls the gamma of the color green in the display." }, { "BlueGamma", GAMMA_VALUE|BLUE_CHANNEL, C|G, "Controls the gamma of the color blue in the display." }, - { "FlatpanelDithering", NV_CTRL_FLATPANEL_DITHERING, 0, "This is the current state of flat panel dithering. This attribute has been deprecated." }, + { "FlatPanelDithering", NV_CTRL_FLATPANEL_DITHERING, 0, "Controls the FlatPanel dithering: enabled (1), disabled (0)." }, + { "FlatPanelDitheringMode", NV_CTRL_FLATPANEL_DITHERING_MODE, 0, "Controls the FlatPanel dithering mode when FlatPanelDithering=1; temporally static dithering pattern (1), temporally dynamic dithering pattern (0)." }, { "DigitalVibrance", NV_CTRL_DIGITAL_VIBRANCE, 0, "Sets the digital vibrance level of the display device." }, { "ImageSharpening", NV_CTRL_IMAGE_SHARPENING, 0, "Adjusts the sharpness of the display's image quality by amplifying high frequency content." }, { "ImageSharpeningDefault", NV_CTRL_IMAGE_SHARPENING_DEFAULT, 0, "Returns default value of image sharpening." }, @@ -277,6 +280,8 @@ AttributeTableEntry attributeTable[] = { { "FlatpanelBestFitResolution", NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION, N|P, "Returns the dimensions of the resolution, selected by the X driver, from the DFP's EDID that most closely matches the frontend resolution of the current mode. The best fit resolution is selected on a per-mode basis. This attribute is only valid for flat panel (DFP) display devices. This attribute is a packed integer; the width is packed in the upper 16-bits and the height is packed in the lower 16-bits." }, { "DFPScalingActive", NV_CTRL_DFP_SCALING_ACTIVE, N, "Returns the current state of DFP scaling. DFP scaling is mode-specific (meaning it may vary depending on which mode is currently set). DFP scaling is active if the GPU is set to scale to the best fit resolution (GPUScaling is set to use FlatpanelBestFitResolution) and the best fit and native resolutions are different." }, { "GPUScaling", NV_CTRL_GPU_SCALING, P, "Controls what the GPU scales to and how. This attribute is a packed integer; the scaling target (native/best fit) is packed in the upper 16-bits and the scaling method is packed in the lower 16-bits." }, + { "GPUScalingDefaultTarget", NV_CTRL_GPU_SCALING_DEFAULT_TARGET, 0, "Returns the default gpu scaling target for the Flatpanel." }, + { "GPUScalingDefaultMethod", NV_CTRL_GPU_SCALING_DEFAULT_METHOD, 0, "Returns the default gpu scaling method for the Flatpanel." }, { "GPUScalingActive", NV_CTRL_GPU_SCALING_ACTIVE, N, "Returns the current state of GPU scaling. GPU scaling is mode-specific (meaning it may vary depending on which mode is currently set). GPU scaling is active if the frontend timing (current resolution) is different than the target resolution. The target resolution is either the native resolution of the flat panel or the best fit resolution supported by the flat panel. What (and how) the GPU should scale to is controlled through the GPUScaling attribute." }, { "RefreshRate", NV_CTRL_REFRESH_RATE, N|H, "Returns the refresh rate of the specified display device in cHz (Centihertz) (to get the refresh rate in Hz, divide the returned value by 100)." }, { "RefreshRate3", NV_CTRL_REFRESH_RATE_3, N|K, "Returns the refresh rate of the specified display device in mHz (Millihertz) (to get the refresh rate in Hz, divide the returned value by 1000)." }, @@ -329,7 +334,7 @@ AttributeTableEntry attributeTable[] = { * about. */ -#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_GVI_TEST_MODE +#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_THERMAL_SENSOR_TARGET #warning "Have you forgotten to add a new integer attribute to attributeTable?" #endif @@ -390,6 +395,14 @@ TargetTypeEntry targetTypeTable[] = { 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 */ + { NULL, NULL, 0, 0, 0 }, }; @@ -1650,11 +1663,11 @@ const char *parse_read_display_name(const char *str, unsigned int *mask) * "MIN" * **/ -int parse_read_float_range(char *str, float *min, float *max) +int parse_read_float_range(const char *str, float *min, float *max) { if (!str) return 0; - str = (char *)parse_skip_whitespace(str); + str = parse_skip_whitespace(str); *min = atof(str); str = strstr(str, "-"); if (!str) { diff --git a/src/parse.h b/src/parse.h index 2ae9ff6..403782d 100644 --- a/src/parse.h +++ b/src/parse.h @@ -148,7 +148,8 @@ extern AttributeTableEntry attributeTable[]; #define VCS_TARGET 3 #define GVI_TARGET 4 #define COOLER_TARGET 5 -#define MAX_TARGET_TYPES 6 +#define THERMAL_SENSOR_TARGET 6 +#define MAX_TARGET_TYPES 7 @@ -316,7 +317,7 @@ const char *parse_read_integer_pair(const char *str, const char separator, int *a, int *b); const char *parse_read_name(const char *str, char **name, char term); const char *parse_read_display_name(const char *str, unsigned int *mask); -int parse_read_float_range(char *str, float *min, float *max); +int parse_read_float_range(const char *str, float *min, float *max); int count_number_of_bits(unsigned int mask); /* Token parsing functions */ diff --git a/src/query-assign.c b/src/query-assign.c index 7502b75..64f6d64 100644 --- a/src/query-assign.c +++ b/src/query-assign.c @@ -419,6 +419,11 @@ static int process_attribute_queries(int num, char **queries, continue; } + if (nv_strcasecmp(queries[query], "thermalsensors")) { + query_all_targets(display_name, THERMAL_SENSOR_TARGET); + continue; + } + /* call the parser to parse queries[query] */ ret = nv_parse_attribute_string(queries[query], NV_PARSER_QUERY, &a); @@ -1238,6 +1243,7 @@ static int print_target_connections(CtrlHandles *h, get_vcs_name(h->targets[target_index].t[ pData[i] ].h); break; + case THERMAL_SENSOR_TARGET: case COOLER_TARGET: case FRAMELOCK_TARGET: case GVI_TARGET: @@ -1342,8 +1348,13 @@ static int query_all_targets(const char *display_name, const int target_index) t = &h->targets[target_index].t[i]; str = NULL; + if (target_index == THERMAL_SENSOR_TARGET) { + /* for sensor, create the product name */ + + product_name = malloc(32); + snprintf(product_name, 32, "Thermal Sensor %d", i); - if (target_index == COOLER_TARGET) { + } else if (target_index == COOLER_TARGET) { /* for cooler, create the product name */ @@ -1418,6 +1429,9 @@ static int query_all_targets(const char *display_name, const int target_index) print_target_connections (h, t, NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU, COOLER_TARGET); + print_target_connections + (h, t, NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU, + THERMAL_SENSOR_TARGET); break; case X_SCREEN_TARGET: @@ -1444,6 +1458,12 @@ static int query_all_targets(const char *display_name, const int target_index) COOLER_TARGET); break; + case THERMAL_SENSOR_TARGET: + print_target_connections + (h, t, NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU, + THERMAL_SENSOR_TARGET); + break; + default: break; } diff --git a/src/src.mk b/src/src.mk new file mode 100644 index 0000000..2711f64 --- /dev/null +++ b/src/src.mk @@ -0,0 +1,23 @@ +# +# files in the src directory of nvidia-settings +# + +SRC_SRC += command-line.c +SRC_SRC += config-file.c +SRC_SRC += lscf.c +SRC_SRC += msg.c +SRC_SRC += nvidia-settings.c +SRC_SRC += parse.c +SRC_SRC += query-assign.c +SRC_SRC += nvgetopt.c +SRC_SRC += glxinfo.c + +SRC_EXTRA_DIST += src.mk +SRC_EXTRA_DIST += command-line.h +SRC_EXTRA_DIST += config-file.h +SRC_EXTRA_DIST += lscf.h +SRC_EXTRA_DIST += msg.h +SRC_EXTRA_DIST += parse.h +SRC_EXTRA_DIST += query-assign.h +SRC_EXTRA_DIST += nvgetopt.h +SRC_EXTRA_DIST += glxinfo.h diff --git a/src/xpm_data/Makefile.inc b/src/xpm_data/Makefile.inc deleted file mode 100644 index 3221772..0000000 --- a/src/xpm_data/Makefile.inc +++ /dev/null @@ -1,36 +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 of Version 2 of the GNU General Public -# License 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 Version 2 -# of the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the: -# -# Free Software Foundation, Inc. -# 59 Temple Place - Suite 330 -# Boston, MA 02111-1307, USA -# - -# -# src files and headers -# - -EXTRA_DIST += \ - Makefile.inc \ - blue_xpm.h \ - green_xpm.h \ - red_xpm.h \ - rgb_xpm.h - -dist_list:: - @ echo $(SRC) $(EXTRA_DIST) diff --git a/src/xpm_data/src.mk b/src/xpm_data/src.mk new file mode 100644 index 0000000..360d582 --- /dev/null +++ b/src/xpm_data/src.mk @@ -0,0 +1,11 @@ +# +# files in the src/xpm_data directory of nvidia-settings +# + +LIB_XPM_DATA_SRC += + +LIB_XPM_DATA_EXTRA_DIST += blue_xpm.h +LIB_XPM_DATA_EXTRA_DIST += green_xpm.h +LIB_XPM_DATA_EXTRA_DIST += red_xpm.h +LIB_XPM_DATA_EXTRA_DIST += rgb_xpm.h +LIB_XPM_DATA_EXTRA_DIST += src.mk |