diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2012-10-15 13:08:48 -0700 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2012-10-15 13:08:48 -0700 |
commit | 6f881b3f5e7701b9071f7dcf68d608b60472deed (patch) | |
tree | 0338169a5b6daaf1b2cb038bbb7dab7e38435627 | |
parent | a7ffe49011b002706153eea1690383f0958739c8 (diff) |
310.14310.14
31 files changed, 654 insertions, 1515 deletions
diff --git a/doc/version.mk b/doc/version.mk index 2335952..1feef56 100644 --- a/doc/version.mk +++ b/doc/version.mk @@ -1 +1 @@ -NVIDIA_VERSION = 304.51 +NVIDIA_VERSION = 310.14 diff --git a/samples/version.mk b/samples/version.mk index 2335952..1feef56 100644 --- a/samples/version.mk +++ b/samples/version.mk @@ -1 +1 @@ -NVIDIA_VERSION = 304.51 +NVIDIA_VERSION = 310.14 diff --git a/src/command-line.h b/src/command-line.h index 700ed2a..ccd60d3 100644 --- a/src/command-line.h +++ b/src/command-line.h @@ -20,17 +20,11 @@ #ifndef __COMMAND_LINE_H__ #define __COMMAND_LINE_H__ +#include "common-utils.h" + #define DEFAULT_RC_FILE "~/.nvidia-settings-rc" #define CONFIG_FILE_OPTION 1 - -#define VERBOSITY_NONE 0 /* nothing */ -#define VERBOSITY_ERROR 1 /* errors only */ -#define VERBOSITY_WARNING 2 /* errors and warnings */ -#define VERBOSITY_ALL 3 /* errors, warnings and other info */ - -#define VERBOSITY_DEFAULT VERBOSITY_ERROR - /* * Options structure -- stores the parameters specified on the * commandline. diff --git a/src/common-utils/common-utils.h b/src/common-utils/common-utils.h index c5cd411..626fd1b 100644 --- a/src/common-utils/common-utils.h +++ b/src/common-utils/common-utils.h @@ -33,6 +33,13 @@ #define TAB " " #define BIGTAB " " +#define VERBOSITY_NONE 0 /* nothing */ +#define VERBOSITY_ERROR 1 /* errors only */ +#define VERBOSITY_WARNING 2 /* errors and warnings */ +#define VERBOSITY_ALL 3 /* errors, warnings and other info */ + +#define VERBOSITY_DEFAULT VERBOSITY_ERROR + typedef struct { char **t; /* the text rows */ int n; /* number of rows */ diff --git a/src/config-file.c b/src/config-file.c index a267a1c..3f8d39b 100644 --- a/src/config-file.c +++ b/src/config-file.c @@ -211,7 +211,7 @@ int nv_read_config_file(const char *file, const char *display_name, int nv_write_config_file(const char *filename, CtrlHandles *h, ParsedAttribute *p, ConfigProperties *conf) { - int screen, ret, entry, bit, val; + int screen, ret, entry, bit, val, display, randr_gamma_available; FILE *stream; time_t now; AttributeTableEntry *a; @@ -272,8 +272,8 @@ int nv_write_config_file(const char *filename, CtrlHandles *h, fprintf(stream, "\n"); /* - * Note: we only save writable attributes addressable by X screen - * (i.e., we don't look at other target types, yet). + * Note: we only save writable attributes addressable by X screen here + * followed by attributes for display target types. */ for (screen = 0; screen < h->targets[X_SCREEN_TARGET].n; screen++) { @@ -387,6 +387,69 @@ int nv_write_config_file(const char *filename, CtrlHandles *h, } /* entry */ } /* screen */ + + /* + * Write attributes addresssable to display targets + */ + + for (display = 0; display < h->targets[DISPLAY_TARGET].n; display++) { + + t = &h->targets[DISPLAY_TARGET].t[display]; + + /* skip it if we don't have a handle for this display */ + + if (!t->h) continue; + + /* + * check to see if we have RANDR gamma available. We may + * skip writing attributes if it is missing. + */ + + status = NvCtrlGetAttribute(t->h, + NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE, + &randr_gamma_available); + if (status != NvCtrlSuccess) { + randr_gamma_available = 0; + } + + /* + * use the full display name as the prefix for display targets + * until we can parse other display target names + */ + + prefix = t->name; + + /* loop over all the entries in the table */ + + for (entry = 0; attributeTable[entry].name; entry++) { + + a = &attributeTable[entry]; + + /* + * skip all attributes that are not supposed to be written + * to the config file + */ + + if (a->flags & NV_PARSER_TYPE_NO_CONFIG_WRITE) continue; + + /* + * for the display target we only write color attributes for now + */ + + if (a->flags & NV_PARSER_TYPE_COLOR_ATTRIBUTE) { + float c[3], b[3], g[3]; + + if (!randr_gamma_available) continue; + + status = NvCtrlGetColorAttributes(t->h, c, b, g); + if (status != NvCtrlSuccess) continue; + + fprintf(stream, "%s%c%s=%f\n", + prefix, DISPLAY_NAME_SEPARATOR, a->name, + get_color_value(a->attr, c, b, g)); + } + } + } /* * loop the ParsedAttribute list, writing the attributes to file. @@ -418,40 +481,38 @@ int nv_write_config_file(const char *filename, CtrlHandles *h, * target type other than an X screen, include a target * specification in what we write to the .rc file. */ - + target_str[0] = '\0'; - + if ((p->flags & NV_PARSER_HAS_TARGET) && (p->target_type != NV_CTRL_TARGET_TYPE_X_SCREEN)) { - - int j; - + + TargetTypeEntry *targetTypeEntry; + /* Find the target name of the target type */ - for (j = 0; targetTypeTable[j].name; j++) { - if (targetTypeTable[j].nvctrl == p->target_type) { - snprintf(target_str, 64, "[%s:%d]", - targetTypeTable[j].parsed_name, p->target_id); - break; - } + targetTypeEntry = nv_get_target_type_entry_by_nvctrl(p->target_type); + if (targetTypeEntry) { + snprintf(target_str, 64, "[%s:%d]", + targetTypeEntry->parsed_name, p->target_id); } } - + if (p->display_device_mask) { - + tmp_d_str = display_device_mask_to_display_device_name (p->display_device_mask); - + fprintf(stream, "%s%s%c%s[%s]=%d\n", p->display, target_str, DISPLAY_NAME_SEPARATOR, tmp, tmp_d_str, p->val.i); - + free(tmp_d_str); - + } else { - + fprintf(stream, "%s%s%c%s=%d\n", p->display, target_str, DISPLAY_NAME_SEPARATOR, tmp, p->val.i); } - + p = p->next; } diff --git a/src/gtk+-2.x/ctkcolorcontrols.c b/src/gtk+-2.x/ctkcolorcontrols.c index c6262e8..c93309d 100644 --- a/src/gtk+-2.x/ctkcolorcontrols.c +++ b/src/gtk+-2.x/ctkcolorcontrols.c @@ -510,6 +510,10 @@ void add_color_controls_help(CtkColorControls *ctk_color_controls, GtkTextBuffer *b, GtkTextIter *i) { + if (ctk_color_controls == NULL) { + return; + } + ctk_help_heading(b, i, "Color Controls"); ctk_help_para(b, i, __color_controls_help); diff --git a/src/gtk+-2.x/ctkcolorcorrection.c b/src/gtk+-2.x/ctkcolorcorrection.c index 456dedb..8abfb8e 100644 --- a/src/gtk+-2.x/ctkcolorcorrection.c +++ b/src/gtk+-2.x/ctkcolorcorrection.c @@ -922,6 +922,25 @@ static void apply_parsed_attribute_list( } if (attr) { + + int i; + + /* + * if all the separate color channels are the same for an + * attribute, propagate the value to ALL_CHANNELS for that + * attribute + */ + for (i = CONTRAST; i <= GAMMA; i++) { + float val = ctk_color_correction->cur_slider_val[i][RED]; + + if ((ctk_color_correction->cur_slider_val[i][GREEN] == val) && + (ctk_color_correction->cur_slider_val[i][BLUE] == val)) { + set_color_state(ctk_color_correction, i, + ALL_CHANNELS, val, TRUE); + attr |= ALL_CHANNELS; + } + } + NvCtrlSetColorAttributes(ctk_color_correction->handle, ctk_color_correction->cur_slider_val[CONTRAST], ctk_color_correction->cur_slider_val[BRIGHTNESS], diff --git a/src/gtk+-2.x/ctkdisplayconfig-utils.c b/src/gtk+-2.x/ctkdisplayconfig-utils.c index 0d4c406..bb0ff6a 100644 --- a/src/gtk+-2.x/ctkdisplayconfig-utils.c +++ b/src/gtk+-2.x/ctkdisplayconfig-utils.c @@ -128,16 +128,18 @@ void apply_metamode_token(char *token, char *value, void *data) metamode->id = atoi(value); } - /* Modeline Source */ + /* Source */ } else if (!strcasecmp("source", token)) { if (!value || !strlen(value)) { nv_warning_msg("MetaMode 'source' token requires a value!"); } else if (!strcasecmp("xconfig", value)) { - metamode->source |= METAMODE_SOURCE_XCONFIG; + metamode->source = METAMODE_SOURCE_XCONFIG; } else if (!strcasecmp("implicit", value)) { - metamode->source |= METAMODE_SOURCE_IMPLICIT; + metamode->source = METAMODE_SOURCE_IMPLICIT; } else if (!strcasecmp("nv-control", value)) { - metamode->source |= METAMODE_SOURCE_NVCONTROL; + metamode->source = METAMODE_SOURCE_NVCONTROL; + } else if (!strcasecmp("randr", value)) { + metamode->source = METAMODE_SOURCE_RANDR; } else { nv_warning_msg("Unknown MetaMode source '%s'", value); } diff --git a/src/gtk+-2.x/ctkdisplayconfig.c b/src/gtk+-2.x/ctkdisplayconfig.c index 8111aa1..794bec2 100644 --- a/src/gtk+-2.x/ctkdisplayconfig.c +++ b/src/gtk+-2.x/ctkdisplayconfig.c @@ -159,7 +159,7 @@ static int __position_table[] = { CONF_ADJ_ABSOLUTE, /* Layout tooltips */ static const char * __layout_hidden_label_help = -"To select a display, use the \"Model\" dropdown menu."; +"To select a display, use the \"Selection\" dropdown menu."; static const char * __layout_xinerama_button_help = "The Enable Xinerama checkbox enables the Xinerama X extension; changing " @@ -232,19 +232,19 @@ static const char * __screen_stereo_help = "screen; changing this option will require restarting your X server."; static const char * __screen_position_type_help = -"The Position Type drop-down appears when two or more display devices are active. " +"The Position Type drop-down appears when two or more X screens are active. " "This allows you to set how the selected screen " "is placed within the X server layout; changing this option will require " "restarting your X server."; static const char * __screen_position_relative_help = -"The Position Relative drop-down appears when two or more display devices " +"The Position Relative drop-down appears when two or more X screens " "are active. This allows you to set which other Screen " "the selected screen should be relative to; changing this option will " "require restarting your X server."; static const char * __screen_position_offset_help = -"The Position Offset drop-down appears when two or more display devices " +"The Position Offset drop-down appears when two or more X screens " "are active. This identifies the top left of the selected Screen as " "an offset from the top left of the X server layout in absolute coordinates; " "changing this option will require restarting your X server."; @@ -634,7 +634,9 @@ static int generate_xconf_metamode_str(CtkDisplayConfig *ctk_object, int metamode_len; /* Only write out metamodes that were specified by the user */ - if (!(metamode->source & METAMODE_SOURCE_USER)) continue; + if (!IS_METAMODE_SOURCE_USER(metamode->source)) { + continue; + } /* The current mode was already included */ if (!ctk_object->advanced_mode && @@ -2036,11 +2038,10 @@ GtkTextBuffer *ctk_display_config_create_help(GtkTextTagTable *table, ctk_help_para(b, &i, __selected_item_help); ctk_help_para(b, &i, ""); - ctk_help_heading(b, &i, "Display Section"); - ctk_help_para(b, &i, "This section shows information and configuration " - "settings for the currently selected display device."); - ctk_help_heading(b, &i, "Model"); - ctk_help_para(b, &i, "The Model name is the name of the display device."); + ctk_help_heading(b, &i, "Display Options"); + ctk_help_para(b, &i, "The following options are available when a display " + "device is selected in the Selection drop-down to configure " + "the settings for that display device."); ctk_help_heading(b, &i, "Resolution"); ctk_help_para(b, &i, __dpy_resolution_mnu_help); ctk_help_heading(b, &i, "Refresh"); @@ -2064,9 +2065,10 @@ GtkTextBuffer *ctk_display_config_create_help(GtkTextTagTable *table, ctk_help_para(b, &i, ""); - ctk_help_heading(b, &i, "X Screen Section"); - ctk_help_para(b, &i, "This section shows information and configuration " - "settings for the currently selected X screen."); + ctk_help_heading(b, &i, "X Screen Options"); + ctk_help_para(b, &i, "The following options are available when an X " + "screen is selected in the Selection drop-down to configure " + "the settings for that X screen."); ctk_help_heading(b, &i, "Virtual Size"); ctk_help_para(b, &i, "%s The Virtual screen size must be at least " "304x200, and the width must be a multiple of 8.", diff --git a/src/gtk+-2.x/ctkdisplaydevice-tv.c b/src/gtk+-2.x/ctkdisplaydevice-tv.c deleted file mode 100644 index c7310dd..0000000 --- a/src/gtk+-2.x/ctkdisplaydevice-tv.c +++ /dev/null @@ -1,929 +0,0 @@ -/* - * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix - * and Linux systems. - * - * Copyright (C) 2004 NVIDIA Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses>. - */ - -/* - * The TV DisplayDevice widget provides a way to adjust TV settings. - */ - -#include <gtk/gtk.h> -#include <NvCtrlAttributes.h> - -#include "ctkbanner.h" - -#include "ctkdisplaydevice-tv.h" - -#include "ctkimagesliders.h" -#include "ctkedid.h" -#include "ctkconfig.h" -#include "ctkhelp.h" -#include "ctkscale.h" -#include "ctkutils.h" -#include <stdio.h> -#define FRAME_PADDING 5 - - -static const char* __tv_overscan_help = "The TV Overscan slider adjusts how " -"large the image is on the TV."; - -static const char* __tv_flicker_filter_help = "The TV Flicker Filter slider " -"adjusts how much flicker filter is applied to the TV signal."; - -static const char* __tv_brightness_help = "The TV Brightness slider adjusts " -"the brightness of the TV image."; - -static const char* __tv_hue_help = "The TV Brightness slider adjusts " -"the hue of the TV image."; - -static const char* __tv_contrast_help = "The TV Brightness slider adjusts " -"the contrast of the TV image."; - -static const char* __tv_saturation_help = "The TV Brightness slider adjusts " -"the saturation of the TV image."; - -static const char* __tv_refresh_rate_help = "The refresh rate displays the " -"rate at which the screen is currently refreshing the image."; - -static const char* __tv_encoder_name_help = "The TV Encoder name displays " -"the name of TV Encoder."; - -/* local prototypes */ - -static void ctk_display_device_tv_class_init(CtkDisplayDeviceTvClass *); -static void ctk_display_device_tv_finalize(GObject *); - -static GtkWidget * add_scale(CtkDisplayDeviceTv *ctk_display_device_tv, - int attribute, char *name, const char *help); - -static void adjustment_value_changed(GtkAdjustment *adjustment, - gpointer user_data); - -static void reset_button_clicked(GtkButton *button, gpointer user_data); - -static void value_received(GtkObject *object, gpointer arg1, - gpointer user_data); - -static void ctk_display_device_tv_setup(CtkDisplayDeviceTv - *ctk_display_device_tv); - -static void tv_info_setup(CtkDisplayDeviceTv *ctk_display_device_tv); - -static void enabled_displays_received(GtkObject *object, gpointer arg1, - gpointer user_data); -static void info_update_received(GtkObject *object, gpointer arg1, - gpointer user_data); - - -GType ctk_display_device_tv_get_type(void) -{ - static GType ctk_display_device_tv_type = 0; - - if (!ctk_display_device_tv_type) { - static const GTypeInfo ctk_display_device_tv_info = { - sizeof (CtkDisplayDeviceTvClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ctk_display_device_tv_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (CtkDisplayDeviceTv), - 0, /* n_preallocs */ - NULL, /* instance_init */ - NULL /* value_table */ - }; - - ctk_display_device_tv_type = g_type_register_static (GTK_TYPE_VBOX, - "CtkDisplayDeviceTv", &ctk_display_device_tv_info, 0); - } - - return ctk_display_device_tv_type; -} - -static void ctk_display_device_tv_class_init( - CtkDisplayDeviceTvClass *ctk_display_device_tv_class -) -{ - GObjectClass *gobject_class = (GObjectClass *)ctk_display_device_tv_class; - gobject_class->finalize = ctk_display_device_tv_finalize; -} - -static void ctk_display_device_tv_finalize( - GObject *object -) -{ - CtkDisplayDeviceTv *ctk_display_device_tv = CTK_DISPLAY_DEVICE_TV(object); - g_free(ctk_display_device_tv->name); - g_signal_handlers_disconnect_matched(ctk_display_device_tv->ctk_event, - G_SIGNAL_MATCH_DATA, - 0, - 0, - NULL, - NULL, - (gpointer) ctk_display_device_tv); -} - - -/* - * ctk_display_device_tv_new() - constructor for the TV display - * device page. - */ - -GtkWidget* ctk_display_device_tv_new(NvCtrlAttributeHandle *handle, - CtkConfig *ctk_config, - CtkEvent *ctk_event, - char *name) -{ - GObject *object; - CtkDisplayDeviceTv *ctk_display_device_tv; - GtkWidget *banner; - GtkWidget *frame; - GtkWidget *eventbox; - GtkWidget *tmpbox; - GtkWidget *hbox; - GtkWidget *alignment; - - - object = g_object_new(CTK_TYPE_DISPLAY_DEVICE_TV, NULL); - if (!object) return NULL; - - ctk_display_device_tv = CTK_DISPLAY_DEVICE_TV(object); - ctk_display_device_tv->handle = handle; - ctk_display_device_tv->ctk_config = ctk_config; - ctk_display_device_tv->ctk_event = ctk_event; - ctk_display_device_tv->name = g_strdup(name); - - gtk_box_set_spacing(GTK_BOX(object), 10); - - /* banner */ - - banner = ctk_banner_image_new(BANNER_ARTWORK_TV); - gtk_box_pack_start(GTK_BOX(object), banner, FALSE, FALSE, 0); - - /* Information */ - - frame = gtk_frame_new(NULL); - gtk_box_pack_start(GTK_BOX(object), frame, FALSE, FALSE, 0); - ctk_display_device_tv->info_frame = frame; - - hbox = gtk_hbox_new(FALSE, FRAME_PADDING); - gtk_container_set_border_width(GTK_CONTAINER(hbox), FRAME_PADDING); - gtk_container_add(GTK_CONTAINER(frame), hbox); - - tmpbox = gtk_vbox_new(FALSE, 5); - gtk_container_add(GTK_CONTAINER(hbox), tmpbox); - - ctk_display_device_tv->txt_encoder_name = gtk_label_new(""); - ctk_display_device_tv->txt_refresh_rate = gtk_label_new(""); - - /* pack the Refresh Rate Label */ - { - typedef struct { - GtkWidget *label; - GtkWidget *txt; - const gchar *tooltip; - } TextLineInfo; - - TextLineInfo lines[] = { - { - gtk_label_new("TV Encoder:"), - ctk_display_device_tv->txt_encoder_name, - __tv_encoder_name_help, - }, - { - gtk_label_new("TV Refresh Rate:"), - ctk_display_device_tv->txt_refresh_rate, - __tv_refresh_rate_help, - }, - { NULL, NULL, NULL } - }; - - int i; - GtkRequisition req; - int max_width; - - /* Compute max width of lables and setup text alignments */ - max_width = 0; - for (i = 0; lines[i].label; i++) { - gtk_misc_set_alignment(GTK_MISC(lines[i].label), 0.0f, 0.5f); - gtk_misc_set_alignment(GTK_MISC(lines[i].txt), 0.0f, 0.5f); - gtk_widget_size_request(lines[i].label, &req); - - if (max_width < req.width) { - max_width = req.width; - } - } - - /* Pack labels */ - for (i = 0; lines[i].label; i++) { - GtkWidget *tmphbox; - - /* Add separators */ - - if (i == 1) { - GtkWidget *separator = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(tmpbox), separator, - FALSE, FALSE, 0); - } - /* Set the label's width */ - gtk_widget_set_size_request(lines[i].label, max_width, -1); - /* add the widgets for this line */ - tmphbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(tmphbox), lines[i].label, - FALSE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(tmphbox), lines[i].txt, - FALSE, TRUE, 5); - - /* Include tooltips */ - if (!lines[i].tooltip) { - gtk_box_pack_start(GTK_BOX(tmpbox), tmphbox, FALSE, FALSE, 0); - } else { - eventbox = gtk_event_box_new(); - gtk_container_add(GTK_CONTAINER(eventbox), tmphbox); - ctk_config_set_tooltip(ctk_config, eventbox, lines[i].tooltip); - gtk_box_pack_start(GTK_BOX(tmpbox), eventbox, FALSE, FALSE, 0); - } - } - } - - /* NV_CTRL_REFRESH_RATE */ - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_REFRESH_RATE), - G_CALLBACK(info_update_received), - (gpointer) ctk_display_device_tv); - - - /* NV_CTRL_TV_OVERSCAN */ - - ctk_display_device_tv->overscan = - add_scale(ctk_display_device_tv, NV_CTRL_TV_OVERSCAN, - "TV OverScan", __tv_overscan_help); - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_TV_OVERSCAN), - G_CALLBACK(value_received), - (gpointer) ctk_display_device_tv); - - /* NV_CTRL_TV_FLICKER_FILTER */ - - ctk_display_device_tv->flicker_filter = - add_scale(ctk_display_device_tv, NV_CTRL_TV_FLICKER_FILTER, - "TV Flicker Filter", __tv_flicker_filter_help); - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_TV_FLICKER_FILTER), - G_CALLBACK(value_received), - (gpointer) ctk_display_device_tv); - - /* NV_CTRL_TV_BRIGHTNESS */ - - ctk_display_device_tv->brightness = - add_scale(ctk_display_device_tv, NV_CTRL_TV_BRIGHTNESS, - "TV Brightness", __tv_brightness_help); - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_TV_BRIGHTNESS), - G_CALLBACK(value_received), - (gpointer) ctk_display_device_tv); - - /* NV_CTRL_TV_HUE */ - - ctk_display_device_tv->hue = - add_scale(ctk_display_device_tv, NV_CTRL_TV_HUE, - "TV Hue", __tv_hue_help); - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_TV_HUE), - G_CALLBACK(value_received), - (gpointer) ctk_display_device_tv); - - /* NV_CTRL_TV_CONTRAST */ - - ctk_display_device_tv->contrast = - add_scale(ctk_display_device_tv, NV_CTRL_TV_CONTRAST, - "TV Contrast", __tv_contrast_help); - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_TV_CONTRAST), - G_CALLBACK(value_received), - (gpointer) ctk_display_device_tv); - - /* NV_CTRL_TV_SATURATION */ - - ctk_display_device_tv->saturation = - add_scale(ctk_display_device_tv, NV_CTRL_TV_SATURATION, - "TV Saturation", __tv_saturation_help); - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_TV_SATURATION), - G_CALLBACK(value_received), - (gpointer) ctk_display_device_tv); - - /* Create the reset button here so it can be used by the image sliders */ - - ctk_display_device_tv->reset_button = - gtk_button_new_with_label("Reset TV Hardware Defaults"); - - /* create and pack the image sliders */ - - ctk_display_device_tv->image_sliders = - ctk_image_sliders_new(handle, ctk_config, ctk_event, - ctk_display_device_tv->reset_button, - name); - if (ctk_display_device_tv->image_sliders) { - gtk_box_pack_start(GTK_BOX(object), - ctk_display_device_tv->image_sliders, - FALSE, FALSE, 0); - } - - /* reset button */ - - g_signal_connect(G_OBJECT(ctk_display_device_tv->reset_button), "clicked", - G_CALLBACK(reset_button_clicked), - (gpointer) ctk_display_device_tv); - - alignment = gtk_alignment_new(1, 1, 0, 0); - gtk_container_add(GTK_CONTAINER(alignment), - ctk_display_device_tv->reset_button); - gtk_box_pack_end(GTK_BOX(object), alignment, TRUE, TRUE, 0); - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_TV_RESET_SETTINGS), - G_CALLBACK(value_received), - (gpointer) ctk_display_device_tv); - - ctk_config_set_tooltip(ctk_config, ctk_display_device_tv->reset_button, - ctk_help_create_reset_hardware_defaults_text("TV", name)); - - /* EDID button box */ - - ctk_display_device_tv->edid = - ctk_edid_new(ctk_display_device_tv->handle, - ctk_display_device_tv->ctk_config, - ctk_display_device_tv->ctk_event, - ctk_display_device_tv->name); - - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(object), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), ctk_display_device_tv->edid, - TRUE, TRUE, 0); - - /* finally, display the widget */ - - gtk_widget_show_all(GTK_WIDGET(object)); - - /* update the GUI */ - - update_display_enabled_flag(ctk_display_device_tv->handle, - &ctk_display_device_tv->display_enabled); - - ctk_display_device_tv_setup(ctk_display_device_tv); - - /* handle enable/disable events on the display device */ - - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_ENABLED_DISPLAYS), - G_CALLBACK(enabled_displays_received), - (gpointer) ctk_display_device_tv); - - return GTK_WIDGET(object); - -} /* ctk_display_device_tv_new() */ - - - -/* - * Returns whether or not the scale is active - */ - -static gint get_scale_active(CtkScale *scale) -{ - GtkAdjustment *adj = scale->gtk_adjustment; - - return - GPOINTER_TO_INT(g_object_get_data(G_OBJECT(adj), "attribute active")); - -} /* get_scale_active() */ - - - -/* - * add_scale() - if the specified attribute exists and we can - * query its valid values, create a new scale widget and pack it - * in the ctk_display_device_tv - */ - -static GtkWidget * add_scale(CtkDisplayDeviceTv *ctk_display_device_tv, - int attribute, char *name, const char *help) -{ - GtkObject *adj; - GtkWidget *scale; - - - adj = gtk_adjustment_new(0, 0, 10, 1, 1, 0); - - g_object_set_data(G_OBJECT(adj), "attribute", - GINT_TO_POINTER(attribute)); - - g_object_set_data(G_OBJECT(adj), "attribute name", name); - - g_object_set_data(G_OBJECT(adj), "attribute active", - GINT_TO_POINTER(0)); - - g_signal_connect(G_OBJECT(adj), "value_changed", - G_CALLBACK(adjustment_value_changed), - (gpointer) ctk_display_device_tv); - - scale = ctk_scale_new(GTK_ADJUSTMENT(adj), name, - ctk_display_device_tv->ctk_config, - G_TYPE_INT); - - if (help) { - ctk_config_set_tooltip(ctk_display_device_tv->ctk_config, - CTK_SCALE_TOOLTIP_WIDGET(scale), help); - } - - gtk_box_pack_start(GTK_BOX(ctk_display_device_tv), scale, - FALSE, FALSE, 0); - - return scale; - -} /* add_scale() */ - - - -/* - * post_adjustment_value_changed() - helper function for - * adjustment_value_changed() and value_changed(); this does whatever - * work is necessary after the adjustment has been updated -- - * currently, this just means posting a statusbar message. - */ - -static void post_adjustment_value_changed(GtkAdjustment *adjustment, - CtkDisplayDeviceTv - *ctk_display_device_tv, - gint value) -{ - char *name = g_object_get_data(G_OBJECT(adjustment), "attribute name"); - - gtk_widget_set_sensitive(ctk_display_device_tv->reset_button, TRUE); - - ctk_config_statusbar_message(ctk_display_device_tv->ctk_config, - "%s set to %d.", name, value); - -} /* post_adjustment_value_changed() */ - - - -/* - * adjustment_value_changed() - callback when any of the adjustments - * in the CtkDisplayDeviceTv are changed: get the new value from the - * adjustment, send it to the X server, and do any post-adjustment - * work. - */ - -static void adjustment_value_changed(GtkAdjustment *adjustment, - gpointer user_data) -{ - CtkDisplayDeviceTv *ctk_display_device_tv = - CTK_DISPLAY_DEVICE_TV(user_data); - - gint value; - gint attribute; - - value = (gint) gtk_adjustment_get_value(adjustment); - - user_data = g_object_get_data(G_OBJECT(adjustment), "attribute"); - attribute = GPOINTER_TO_INT(user_data); - - NvCtrlSetAttribute(ctk_display_device_tv->handle, - attribute, (int) value); - - post_adjustment_value_changed(adjustment, ctk_display_device_tv, value); - -} /* adjustment_value_changed() */ - - - -/* - * reset_slider() - if the adjustment exists, query its current value - * from the X server, and update the adjustment with the retrieved - * value. - */ - -static void reset_slider(CtkDisplayDeviceTv *ctk_display_device_tv, - GtkWidget *scale) -{ - GtkAdjustment *adj; - gint attribute; - ReturnStatus ret; - gint val; - - adj = CTK_SCALE(scale)->gtk_adjustment; - - if (!adj) return; - - if (!get_scale_active(CTK_SCALE(scale))) return; - - attribute = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(adj), "attribute")); - - ret = NvCtrlGetAttribute(ctk_display_device_tv->handle, attribute, &val); - if (ret != NvCtrlSuccess) return; - - g_signal_handlers_block_matched(adj, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, - G_CALLBACK(adjustment_value_changed), - NULL); - - gtk_adjustment_set_value(GTK_ADJUSTMENT(adj), val); - - g_signal_handlers_unblock_matched(adj, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, - G_CALLBACK(adjustment_value_changed), - NULL); -} /* reset_slider() */ - - - -/* - * reset_sliders() - reset all the adjustments and post a statusbar - * message. - */ - -static void reset_sliders(CtkDisplayDeviceTv *ctk_display_device_tv) -{ - /* retrieve all existing settings */ - - reset_slider(ctk_display_device_tv, ctk_display_device_tv->overscan); - reset_slider(ctk_display_device_tv, ctk_display_device_tv->flicker_filter); - reset_slider(ctk_display_device_tv, ctk_display_device_tv->brightness); - reset_slider(ctk_display_device_tv, ctk_display_device_tv->hue); - reset_slider(ctk_display_device_tv, ctk_display_device_tv->contrast); - reset_slider(ctk_display_device_tv, ctk_display_device_tv->saturation); - - ctk_config_statusbar_message(ctk_display_device_tv->ctk_config, - "Reset TV Hardware defaults for %s.", - ctk_display_device_tv->name); -} /* reset_sliders() */ - - - -/* - * reset_button_clicked() - called when the "reset defaults" button is - * pressed; tells the X server to reset its defaults, and then resets - * all the sliders. - */ - -static void reset_button_clicked(GtkButton *button, gpointer user_data) -{ - CtkDisplayDeviceTv *ctk_display_device_tv = - CTK_DISPLAY_DEVICE_TV(user_data); - gint active = 0; - - - /* Disable the reset button here and allow the controls below to (re)enable - * it if need be,. - */ - gtk_widget_set_sensitive(ctk_display_device_tv->reset_button, FALSE); - - /* Make sure something is active */ - - active = - (get_scale_active(CTK_SCALE(ctk_display_device_tv->overscan)) || - get_scale_active(CTK_SCALE(ctk_display_device_tv->flicker_filter)) || - get_scale_active(CTK_SCALE(ctk_display_device_tv->brightness)) || - get_scale_active(CTK_SCALE(ctk_display_device_tv->hue)) || - get_scale_active(CTK_SCALE(ctk_display_device_tv->contrast)) || - get_scale_active(CTK_SCALE(ctk_display_device_tv->saturation))); - - if (active) { - NvCtrlSetAttribute(ctk_display_device_tv->handle, - NV_CTRL_TV_RESET_SETTINGS, 1); - } - - ctk_image_sliders_reset - (CTK_IMAGE_SLIDERS(ctk_display_device_tv->image_sliders)); - - reset_sliders(ctk_display_device_tv); - -} /* reset_button_clicked() */ - - - -/* - * value_received() - callback function for changed TV settings; this - * is called when we receive an event indicating that another - * NV-CONTROL client changed any of the settings that we care about. - */ - -static void value_received(GtkObject *object, gpointer arg1, - gpointer user_data) -{ - CtkEventStruct *event_struct; - CtkDisplayDeviceTv *ctk_display_device_tv = - CTK_DISPLAY_DEVICE_TV(user_data); - - GtkAdjustment *adj; - GtkWidget *scale; - gint val; - - event_struct = (CtkEventStruct *) arg1; - - switch (event_struct->attribute) { - case NV_CTRL_TV_OVERSCAN: - scale = ctk_display_device_tv->overscan; - break; - case NV_CTRL_TV_FLICKER_FILTER: - scale = ctk_display_device_tv->flicker_filter; - break; - case NV_CTRL_TV_BRIGHTNESS: - scale = ctk_display_device_tv->brightness; - break; - case NV_CTRL_TV_HUE: - scale = ctk_display_device_tv->hue; - break; - case NV_CTRL_TV_CONTRAST: - scale = ctk_display_device_tv->contrast; - break; - case NV_CTRL_TV_SATURATION: - scale = ctk_display_device_tv->saturation; - break; - case NV_CTRL_TV_RESET_SETTINGS: - reset_sliders(ctk_display_device_tv); - ctk_display_device_tv_setup(ctk_display_device_tv); - return; - default: - return; - } - - adj = CTK_SCALE(scale)->gtk_adjustment; - val = gtk_adjustment_get_value(GTK_ADJUSTMENT(adj)); - - if (val != event_struct->value) { - - val = event_struct->value; - - g_signal_handlers_block_by_func(adj, adjustment_value_changed, - ctk_display_device_tv); - - gtk_adjustment_set_value(GTK_ADJUSTMENT(adj), val); - - post_adjustment_value_changed(GTK_ADJUSTMENT(adj), - ctk_display_device_tv, val); - - g_signal_handlers_unblock_by_func(adj, adjustment_value_changed, - ctk_display_device_tv); - } -} /* value_received() */ - - - -/* - * ctk_display_device_tv_create_help() - generate the help TextBuffer - * for the TV DisplayDevice. - */ - -GtkTextBuffer *ctk_display_device_tv_create_help(GtkTextTagTable *table, - CtkDisplayDeviceTv - *ctk_display_device_tv) -{ - GtkTextIter i; - GtkTextBuffer *b; - GtkTooltipsData *td; - - b = gtk_text_buffer_new(table); - - gtk_text_buffer_get_iter_at_offset(b, &i, 0); - - ctk_help_title(b, &i, "%s Help", ctk_display_device_tv->name); - - ctk_help_heading(b, &i, "TV Overscan"); - ctk_help_para(b, &i, __tv_overscan_help); - - ctk_help_heading(b, &i, "TV Flicker Filter"); - ctk_help_para(b, &i, __tv_flicker_filter_help); - - ctk_help_heading(b, &i, "TV Brightness"); - ctk_help_para(b, &i, __tv_brightness_help); - - ctk_help_heading(b, &i, "TV Hue"); - ctk_help_para(b, &i, __tv_hue_help); - - ctk_help_heading(b, &i, "TV Contrast"); - ctk_help_para(b, &i, __tv_contrast_help); - - ctk_help_heading(b, &i, "TV Saturation"); - ctk_help_para(b, &i, __tv_saturation_help); - - ctk_help_heading(b, &i, "TV Encoder name"); - ctk_help_para(b, &i, __tv_encoder_name_help); - - ctk_help_heading(b, &i, "TV Refresh rate"); - ctk_help_para(b, &i, __tv_refresh_rate_help); - - add_image_sliders_help - (CTK_IMAGE_SLIDERS(ctk_display_device_tv->image_sliders), b, &i); - - add_acquire_edid_help(b, &i); - - td = gtk_tooltips_data_get(GTK_WIDGET(ctk_display_device_tv->reset_button)); - ctk_help_reset_hardware_defaults (b, &i, td->tip_text); - - ctk_help_finish(b); - - return b; - -} /* ctk_display_device_tv_create_help() */ - - -/* Update GUI state of the scale to reflect current settings - * on the X Driver. - */ - -static void setup_scale(CtkDisplayDeviceTv *ctk_display_device_tv, - int attribute, GtkWidget *scale) -{ - ReturnStatus ret0, ret1; - NVCTRLAttributeValidValuesRec valid; - NvCtrlAttributeHandle *handle = ctk_display_device_tv->handle; - int val; - GtkAdjustment *adj = CTK_SCALE(scale)->gtk_adjustment; - - - /* Read settings from X server */ - ret0 = NvCtrlGetValidAttributeValues(handle, attribute, &valid); - - ret1 = NvCtrlGetAttribute(handle, attribute, &val); - - if ((ret0 == NvCtrlSuccess) && (ret1 == NvCtrlSuccess) && - (valid.type == ATTRIBUTE_TYPE_RANGE)) { - - g_signal_handlers_block_by_func(adj, adjustment_value_changed, - ctk_display_device_tv); - - adj->lower = valid.u.range.min; - adj->upper = valid.u.range.max; - gtk_adjustment_changed(GTK_ADJUSTMENT(adj)); - - gtk_adjustment_set_value(GTK_ADJUSTMENT(adj), val); - - g_signal_handlers_unblock_by_func(adj, adjustment_value_changed, - ctk_display_device_tv); - - g_object_set_data(G_OBJECT(adj), "attribute active", - GINT_TO_POINTER(1)); - - gtk_widget_set_sensitive(scale, TRUE); - gtk_widget_show(scale); - } else { - - g_object_set_data(G_OBJECT(adj), "attribute active", - GINT_TO_POINTER(0)); - - gtk_widget_set_sensitive(scale, FALSE); - gtk_widget_hide(scale); - } - - -} /* setup_scale() */ - - - -/* - * Updates the display device TV page to reflect the current - * configuration of the display device. - */ -static void ctk_display_device_tv_setup(CtkDisplayDeviceTv - *ctk_display_device_tv) -{ - /* Disable the reset button here and allow the controls below to (re)enable - * it if need be,. - */ - gtk_widget_set_sensitive(ctk_display_device_tv->reset_button, FALSE); - - - /* Update info */ - - tv_info_setup(ctk_display_device_tv); - - /* update acquire EDID button */ - - ctk_edid_setup(CTK_EDID(ctk_display_device_tv->edid)); - - - /* Update controls */ - - /* NV_CTRL_TV_OVERSCAN */ - - setup_scale(ctk_display_device_tv, NV_CTRL_TV_OVERSCAN, - ctk_display_device_tv->overscan); - - /* NV_CTRL_TV_FLICKER_FILTER */ - - setup_scale(ctk_display_device_tv, NV_CTRL_TV_FLICKER_FILTER, - ctk_display_device_tv->flicker_filter); - - /* NV_CTRL_TV_BRIGHTNESS */ - - setup_scale(ctk_display_device_tv, NV_CTRL_TV_BRIGHTNESS, - ctk_display_device_tv->brightness); - - /* NV_CTRL_TV_HUE */ - - setup_scale(ctk_display_device_tv, NV_CTRL_TV_HUE, - ctk_display_device_tv->hue); - - /* NV_CTRL_TV_CONTRAST */ - - setup_scale(ctk_display_device_tv, NV_CTRL_TV_CONTRAST, - ctk_display_device_tv->contrast); - - /* NV_CTRL_TV_SATURATION */ - - setup_scale(ctk_display_device_tv, NV_CTRL_TV_SATURATION, - ctk_display_device_tv->saturation); - - ctk_image_sliders_setup - (CTK_IMAGE_SLIDERS(ctk_display_device_tv->image_sliders)); - -} /* ctk_display_device_tv_setup() */ - -static void tv_info_setup(CtkDisplayDeviceTv *ctk_display_device_tv) -{ - ReturnStatus ret; - int val; - char *str; - - /* NV_CTRL_STRING_TV_ENCODER_NAME */ - - ret = NvCtrlGetStringDisplayAttribute(ctk_display_device_tv->handle, 0, - NV_CTRL_STRING_TV_ENCODER_NAME, - &str); - if (ret == NvCtrlSuccess) { - gtk_label_set_text(GTK_LABEL(ctk_display_device_tv->txt_encoder_name), - str); - gtk_widget_show(ctk_display_device_tv->info_frame); - } else { - gtk_widget_hide(ctk_display_device_tv->info_frame); - } - - /* NV_CTRL_REFRESH_RATE */ - - ret = NvCtrlGetAttribute(ctk_display_device_tv->handle, - NV_CTRL_REFRESH_RATE, - &val); - if (ret == NvCtrlSuccess) { - float fvalue = ((float)(val)) / 100.0f; - snprintf(str, 32, "%.2f Hz", fvalue); - gtk_label_set_text(GTK_LABEL(ctk_display_device_tv->txt_refresh_rate), - str); - } else { - gtk_label_set_text - (GTK_LABEL(ctk_display_device_tv->txt_refresh_rate), - "Unknown"); - } -} - -/* - * When the list of enabled displays on the GPU changes, - * this page should disable/enable access based on whether - * or not the display device is enabled. - */ -static void enabled_displays_received(GtkObject *object, gpointer arg1, - gpointer user_data) -{ - 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_display_device_tv_setup(ctk_object); - -} /* enabled_displays_received() */ - -/* - * When GPU scaling activation and/or TV resolution changes occur, - * we should update the GUI to reflect the current state. - */ -static void info_update_received(GtkObject *object, gpointer arg1, - gpointer user_data) -{ - CtkDisplayDeviceTv *ctk_object = CTK_DISPLAY_DEVICE_TV(user_data); - - tv_info_setup(ctk_object); -} diff --git a/src/gtk+-2.x/ctkdisplaydevice-tv.h b/src/gtk+-2.x/ctkdisplaydevice-tv.h deleted file mode 100644 index 65742ee..0000000 --- a/src/gtk+-2.x/ctkdisplaydevice-tv.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix - * and Linux systems. - * - * Copyright (C) 2004 NVIDIA Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses>. - */ - -#ifndef __CTK_DISPLAYDEVICE_TV_H__ -#define __CTK_DISPLAYDEVICE_TV_H__ - -#include "ctkevent.h" -#include "ctkconfig.h" - -G_BEGIN_DECLS - -#define CTK_TYPE_DISPLAY_DEVICE_TV (ctk_display_device_tv_get_type()) - -#define CTK_DISPLAY_DEVICE_TV(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), CTK_TYPE_DISPLAY_DEVICE_TV, \ - CtkDisplayDeviceTv)) - -#define CTK_DISPLAY_DEVICE_TV_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), CTK_TYPE_DISPLAY_DEVICE_TV, \ - CtkDisplayDeviceTvClass)) - -#define CTK_IS_DISPLAY_DEVICE_TV(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CTK_TYPE_DISPLAY_DEVICE_TV)) - -#define CTK_IS_DISPLAY_DEVICE_TV_CLASS(class) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), CTK_TYPE_DISPLAY_DEVICE_TV)) - -#define CTK_DISPLAY_DEVICE_TV_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), CTK_TYPE_DISPLAY_DEVICE_TV, \ - CtkDisplayDeviceTvClass)) - - -typedef struct _CtkDisplayDeviceTv CtkDisplayDeviceTv; -typedef struct _CtkDisplayDeviceTvClass CtkDisplayDeviceTvClass; - -struct _CtkDisplayDeviceTv -{ - GtkVBox parent; - CtkConfig *ctk_config; - CtkEvent *ctk_event; - - NvCtrlAttributeHandle *handle; - gboolean display_enabled; - char *name; - - GtkWidget *info_frame; - GtkWidget *txt_encoder_name; - - GtkWidget *overscan; - GtkWidget *flicker_filter; - - GtkWidget *brightness; - GtkWidget *hue; - GtkWidget *contrast; - GtkWidget *saturation; - GtkWidget *txt_refresh_rate; - - GtkWidget *image_sliders; - - GtkWidget *edid; - GtkWidget *reset_button; -}; - -struct _CtkDisplayDeviceTvClass -{ - GtkVBoxClass parent_class; -}; - -GType ctk_display_device_tv_get_type (void) G_GNUC_CONST; -GtkWidget* ctk_display_device_tv_new (NvCtrlAttributeHandle *, - CtkConfig *, CtkEvent *, - char *); - -GtkTextBuffer *ctk_display_device_tv_create_help(GtkTextTagTable *, - CtkDisplayDeviceTv *); - -G_END_DECLS - -#endif /* __CTK_DISPLAYDEVICE_TV_H__ */ diff --git a/src/gtk+-2.x/ctkdisplaydevice.c b/src/gtk+-2.x/ctkdisplaydevice.c index 40a3ea4..8ee692b 100644 --- a/src/gtk+-2.x/ctkdisplaydevice.c +++ b/src/gtk+-2.x/ctkdisplaydevice.c @@ -2,7 +2,7 @@ * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix * and Linux systems. * - * Copyright (C) 2004 NVIDIA Corporation. + * Copyright (C) 2004,2012 NVIDIA Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -23,8 +23,6 @@ #include <stdio.h> #include <stdlib.h> -#include "common-utils.h" - #include "ctkbanner.h" #include "ctkdisplaydevice.h" @@ -56,21 +54,23 @@ static void callback_link_changed(GtkObject *object, gpointer arg1, static void callback_refresh_rate_changed(GtkObject *object, gpointer arg1, gpointer user_data); -static void update_chip_info(InfoEntry *entry); -static void update_signal_info(InfoEntry *entry); -static void update_link_info(InfoEntry *entry); -static void update_native_resolution(InfoEntry *entry); -static void update_refresh_rate(InfoEntry *entry); +static gboolean update_tv_encoder_info(InfoEntry *entry); +static gboolean update_chip_info(InfoEntry *entry); +static gboolean update_signal_info(InfoEntry *entry); +static gboolean update_link_info(InfoEntry *entry); +static gboolean update_native_resolution(InfoEntry *entry); +static gboolean update_refresh_rate(InfoEntry *entry); -static void register_link_events(InfoEntry *entry); -static void unregister_link_events(InfoEntry *entry); -static void register_refresh_rate_events(InfoEntry *entry); -static void unregister_refresh_rate_events(InfoEntry *entry); +static gboolean register_link_events(InfoEntry *entry); +static gboolean unregister_link_events(InfoEntry *entry); +static gboolean register_refresh_rate_events(InfoEntry *entry); +static gboolean unregister_refresh_rate_events(InfoEntry *entry); static void add_color_correction_tab(CtkDisplayDevice *ctk_object, CtkConfig *ctk_config, CtkEvent *ctk_event, - GtkWidget *notebook); + GtkWidget *notebook, + ParsedAttribute *p); #define FRAME_PADDING 5 @@ -78,6 +78,9 @@ static const char *__info_help = "This section describes basic information about the connection to the display " "device."; +static const char* __tv_encoder_name_help = +"The TV Encoder name displays the name of the TV Encoder."; + static const char *__info_chip_location_help = "Report whether the display device is driven by the on-chip controller " "(internal), or a separate controller chip elsewhere on the graphics " @@ -101,18 +104,25 @@ static const char * __refresh_rate_help = "The refresh rate displays the rate at which the screen is currently " "refreshing the image."; -typedef void (*InfoEntryFunc)(InfoEntry *entry); +typedef gboolean (*InfoEntryFunc)(InfoEntry *entry); typedef struct { const char *str; const gchar **tooltip; - InfoEntryFunc update_func; + InfoEntryFunc update_func; /* return FALSE if not present */ InfoEntryFunc register_events_func; InfoEntryFunc unregister_events_func; } InfoEntryData; static InfoEntryData __info_entry_data[] = { { + "TV Encoder:", + &__tv_encoder_name_help, + update_tv_encoder_info, + NULL, + NULL, + }, + { "Chip Location", &__info_chip_location_help, update_chip_info, @@ -220,7 +230,8 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle, CtkEvent *ctk_event, CtkEvent *ctk_event_gpu, char *name, - char *typeBaseName) + char *typeBaseName, + ParsedAttribute *p) { GObject *object; CtkDisplayDevice *ctk_object; @@ -415,7 +426,7 @@ GtkWidget* ctk_display_device_new(NvCtrlAttributeHandle *handle, /* add the color correction tab if RandR is available */ - add_color_correction_tab(ctk_object, ctk_config, ctk_event, notebook); + add_color_correction_tab(ctk_object, ctk_config, ctk_event, notebook, p); /* Update the GUI */ @@ -499,9 +510,12 @@ GtkTextBuffer *ctk_display_device_create_help(GtkTextTagTable *table, for (j = 0; j < ARRAY_LEN(__info_entry_data); j++) { InfoEntryData *entryData = __info_entry_data+j; + InfoEntry *entry = ctk_object->info_entries+j; - ctk_help_term(b, &i, entryData->str); - ctk_help_para(b, &i, *entryData->tooltip); + if (entry->present) { + ctk_help_term(b, &i, entryData->str); + ctk_help_para(b, &i, *entryData->tooltip); + } } add_acquire_edid_help(b, &i); @@ -525,10 +539,28 @@ GtkTextBuffer *ctk_display_device_create_help(GtkTextTagTable *table, } /* ctk_display_device_create_help() */ +static gboolean update_tv_encoder_info(InfoEntry *entry) +{ + CtkDisplayDevice *ctk_object = entry->ctk_object; + ReturnStatus ret; + char *str; + + ret = NvCtrlGetStringDisplayAttribute(ctk_object->handle, 0, + NV_CTRL_STRING_TV_ENCODER_NAME, &str); + if (ret != NvCtrlSuccess) { + return FALSE; + } + + gtk_label_set_text(GTK_LABEL(entry->txt), str); + + XFree(str); + + return TRUE; +} -static void update_chip_info(InfoEntry *entry) +static gboolean update_chip_info(InfoEntry *entry) { CtkDisplayDevice *ctk_object = entry->ctk_object; ReturnStatus ret; @@ -538,8 +570,7 @@ static void update_chip_info(InfoEntry *entry) ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_FLATPANEL_CHIP_LOCATION, &val); if (ret != NvCtrlSuccess) { - gtk_widget_hide(entry->hbox); - return; + return FALSE; } switch (val) { @@ -555,12 +586,13 @@ static void update_chip_info(InfoEntry *entry) } gtk_label_set_text(GTK_LABEL(entry->txt), str); - gtk_widget_show(entry->hbox); + + return TRUE; } -static void update_signal_info(InfoEntry *entry) +static gboolean update_signal_info(InfoEntry *entry) { CtkDisplayDevice *ctk_object = entry->ctk_object; ReturnStatus ret; @@ -570,8 +602,7 @@ static void update_signal_info(InfoEntry *entry) ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_FLATPANEL_SIGNAL, &val); if (ret != NvCtrlSuccess) { - gtk_widget_hide(entry->hbox); - return; + return FALSE; } switch (val) { @@ -590,16 +621,17 @@ static void update_signal_info(InfoEntry *entry) } gtk_label_set_text(GTK_LABEL(entry->txt), str); - gtk_widget_show(entry->hbox); ctk_object->signal_type = val; + + return TRUE; } /* NOTE: Link information is dependent on signal type, and this function * assumes the signal type is querried first. */ -static void update_link_info(InfoEntry *entry) +static gboolean update_link_info(InfoEntry *entry) { CtkDisplayDevice *ctk_object = entry->ctk_object; ReturnStatus ret; @@ -609,8 +641,7 @@ static void update_link_info(InfoEntry *entry) ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_FLATPANEL_LINK, &val); if (ret != NvCtrlSuccess) { - gtk_widget_hide(entry->hbox); - return; + return FALSE; } if (ctk_object->signal_type == NV_CTRL_FLATPANEL_SIGNAL_DISPLAYPORT) { @@ -653,12 +684,13 @@ static void update_link_info(InfoEntry *entry) } gtk_label_set_text(GTK_LABEL(entry->txt), link); - gtk_widget_show(entry->hbox); + + return TRUE; } -static void update_native_resolution(InfoEntry *entry) +static gboolean update_native_resolution(InfoEntry *entry) { CtkDisplayDevice *ctk_object = entry->ctk_object; ReturnStatus ret; @@ -668,20 +700,19 @@ static void update_native_resolution(InfoEntry *entry) ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_FLATPANEL_NATIVE_RESOLUTION, &val); if (ret != NvCtrlSuccess) { - gtk_widget_hide(entry->hbox); - return; + return FALSE; } str = g_strdup_printf("%dx%d", (val >> 16), (val & 0xFFFF)); gtk_label_set_text(GTK_LABEL(entry->txt), str); g_free(str); - gtk_widget_show(entry->hbox); + return TRUE; } -static void update_refresh_rate(InfoEntry *entry) +static gboolean update_refresh_rate(InfoEntry *entry) { CtkDisplayDevice *ctk_object = entry->ctk_object; ReturnStatus ret; @@ -691,8 +722,7 @@ static void update_refresh_rate(InfoEntry *entry) ret = NvCtrlGetAttribute(ctk_object->handle, NV_CTRL_REFRESH_RATE, &val); if (ret != NvCtrlSuccess) { - gtk_widget_hide(entry->hbox); - return; + return FALSE; } fvalue = ((float)(val)) / 100.0f; @@ -701,7 +731,7 @@ static void update_refresh_rate(InfoEntry *entry) gtk_label_set_text(GTK_LABEL(entry->txt), str); g_free(str); - gtk_widget_show(entry->hbox); + return TRUE; } @@ -721,19 +751,24 @@ static void update_device_info(CtkDisplayDevice *ctk_object) InfoEntryData *entryData = __info_entry_data+i; InfoEntry *entry = ctk_object->info_entries+i; - entryData->update_func(entry); + entry->present = entryData->update_func(entry); - if (GTK_WIDGET_VISIBLE(entry->hbox)) { + if (entry->present) { + gtk_widget_show(entry->hbox); gtk_widget_size_request(entry->label, &req); if (max_width < req.width) { max_width = req.width; } + } else { + gtk_widget_hide(entry->hbox); } } for (i = 0; i < ctk_object->num_info_entries; i++) { InfoEntry *entry = ctk_object->info_entries+i; - gtk_widget_set_size_request(entry->label, max_width, -1); + if (entry->present) { + gtk_widget_set_size_request(entry->label, max_width, -1); + } } } /* update_device_info() */ @@ -773,7 +808,7 @@ static void display_device_setup(CtkDisplayDevice *ctk_object) -static void register_link_events(InfoEntry *entry) +static gboolean register_link_events(InfoEntry *entry) { CtkDisplayDevice *ctk_object = entry->ctk_object; @@ -786,9 +821,11 @@ static void register_link_events(InfoEntry *entry) CTK_EVENT_NAME(NV_CTRL_DISPLAYPORT_LINK_RATE), G_CALLBACK(callback_link_changed), (gpointer) entry); + + return TRUE; } -static void unregister_link_events(InfoEntry *entry) +static gboolean unregister_link_events(InfoEntry *entry) { CtkDisplayDevice *ctk_object = entry->ctk_object; @@ -799,9 +836,10 @@ static void unregister_link_events(InfoEntry *entry) NULL, /* closure */ NULL, /* func */ (gpointer) entry); + return TRUE; } -static void register_refresh_rate_events(InfoEntry *entry) +static gboolean register_refresh_rate_events(InfoEntry *entry) { CtkDisplayDevice *ctk_object = entry->ctk_object; @@ -809,9 +847,10 @@ static void register_refresh_rate_events(InfoEntry *entry) CTK_EVENT_NAME(NV_CTRL_REFRESH_RATE), G_CALLBACK(callback_refresh_rate_changed), (gpointer) entry); + return TRUE; } -static void unregister_refresh_rate_events(InfoEntry *entry) +static gboolean unregister_refresh_rate_events(InfoEntry *entry) { CtkDisplayDevice *ctk_object = entry->ctk_object; @@ -822,6 +861,7 @@ static void unregister_refresh_rate_events(InfoEntry *entry) NULL, /* closure */ NULL, /* func */ (gpointer) entry); + return TRUE; } @@ -864,7 +904,8 @@ static void callback_refresh_rate_changed(GtkObject *object, gpointer arg1, static void add_color_correction_tab(CtkDisplayDevice *ctk_object, CtkConfig *ctk_config, CtkEvent *ctk_event, - GtkWidget *notebook) + GtkWidget *notebook, + ParsedAttribute *p) { ReturnStatus ret; gint val; @@ -884,7 +925,7 @@ static void add_color_correction_tab(CtkDisplayDevice *ctk_object, ctk_color_correction = ctk_color_correction_new(ctk_object->handle, ctk_config, - NULL /* ParsedAttribute*/, + p, ctk_event); if (ctk_color_correction == NULL) { return; diff --git a/src/gtk+-2.x/ctkdisplaydevice.h b/src/gtk+-2.x/ctkdisplaydevice.h index 402450f..349d17d 100644 --- a/src/gtk+-2.x/ctkdisplaydevice.h +++ b/src/gtk+-2.x/ctkdisplaydevice.h @@ -50,6 +50,7 @@ typedef struct _CtkDisplayDevice CtkDisplayDevice; typedef struct _CtkDisplayDeviceClass CtkDisplayDeviceClass; typedef struct InfoEntryRec { + gboolean present; GtkWidget *hbox; GtkWidget *label; GtkWidget *txt; @@ -90,7 +91,8 @@ struct _CtkDisplayDeviceClass GType ctk_display_device_get_type (void) G_GNUC_CONST; GtkWidget* ctk_display_device_new (NvCtrlAttributeHandle *, CtkConfig *, CtkEvent *, - CtkEvent *, char *, char *); + CtkEvent *, char *, char *, + ParsedAttribute *); GtkTextBuffer *ctk_display_device_create_help(GtkTextTagTable *, CtkDisplayDevice *); diff --git a/src/gtk+-2.x/ctkdisplaylayout.c b/src/gtk+-2.x/ctkdisplaylayout.c index 7226ae8..124e246 100644 --- a/src/gtk+-2.x/ctkdisplaylayout.c +++ b/src/gtk+-2.x/ctkdisplaylayout.c @@ -143,9 +143,10 @@ static gboolean button_release_event_callback (GtkWidget *widget, GdkEventButton *event, gpointer data); - static void calc_metamode(nvScreenPtr screen, nvMetaModePtr metamode); +static Bool sync_layout(nvLayoutPtr layout); + @@ -2023,17 +2024,10 @@ static int move_selected(CtkDisplayLayout *ctk_object, int x, int y, int snap) } /* Recalculate layout dimensions and scaling */ - calc_layout(layout); - - /* If layout needs to offset, it was modified */ - if (layout->dim[X] || layout->dim[Y]) { - offset_layout(layout, -layout->dim[X], -layout->dim[Y]); + if (sync_layout(layout)) { modified = 1; } - if (recenter_layout(layout)) { - modified = 1; - } if (sync_scaling(ctk_object)) { modified = 1; } @@ -2186,17 +2180,10 @@ static int pan_selected(CtkDisplayLayout *ctk_object, int x, int y, int snap) /* Recalculate layout dimensions and scaling */ - calc_layout(layout); - - /* If layout needs to offset, something moved */ - if (layout->dim[X] || layout->dim[Y]) { - offset_layout(layout, -layout->dim[X], -layout->dim[Y]); + if (sync_layout(layout)) { modified = 1; } - if (recenter_layout(layout)) { - modified = 1; - } if (sync_scaling(ctk_object)) { modified = 1; } @@ -2758,13 +2745,14 @@ GtkWidget* ctk_display_layout_new(NvCtrlAttributeHandle *handle, ctk_object->Zorder = NULL; ctk_object->Zcount = 0; + /* Setup widget properties */ ctk_object->ctk_config = ctk_config; ctk_object->handle = handle; ctk_object->layout = layout; - calc_layout(layout); + sync_layout(layout); sync_scaling(ctk_object); zorder_layout(ctk_object); select_default_item(ctk_object); @@ -3315,6 +3303,34 @@ static void clear_layout(CtkDisplayLayout *ctk_object) +/** sync_layout() **************************************************** + * + * Recalculates the X screen positions in the layout such that the + * top-left most X screen is at 0x0. + * + **/ + +static Bool sync_layout(nvLayoutPtr layout) +{ + Bool modified = FALSE; + + calc_layout(layout); + + /* If layout needs to offset, it was modified */ + if (layout->dim[X] || layout->dim[Y]) { + offset_layout(layout, -layout->dim[X], -layout->dim[Y]); + modified = TRUE; + } + + if (recenter_layout(layout)) { + modified = TRUE; + } + + return modified; +} + + + /** ctk_display_layout_update() ************************************** * * Causes a recalculation of the layout. @@ -3326,9 +3342,7 @@ void ctk_display_layout_update(CtkDisplayLayout *ctk_object) nvLayoutPtr layout = ctk_object->layout; /* Recalculate layout dimensions and scaling */ - calc_layout(layout); - offset_layout(layout, -layout->dim[X], -layout->dim[Y]); - recenter_layout(layout); + sync_layout(layout); sync_scaling(ctk_object); ctk_object->modify_info.modify_dirty = 1; diff --git a/src/gtk+-2.x/ctkdisplaylayout.h b/src/gtk+-2.x/ctkdisplaylayout.h index bf74a58..31e3455 100644 --- a/src/gtk+-2.x/ctkdisplaylayout.h +++ b/src/gtk+-2.x/ctkdisplaylayout.h @@ -96,15 +96,6 @@ G_BEGIN_DECLS ((MODELINE_SOURCE_XCONFIG)|(MODELINE_SOURCE_NVCONTROL)) -/* NV-CONTROL metamode sources */ -#define METAMODE_SOURCE_XCONFIG 0x001 -#define METAMODE_SOURCE_IMPLICIT 0x002 -#define METAMODE_SOURCE_NVCONTROL 0x004 - -#define METAMODE_SOURCE_USER \ - ((METAMODE_SOURCE_XCONFIG)|(METAMODE_SOURCE_NVCONTROL)) - - /*** M A C R O S *************************************************************/ @@ -123,6 +114,11 @@ G_BEGIN_DECLS #define GET_MODELINE_HSYNC(m) \ (((double)((m)->data.clock)) / (2.0f * (double)((m)->data.htotal))) +/* Determines if the metamode was created/modified by the user */ +#define IS_METAMODE_SOURCE_USER(s) \ +(((s) == METAMODE_SOURCE_XCONFIG) || \ + ((s) == METAMODE_SOURCE_NVCONTROL) || \ + ((s) == METAMODE_SOURCE_RANDR)) @@ -134,6 +130,12 @@ typedef enum { PASSIVE_STEREO_EYE_RIGHT, } PassiveStereoEye; +typedef enum { + METAMODE_SOURCE_XCONFIG = 0, + METAMODE_SOURCE_IMPLICIT, + METAMODE_SOURCE_NVCONTROL, + METAMODE_SOURCE_RANDR, +} MetaModeSource; typedef struct nvModeLineRec { struct nvModeLineRec *next; @@ -216,7 +218,7 @@ typedef struct nvMetaModeRec { struct nvMetaModeRec *next; int id; /* Magic id */ - int source; /* Source of the metamode */ + MetaModeSource source; /* Source of the metamode */ Bool switchable; /* Can the metamode be accessed through Ctrl Alt +- */ // Used for drawing & moving metamode boxes diff --git a/src/gtk+-2.x/ctkditheringcontrols.c b/src/gtk+-2.x/ctkditheringcontrols.c index 95fd3f7..51ec82b 100644 --- a/src/gtk+-2.x/ctkditheringcontrols.c +++ b/src/gtk+-2.x/ctkditheringcontrols.c @@ -126,6 +126,14 @@ GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle, CtkDitheringControls *ctk_dithering_controls; GtkWidget *frame, *vbox, *hbox, *label; GtkWidget *menu, *table, *menu_item = NULL, *separator; + ReturnStatus ret; + int tmp; + + /* test that dithering is available before creating the widget */ + ret = NvCtrlGetAttribute(handle, NV_CTRL_DITHERING, &tmp); + if (ret != NvCtrlSuccess) { + return NULL; + } /* create the object */ object = g_object_new(CTK_TYPE_DITHERING_CONTROLS, NULL); @@ -851,6 +859,10 @@ void add_dithering_controls_help(CtkDitheringControls *ctk_dithering_controls, GtkTextBuffer *b, GtkTextIter *i) { + if (ctk_dithering_controls == NULL) { + return; + } + ctk_help_heading(b, i, "Dithering Controls"); ctk_help_para(b, i, __dithering_help); diff --git a/src/gtk+-2.x/ctkecc.c b/src/gtk+-2.x/ctkecc.c index d6f0c3f..05525c4 100644 --- a/src/gtk+-2.x/ctkecc.c +++ b/src/gtk+-2.x/ctkecc.c @@ -66,9 +66,9 @@ static const char *__reset_default_config_button_help = static void ecc_config_button_toggled(GtkWidget *, gpointer); static void show_ecc_toggle_warning_dlg(CtkEcc *); -static void ecc_set_config_status(CtkEcc *, gboolean); +static void ecc_set_config_status(CtkEcc *); static void ecc_configuration_update_received(GtkObject *, gpointer, gpointer); -static void post_ecc_configuration_update(CtkEcc *, gboolean); +static void post_ecc_configuration_update(CtkEcc *); GType ctk_ecc_get_type(void) { @@ -192,26 +192,38 @@ static gboolean update_ecc_info(gpointer user_data) * post_ecc_configuration_update() - this function update status bar string. */ -static void post_ecc_configuration_update(CtkEcc *ctk_ecc, gboolean enabled) +static void post_ecc_configuration_update(CtkEcc *ctk_ecc) { - ctk_config_statusbar_message(ctk_ecc->ctk_config, - "ECC %s.", - enabled ? "enabled" : "disabled"); + gboolean configured = ctk_ecc->ecc_configured; + gboolean enabled = ctk_ecc->ecc_enabled; + + const char *conf_string = configured ? "enabled" : "disabled"; + char message[128]; + + if (configured != enabled) { + snprintf(message, sizeof(message), "ECC will be %s after reboot.", + conf_string); + } else { + snprintf(message, sizeof(message), "ECC %s.", conf_string); + } + + ctk_config_statusbar_message(ctk_ecc->ctk_config, message); } /* post_ecc_configuration_update() */ /* - * ecc_set_config_status() - set ECC configuration button status + * ecc_set_config_status() - set ECC configuration button status: caller + * should make sure ctk_ecc->ecc_configured is set correctly before calling. */ -static void ecc_set_config_status(CtkEcc *ctk_ecc, gboolean value) +static void ecc_set_config_status(CtkEcc *ctk_ecc) { g_signal_handlers_block_by_func(G_OBJECT(ctk_ecc->configuration_status), G_CALLBACK(ecc_config_button_toggled), (gpointer) ctk_ecc); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctk_ecc->configuration_status), - value); + ctk_ecc->ecc_configured); g_signal_handlers_unblock_by_func(G_OBJECT(ctk_ecc->configuration_status), G_CALLBACK(ecc_config_button_toggled), @@ -231,12 +243,14 @@ static void ecc_configuration_update_received(GtkObject *object, { CtkEventStruct *event_struct = (CtkEventStruct *) arg1; CtkEcc *ctk_ecc = CTK_ECC(user_data); - + + ctk_ecc->ecc_configured = event_struct->value; + /* set ECC configuration buttion status */ - ecc_set_config_status(ctk_ecc, event_struct->value); + ecc_set_config_status(ctk_ecc); /* Update status bar message */ - post_ecc_configuration_update(ctk_ecc, event_struct->value); + post_ecc_configuration_update(ctk_ecc); } @@ -250,18 +264,31 @@ static void reset_default_config_button_clicked(GtkWidget *widget, gpointer user_data) { gboolean status; + ReturnStatus ret; CtkEcc *ctk_ecc = CTK_ECC(user_data); /* get default status and set it to ECC configuration */ - NvCtrlGetAttribute(ctk_ecc->handle, - NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION, - &status); - NvCtrlSetAttribute(ctk_ecc->handle, - NV_CTRL_GPU_ECC_CONFIGURATION, - status); + ret = NvCtrlGetAttribute(ctk_ecc->handle, + NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION, + &status); + if (ret != NvCtrlSuccess) { + ctk_config_statusbar_message(ctk_ecc->ctk_config, + "Failed to get default configuration!"); + return; + } + ret = NvCtrlSetAttribute(ctk_ecc->handle, + NV_CTRL_GPU_ECC_CONFIGURATION, + status); + if (ret != NvCtrlSuccess) { + ctk_config_statusbar_message(ctk_ecc->ctk_config, + "Failed to set default configuration!"); + return; + } + + ctk_ecc->ecc_configured = status; /* update ECC configuration button status */ - ecc_set_config_status(ctk_ecc, status); + ecc_set_config_status(ctk_ecc); /* show popup dialog*/ show_ecc_toggle_warning_dlg(ctk_ecc); @@ -348,20 +375,29 @@ static void ecc_config_button_toggled(GtkWidget *widget, { gboolean enabled; CtkEcc *ctk_ecc = CTK_ECC(user_data); + ReturnStatus ret; + enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); /* show popup dialog when user first time click ECC config */ show_ecc_toggle_warning_dlg(ctk_ecc); /* set the newly specified ECC value */ - NvCtrlSetAttribute(ctk_ecc->handle, - NV_CTRL_GPU_ECC_CONFIGURATION, - enabled); + ret = NvCtrlSetAttribute(ctk_ecc->handle, + NV_CTRL_GPU_ECC_CONFIGURATION, + enabled); + if (ret != NvCtrlSuccess) { + ctk_config_statusbar_message(ctk_ecc->ctk_config, + "Failed to set ECC configuration!"); + return; + } + + ctk_ecc->ecc_configured = enabled; gtk_widget_set_sensitive(ctk_ecc->reset_default_config_button, TRUE); /* Update status bar message */ - post_ecc_configuration_update(ctk_ecc, enabled); + post_ecc_configuration_update(ctk_ecc); } /* ecc_config_button_toggled() */ @@ -428,6 +464,16 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle, } ctk_ecc->ecc_enabled = ecc_enabled; + /* Query ECC Configuration */ + + ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_ECC_CONFIGURATION, &val); + if (ret != NvCtrlSuccess || + val == NV_CTRL_GPU_ECC_CONFIGURATION_DISABLED) { + ctk_ecc->ecc_configured = FALSE; + } else { + ctk_ecc->ecc_configured = TRUE; + } + /* get default status */ ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION, @@ -547,7 +593,7 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle, gtk_container_set_border_width(GTK_CONTAINER(hbox2), 5); gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctk_ecc->configuration_status), - ecc_enabled); + ctk_ecc->ecc_configured); ctk_config_set_tooltip(ctk_config, ctk_ecc->configuration_status, __configuration_status_help); g_signal_connect(G_OBJECT(ctk_ecc->configuration_status), "clicked", diff --git a/src/gtk+-2.x/ctkecc.h b/src/gtk+-2.x/ctkecc.h index b4706f9..1f5c7a4 100644 --- a/src/gtk+-2.x/ctkecc.h +++ b/src/gtk+-2.x/ctkecc.h @@ -64,6 +64,7 @@ struct _CtkEcc GtkWidget* configuration_status; gboolean ecc_enabled; + gboolean ecc_configured; gboolean ecc_toggle_warning_dlg_shown; gboolean dbit_error_available; gboolean aggregate_dbit_error_available; diff --git a/src/gtk+-2.x/ctkscreen.c b/src/gtk+-2.x/ctkscreen.c index 4fa2541..e486eeb 100644 --- a/src/gtk+-2.x/ctkscreen.c +++ b/src/gtk+-2.x/ctkscreen.c @@ -101,75 +101,13 @@ GType ctk_screen_get_type( -/* Generates a list of display device names for those display devices that - * are enabled on the given GPU and, if Xinerama is disabled, are also - * associated to the given X screen (handle). - */ -static gchar *make_gpu_display_device_list(NvCtrlAttributeHandle *handle, - int gpu_id, - int xinerama_enabled) -{ - return create_display_name_list_string(handle, - NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN); -} - - - /* Generates a list of display devices for the logical X screen * given as "handle". */ static gchar *make_display_device_list(NvCtrlAttributeHandle *handle) { - ReturnStatus ret; - int len; - int i; - int *pData; - gchar *displays = NULL; - int xinerama_enabled; - - - /* See if Xinerama is enabled */ - ret = NvCtrlGetAttribute(handle, NV_CTRL_XINERAMA, &xinerama_enabled); - if (ret != NvCtrlSuccess) { - goto done; - } - - /* Get all GPUs driving this X screen */ - ret = NvCtrlGetBinaryAttribute(handle, - 0, - NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN, - (unsigned char **)(&pData), - &len); - if (ret != NvCtrlSuccess) { - goto done; - } - - /* Generate the list of display device names that display this X screen */ - for (i = 1; i <= pData[0]; i++) { - gchar *new_str; - gchar *tmp_str; - - new_str = make_gpu_display_device_list(handle, pData[i], - xinerama_enabled); - if (new_str) { - if (displays) { - tmp_str = g_strdup_printf("%s,\n%s", displays, new_str); - g_free(displays); - g_free(new_str); - displays = tmp_str; - } else { - displays = new_str; - } - } - } - - done: - if (!displays) { - displays = g_strdup("None"); - } - - return displays; - + return create_display_name_list_string(handle, + NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN); } /* make_display_device_list() */ diff --git a/src/gtk+-2.x/ctkwindow.c b/src/gtk+-2.x/ctkwindow.c index cb4cade..e813baa 100644 --- a/src/gtk+-2.x/ctkwindow.c +++ b/src/gtk+-2.x/ctkwindow.c @@ -57,7 +57,6 @@ #include "ctkpowersavings.h" #include "ctk3dvisionpro.h" -#include "ctkdisplaydevice-tv.h" #include "ctkdisplaydevice.h" #include "ctkdisplayconfig.h" @@ -122,7 +121,8 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter, NvCtrlAttributeHandle *handle, CtkEvent *ctk_event, GtkTextTagTable *tag_table, - UpdateDisplaysData *data); + UpdateDisplaysData *data, + ParsedAttribute *p); static void update_display_devices(GtkObject *object, gpointer arg1, gpointer user_data); @@ -876,7 +876,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, (gpointer) data); add_display_devices(ctk_window, &iter, gpu_handle, ctk_event, tag_table, - data); + data, ctk_window->attribute_list); } /* add the per-vcs (e.g. Quadro Plex) entries into the tree model */ @@ -1369,7 +1369,8 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter, NvCtrlAttributeHandle *gpu_handle, CtkEvent *ctk_event_gpu, GtkTextTagTable *tag_table, - UpdateDisplaysData *data) + UpdateDisplaysData *data, + ParsedAttribute *p) { GtkTextBuffer *help; ReturnStatus ret; @@ -1407,13 +1408,21 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter, GtkWidget *widget; gchar *title; CtkEvent *ctk_event; + CtrlHandles *handles = ctk_window->ctk_config->pCtrlHandles; + + /* + * Get the ctrl handle that was passed into ctk_main so that updated + * backend color slider values, cached in the handle itself, can be + * saved to the RC file when the UI is closed. + */ + + if (handles) { + display_handle = + handles->targets[NV_CTRL_TARGET_TYPE_DISPLAY].t[display_id].h; + } else { + display_handle = NULL; + } - display_handle = - NvCtrlAttributeInit(NvCtrlGetDisplayPtr(gpu_handle), - NV_CTRL_TARGET_TYPE_DISPLAY, - display_id, - NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM | - NV_CTRL_ATTRIBUTES_XRANDR_SUBSYSTEM); if (!display_handle) { continue; } @@ -1449,27 +1458,16 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter, XFree(logName); XFree(typeIdName); - /* Create the appropriate page for the display */ - if (strcmp(typeBaseName, "TV") == 0) { - widget = ctk_display_device_tv_new - (display_handle, ctk_window->ctk_config, ctk_event, title); - help = ctk_display_device_tv_create_help - (tag_table, CTK_DISPLAY_DEVICE_TV(widget)); - } else if ((strcmp(typeBaseName, "DFP") == 0) || - (strcmp(typeBaseName, "CRT") == 0)) { - widget = ctk_display_device_new(display_handle, - ctk_window->ctk_config, ctk_event, - ctk_event_gpu, - title, typeBaseName); - help = ctk_display_device_create_help(tag_table, - CTK_DISPLAY_DEVICE(widget)); - } else { - widget = NULL; - } - - if (!widget) { + /* Create the page for the display */ + widget = ctk_display_device_new(display_handle, + ctk_window->ctk_config, ctk_event, + ctk_event_gpu, + title, typeBaseName, p); + if (widget == NULL) { NvCtrlAttributeClose(display_handle); } else { + help = ctk_display_device_create_help(tag_table, + CTK_DISPLAY_DEVICE(widget)); add_page(widget, help, ctk_window, iter, &(data->display_iters[data->num_displays]), title, NULL, NULL, NULL); @@ -1543,7 +1541,7 @@ static void update_display_devices(GtkObject *object, gpointer arg1, add_display_devices(ctk_window, &parent_iter, gpu_handle, CTK_GPU(widget)->ctk_event, - tag_table, data); + tag_table, data, ctk_window->attribute_list); /* Expand the GPU entry if it used to be */ if (parent_expanded) { diff --git a/src/libXNVCtrl/NVCtrl.h b/src/libXNVCtrl/NVCtrl.h index 9e97279..777f5e4 100644 --- a/src/libXNVCtrl/NVCtrl.h +++ b/src/libXNVCtrl/NVCtrl.h @@ -339,6 +339,7 @@ #define NV_CTRL_STEREO_INVERSE_CHECKERBOARD_PATTERN 9 #define NV_CTRL_STEREO_3D_VISION 10 #define NV_CTRL_STEREO_3D_VISION_PRO 11 +#define NV_CTRL_STEREO_HDMI_3D 12 /* * NV_CTRL_EMULATE - controls OpenGL software emulation of future @@ -776,58 +777,49 @@ /* - * NV_CTRL_TV_OVERSCAN adjusts the amount of overscan on the specified - * display device. + * NV_CTRL_TV_OVERSCAN - not supported */ #define NV_CTRL_TV_OVERSCAN 53 /* RWDG */ /* - * NV_CTRL_TV_FLICKER_FILTER adjusts the amount of flicker filter on - * the specified display device. + * NV_CTRL_TV_FLICKER_FILTER - not supported */ #define NV_CTRL_TV_FLICKER_FILTER 54 /* RWDG */ /* - * NV_CTRL_TV_BRIGHTNESS adjusts the amount of brightness on the - * specified display device. + * NV_CTRL_TV_BRIGHTNESS - not supported */ #define NV_CTRL_TV_BRIGHTNESS 55 /* RWDG */ /* - * NV_CTRL_TV_HUE adjusts the amount of hue on the specified display - * device. + * NV_CTRL_TV_HUE - not supported */ #define NV_CTRL_TV_HUE 56 /* RWDG */ /* - * NV_CTRL_TV_CONTRAST adjusts the amount of contrast on the specified - * display device. + * NV_CTRL_TV_CONTRAST - not suppoerted */ #define NV_CTRL_TV_CONTRAST 57 /* RWDG */ /* - * NV_CTRL_TV_SATURATION adjusts the amount of saturation on the - * specified display device. + * NV_CTRL_TV_SATURATION - not supported */ #define NV_CTRL_TV_SATURATION 58 /* RWDG */ /* - * NV_CTRL_TV_RESET_SETTINGS - this write-only attribute can be used - * to request that all TV Settings be reset to their default values; - * typical usage would be that this attribute be sent, and then all - * the TV attributes be queried to retrieve their new values. + * NV_CTRL_TV_RESET_SETTINGS - not supported */ #define NV_CTRL_TV_RESET_SETTINGS 59 /* -WDG */ diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributes.c b/src/libXNVCtrlAttributes/NvCtrlAttributes.c index 150126d..6970a3f 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributes.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributes.c @@ -958,11 +958,18 @@ ReturnStatus NvCtrlSetColorAttributes(NvCtrlAttributeHandle *handle, float g[3], unsigned int bitmask) { + ReturnStatus status; + int val = 0; + NvCtrlAttributePrivateHandle *h = (NvCtrlAttributePrivateHandle *) handle; - if (h->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) { + status = NvCtrlGetAttribute(h, NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE, &val); + + if ((status != NvCtrlSuccess || !val) && + h->target_type == NV_CTRL_TARGET_TYPE_X_SCREEN) { return NvCtrlVidModeSetColorAttributes(h, c, b, g, bitmask); - } else if (h->target_type == NV_CTRL_TARGET_TYPE_DISPLAY) { + } else if (status == NvCtrlSuccess && val && + h->target_type == NV_CTRL_TARGET_TYPE_DISPLAY) { return NvCtrlXrandrSetColorAttributes(h, c, b, g, bitmask); } diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h b/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h index 36cbcb9..538f6b2 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h @@ -25,6 +25,13 @@ #include <GL/glx.h> /* GLX #defines */ #include <X11/extensions/Xrandr.h> /* Xrandr */ +/* Make sure we are compiling with XRandR version 1.2 or greater */ +#define MIN_RANDR_MAJOR 1 +#define MIN_RANDR_MINOR 2 +#if (RANDR_MAJOR < MIN_RANDR_MAJOR) || ((RANDR_MAJOR == MIN_RANDR_MAJOR) && (RANDR_MINOR < MIN_RANDR_MINOR)) +#error XRandR version 1.2 or greater is required. +#endif + #define EXTENSION_NV_CONTROL 0x1 #define EXTENSION_XF86VIDMODE 0x2 diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c b/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c index c9c5eb9..9a77b94 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c @@ -38,13 +38,6 @@ #include "msg.h" #include "parse.h" -/* Make sure we are compiling with XRandR version 1.1 or greater */ -#define MIN_RANDR_MAJOR 1 -#define MIN_RANDR_MINOR 1 -#if (RANDR_MAJOR < MIN_RANDR_MAJOR) || ((RANDR_MAJOR == MIN_RANDR_MAJOR) && (RANDR_MINOR < MIN_RANDR_MINOR)) -#error XRandR version 1.1 or greater is required. -#endif - typedef struct __libXrandrInfoRec { /* libXrandr.so library handle */ diff --git a/src/parse.c b/src/parse.c index efb0ba4..1db464f 100644 --- a/src/parse.c +++ b/src/parse.c @@ -456,6 +456,38 @@ TargetTypeEntry targetTypeTable[] = { { NULL, NULL, 0, 0, 0, 0, 0, 0 }, }; +TargetTypeEntry *nv_get_target_type_entry_by_nvctrl(int nvctrl) +{ + TargetTypeEntry *targetTypeEntry; + + for (targetTypeEntry = targetTypeTable; + targetTypeEntry->name; + targetTypeEntry++) { + + if (targetTypeEntry->nvctrl == nvctrl) { + return targetTypeEntry; + } + } + + return NULL; +} + +TargetTypeEntry *nv_get_target_type_entry_by_name(const char *name) +{ + TargetTypeEntry *targetTypeEntry; + + for (targetTypeEntry = targetTypeTable; + targetTypeEntry->name; + targetTypeEntry++) { + + if (nv_strcasecmp(targetTypeEntry->parsed_name, name)) { + return targetTypeEntry; + } + } + + return NULL; +} + /* @@ -681,8 +713,9 @@ static int nv_parse_display_and_target(char *start, char *end, /* exclusive */ ParsedAttribute *a) { - int digits_only, i, target_type, target_id, len; + int digits_only, target_id, len; char *tmp, *s, *pOpen, *pClose, *colon; + TargetTypeEntry *targetTypeEntry; /* * are all characters numeric? compute the target_id integer as we @@ -759,24 +792,18 @@ static int nv_parse_display_and_target(char *start, */ *colon = '\0'; - target_type = -1; - for (i = 0; targetTypeTable[i].name; i++) { - if (nv_strcasecmp(tmp, targetTypeTable[i].parsed_name)) { - target_type = targetTypeTable[i].nvctrl; - break; - } - } - + targetTypeEntry = nv_get_target_type_entry_by_name(tmp); + *colon = ':'; - + /* if we did not find a matching target name, give up */ - - if (target_type == -1) { + + if (!targetTypeEntry) { free(tmp); return NV_PARSER_STATUS_TARGET_SPEC_BAD_TARGET; } - + /* * check that we have something between the colon and the end * of the temp string @@ -808,7 +835,7 @@ static int nv_parse_display_and_target(char *start, * this is a target type-specific name. */ - a->target_type = target_type; + a->target_type = targetTypeEntry->nvctrl; if (digits_only) { a->target_id = target_id; diff --git a/src/parse.h b/src/parse.h index b7358b7..bf71447 100644 --- a/src/parse.h +++ b/src/parse.h @@ -140,8 +140,8 @@ extern AttributeTableEntry attributeTable[]; /* - * Indices into CtrlHandles->targets[] array; stored in - * TargetTypeEntry.target_index. + * Indices into both targetTypeTable[] and CtrlHandles->targets[] array; stored + * in TargetTypeEntry.target_index. */ #define X_SCREEN_TARGET 0 @@ -193,6 +193,14 @@ typedef struct { extern TargetTypeEntry targetTypeTable[]; +/* + * accessor functions for getting target type info based on NV-CONTROL + * attribute type or by a name. + */ +TargetTypeEntry *nv_get_target_type_entry_by_nvctrl(int nvctrl); +TargetTypeEntry *nv_get_target_type_entry_by_name(const char *name); + + /* nv_get_sdi_csc_matrxi() - Returns an array of floats that specifies * all the color, offset and scale values for specifing one of the * Standard CSC. 's' is a string that names the matrix values to return. diff --git a/src/query-assign.c b/src/query-assign.c index 8b54acc..f8fd0c0 100644 --- a/src/query-assign.c +++ b/src/query-assign.c @@ -120,19 +120,26 @@ CtrlHandles *nv_alloc_ctrl_handles(const char *display) ReturnStatus status; CtrlHandles *h, *pQueryHandle = NULL; NvCtrlAttributeHandle *handle; - int target, i, j, val, d, c, len; + int i, val, d, c, len; char *tmp; int *pData = NULL; + TargetTypeEntry *targetTypeEntry; /* allocate the CtrlHandles struct */ - + h = calloc(1, sizeof(CtrlHandles)); - + if (!h) { + return NULL; + } + /* store any given X display name */ - if (display) h->display = strdup(display); - else h->display = NULL; - + if (display) { + h->display = strdup(display); + } else { + h->display = NULL; + } + /* open the X display connection */ h->dpy = XOpenDisplay(h->display); @@ -141,38 +148,39 @@ CtrlHandles *nv_alloc_ctrl_handles(const char *display) nv_error_msg("Cannot open display '%s'.", XDisplayName(h->display)); return h; } - + /* * loop over each target type and setup the appropriate * information */ - - for (j = 0; targetTypeTable[j].name; j++) { - - /* extract the target index from the table */ - target = targetTypeTable[j].target_index; - - /* + for (targetTypeEntry = targetTypeTable; + targetTypeEntry->name; + targetTypeEntry++) { + + int target = targetTypeEntry->target_index; + CtrlHandleTargets *targets = &(h->targets[target]); + + /* * get the number of targets of this type; if this is an X * screen target, just use Xlib's ScreenCount() (note: to * support Xinerama: we'll want to use * NvCtrlQueryTargetCount() rather than ScreenCount()); for * other target types, use NvCtrlQueryTargetCount(). */ - + if (target == X_SCREEN_TARGET) { - - h->targets[target].n = ScreenCount(h->dpy); - + + targets->n = ScreenCount(h->dpy); + } else { - + /* * note: pQueryHandle should be assigned below by a * previous iteration of this loop; depends on X screen * targets getting handled first */ - + if (pQueryHandle) { /* @@ -191,13 +199,13 @@ CtrlHandles *nv_alloc_ctrl_handles(const char *display) &minor); if ((ret1 == NvCtrlSuccess) && (ret2 == NvCtrlSuccess) && - ((major > targetTypeTable[j].major) || - ((major == targetTypeTable[j].major) && - (minor >= targetTypeTable[j].minor)))) { + ((major > targetTypeEntry->major) || + ((major == targetTypeEntry->major) && + (minor >= targetTypeEntry->minor)))) { if (target != DISPLAY_TARGET) { status = NvCtrlQueryTargetCount - (pQueryHandle, targetTypeTable[j].nvctrl, + (pQueryHandle, targetTypeEntry->nvctrl, &val); } else { /* For targets that aren't simply enumerated, @@ -222,35 +230,34 @@ CtrlHandles *nv_alloc_ctrl_handles(const char *display) if (status != NvCtrlSuccess) { nv_warning_msg("Unable to determine number of NVIDIA " "%ss on '%s'.", - targetTypeTable[j].name, + targetTypeEntry->name, XDisplayName(h->display)); val = 0; } - - h->targets[target].n = val; + + targets->n = val; } - + /* if there are no targets of this type, skip */ - if (h->targets[target].n == 0) { - if (pData) { - XFree(pData); - pData = NULL; - } - continue; + if (targets->n == 0) { + goto next_target_type; } /* allocate an array of CtrlHandleTarget's */ - h->targets[target].t = - calloc(h->targets[target].n, sizeof(CtrlHandleTarget)); - + targets->t = calloc(targets->n, sizeof(CtrlHandleTarget)); + if (!targets->t) { + targets->n = 0; + goto next_target_type; + } + /* * loop over all the targets of this type and setup the * CtrlHandleTarget's */ - for (i = 0; i < h->targets[target].n; i++) { + for (i = 0; i < targets->n; i++) { int targetId; switch (target) { @@ -271,23 +278,19 @@ CtrlHandles *nv_alloc_ctrl_handles(const char *display) } /* allocate the handle */ - + handle = NvCtrlAttributeInit(h->dpy, - targetTypeTable[j].nvctrl, targetId, + targetTypeEntry->nvctrl, targetId, NV_CTRL_ATTRIBUTES_ALL_SUBSYSTEMS); - - h->targets[target].t[i].h = handle; - + + targets->t[i].h = handle; + /* * silently fail: this might happen if not all X screens * are NVIDIA X screens */ if (!handle) { - if (pData) { - XFree(pData); - pData = NULL; - } continue; } @@ -301,21 +304,21 @@ CtrlHandles *nv_alloc_ctrl_handles(const char *display) tmp = NvCtrlGetDisplayName(handle); if (target == X_SCREEN_TARGET) { - h->targets[target].t[i].name = tmp; + targets->t[i].name = tmp; } else { - len = strlen(tmp) + strlen(targetTypeTable[j].parsed_name) +16; - h->targets[target].t[i].name = malloc(len); + len = strlen(tmp) + strlen(targetTypeEntry->parsed_name) +16; + targets->t[i].name = malloc(len); - if (h->targets[target].t[i].name) { - snprintf(h->targets[target].t[i].name, len, "%s[%s:%d]", - tmp, targetTypeTable[j].parsed_name, i); + if (targets->t[i].name) { + snprintf(targets->t[i].name, len, "%s[%s:%d]", + tmp, targetTypeEntry->parsed_name, i); free(tmp); } else { - h->targets[target].t[i].name = tmp; + targets->t[i].name = tmp; } if (target == DISPLAY_TARGET) { - query_display_target_names(&(h->targets[target].t[i])); + query_display_target_names(&(targets->t[i])); } } @@ -325,14 +328,14 @@ CtrlHandles *nv_alloc_ctrl_handles(const char *display) * (framelock), we just assign this to 0. */ - if (targetTypeTable[j].uses_display_devices) { + if (targetTypeEntry->uses_display_devices) { status = NvCtrlGetAttribute(handle, NV_CTRL_ENABLED_DISPLAYS, &d); if (status != NvCtrlSuccess) { nv_error_msg("Error querying enabled displays on " - "%s %d (%s).", targetTypeTable[j].name, i, + "%s %d (%s).", targetTypeEntry->name, i, NvCtrlAttributesStrError(status)); d = 0; } @@ -342,7 +345,7 @@ CtrlHandles *nv_alloc_ctrl_handles(const char *display) if (status != NvCtrlSuccess) { nv_error_msg("Error querying connected displays on " - "%s %d (%s).", targetTypeTable[j].name, i, + "%s %d (%s).", targetTypeEntry->name, i, NvCtrlAttributesStrError(status)); c = 0; } @@ -350,9 +353,9 @@ CtrlHandles *nv_alloc_ctrl_handles(const char *display) d = 0; c = 0; } - - h->targets[target].t[i].d = d; - h->targets[target].t[i].c = c; + + targets->t[i].d = d; + targets->t[i].c = c; /* * store this handle so that we can use it to query other @@ -362,12 +365,13 @@ CtrlHandles *nv_alloc_ctrl_handles(const char *display) if (!pQueryHandle) pQueryHandle = handle; } + next_target_type: if (pData) { XFree(pData); pData = NULL; } } - + return h; } /* nv_alloc_ctrl_handles() */ @@ -380,7 +384,7 @@ CtrlHandles *nv_alloc_ctrl_handles(const char *display) void nv_free_ctrl_handles(CtrlHandles *h) { - int i, j, target; + TargetTypeEntry *targetTypeEntry; if (!h) return; @@ -399,12 +403,16 @@ void nv_free_ctrl_handles(CtrlHandles *h) XCloseDisplay(h->dpy); h->dpy = NULL; - for (j = 0; targetTypeTable[j].name; j++) { + for (targetTypeEntry = targetTypeTable; + targetTypeEntry->name; + targetTypeEntry++) { - target = targetTypeTable[j].target_index; + CtrlHandleTargets *targets = + &(h->targets[targetTypeEntry->target_index]); + int i; - for (i = 0; i < h->targets[target].n; i++) { - CtrlHandleTarget *t = &(h->targets[target].t[i]); + for (i = 0; i < targets->n; i++) { + CtrlHandleTarget *t = &(targets->t[i]); int n; NvCtrlAttributeClose(t->h); @@ -417,11 +425,9 @@ void nv_free_ctrl_handles(CtrlHandles *h) memset(t, 0, sizeof(*t)); } - - if (h->targets[target].t) free(h->targets[target].t); + free(targets->t); } } - free(h); } /* nv_free_ctrl_handles() */ @@ -528,6 +534,9 @@ static int process_attribute_queries(int num, char **queries, /* allocate the CtrlHandles */ h = nv_alloc_ctrl_handles(a.display); + if (!h) { + goto done; + } /* call the processing engine to process the parsed query */ @@ -602,7 +611,10 @@ static int process_attribute_assignments(int num, char **assignments, /* allocate the CtrlHandles */ h = nv_alloc_ctrl_handles(a.display); - + if (!h) { + goto done; + } + /* call the processing engine to process the parsed assignment */ ret = nv_process_parsed_attribute(&a, h, NV_TRUE, NV_TRUE, @@ -638,11 +650,12 @@ static int process_attribute_assignments(int num, char **assignments, static int validate_value(CtrlHandleTarget *t, ParsedAttribute *a, uint32 d, int target_type, char *whence) { - int i, bad_val = NV_FALSE; + int bad_val = NV_FALSE; NVCTRLAttributeValidValuesRec valid; ReturnStatus status; char d_str[256]; char *tmp_d_str; + TargetTypeEntry *targetTypeEntry; status = NvCtrlGetValidDisplayAttributeValues(t->h, d, a->attr, &valid); @@ -709,16 +722,14 @@ static int validate_value(CtrlHandleTarget *t, ParsedAttribute *a, uint32 d, /* is this value available for this target type? */ - for (i = 0; targetTypeTable[i].name; i++) { - if ((targetTypeTable[i].target_index == target_type) && - !(targetTypeTable[i].permission_bit & valid.permissions)) { - bad_val = NV_TRUE; - break; - } + targetTypeEntry = nv_get_target_type_entry_by_nvctrl(target_type); + if (!targetTypeEntry || + !(targetTypeEntry->permission_bit & valid.permissions)) { + bad_val = NV_TRUE; } /* if the value is bad, print why */ - + if (bad_val) { if (a->flags & NV_PARSER_TYPE_PACKED_ATTRIBUTE) { nv_warning_msg("The value pair %d,%d for attribute '%s' (%s%s) " @@ -749,12 +760,13 @@ static int validate_value(CtrlHandleTarget *t, ParsedAttribute *a, uint32 d, static void print_valid_values(char *name, int attr, uint32 flags, NVCTRLAttributeValidValuesRec valid) { - int bit, print_bit, last, last2, i, n; + int bit, print_bit, last, last2, n; char str[256]; char *c; char str2[256]; char *c2; char **at; + TargetTypeEntry *targetTypeEntry; /* do not print any valid values information when we are in 'terse' mode */ @@ -862,23 +874,25 @@ static void print_valid_values(char *name, int attr, uint32 flags, } /* print the valid target types */ - + c = str; n = 0; - - for (i = 0; targetTypeTable[i].name; i++) { - if (valid.permissions & targetTypeTable[i].permission_bit) { + + for (targetTypeEntry = targetTypeTable; + targetTypeEntry->name; + targetTypeEntry++) { + if (valid.permissions & targetTypeEntry->permission_bit) { if (n > 0) c += sprintf(c, ", "); - c += sprintf(c, "%s", targetTypeTable[i].name); + c += sprintf(c, "%s", targetTypeEntry->name); n++; } } - + if (n == 0) sprintf(c, "None"); - + nv_msg(INDENT, "'%s' can use the following target types: %s.", name, str); - + if (__verbosity >= VERBOSITY_ALL) print_additional_info(name, attr, valid, INDENT); @@ -1036,28 +1050,36 @@ static void print_additional_info(const char *name, static int query_all(const char *display_name) { - int bit, entry, target_id, val; - int target_type; + int bit, entry, val; uint32 mask; ReturnStatus status; AttributeTableEntry *a; NVCTRLAttributeValidValuesRec valid; CtrlHandles *h; - CtrlHandleTarget *t; - + TargetTypeEntry *targetTypeEntry; + h = nv_alloc_ctrl_handles(display_name); + if (!h) { + return NV_FALSE; + } #define INDENT " " - + /* * Loop through all target types. */ - for (target_type = 0; target_type < MAX_TARGET_TYPES; target_type++) { - - for (target_id = 0; target_id < h->targets[target_type].n; target_id++) { + for (targetTypeEntry = targetTypeTable; + targetTypeEntry->name; + targetTypeEntry++) { + + CtrlHandleTargets *targets = + &(h->targets[targetTypeEntry->target_index]); + int i; + + for (i = 0; i < targets->n; i++) { - t = &h->targets[target_type].t[target_id]; + CtrlHandleTarget *t = &targets->t[i]; if (!t->h) continue; @@ -1086,14 +1108,17 @@ static int query_all(const char *display_name) * display devices), skip to the next bit */ - if (((t->d & mask) == 0x0) && (t->d)) continue; + if (targetTypeEntry->uses_display_devices && + ((t->d & mask) == 0x0) && (t->d)) continue; if (a->flags & NV_PARSER_TYPE_STRING_ATTRIBUTE) { char *tmp_str = NULL; status = NvCtrlGetValidStringDisplayAttributeValues(t->h, mask, a->attr, &valid); - if (status == NvCtrlAttributeNotAvailable) goto exit_bit_loop; + if (status == NvCtrlAttributeNotAvailable) { + goto exit_bit_loop; + } if (status != NvCtrlSuccess) { nv_error_msg("Error while querying valid values for " @@ -1102,10 +1127,12 @@ static int query_all(const char *display_name) NvCtrlAttributesStrError(status)); goto exit_bit_loop; } - + status = NvCtrlGetStringDisplayAttribute(t->h, mask, a->attr, &tmp_str); - if (status == NvCtrlAttributeNotAvailable) goto exit_bit_loop; + if (status == NvCtrlAttributeNotAvailable) { + goto exit_bit_loop; + } if (status != NvCtrlSuccess) { nv_error_msg("Error while querying attribute '%s' " @@ -1124,7 +1151,7 @@ static int query_all(const char *display_name) tmp_str = NULL; } else { - + status = NvCtrlGetValidDisplayAttributeValues(t->h, mask, a->attr, &valid); if (status == NvCtrlAttributeNotAvailable) goto exit_bit_loop; @@ -1166,15 +1193,15 @@ static int query_all(const char *display_name) exit_bit_loop: - bit = 25; /* XXX force us out of the display device loop */ + break; /* XXX force us out of the display device loop */ } /* bit */ } /* entry */ - } /* target_id */ + } /* i (targets) */ - } /* target_type */ + } /* target types */ #undef INDENT @@ -1371,26 +1398,19 @@ static int query_all_targets(const char *display_name, const int target_index) { CtrlHandles *h; CtrlHandleTarget *t; - int i, table_index; - char *str, *name, *product_name; - - /* find the index into targetTypeTable[] for target_index */ + char *str, *name; + int i; + TargetTypeEntry *targetTypeEntry; - table_index = -1; - - for (i = 0; targetTypeTable[i].name; i++) { - if (targetTypeTable[i].target_index == target_index) { - table_index = i; - break; - } - } - - if (table_index == -1) return NV_FALSE; + targetTypeEntry = &(targetTypeTable[target_index]); /* create handles */ h = nv_alloc_ctrl_handles(display_name); - + if (!h) { + return NV_FALSE; + } + /* build the standard X server name */ str = nv_standardize_screen_name(XDisplayName(h->display), -2); @@ -1398,10 +1418,7 @@ static int query_all_targets(const char *display_name, const int target_index) /* warn if we don't have any of the target type */ if (h->targets[target_index].n <= 0) { - - nv_warning_msg("No %ss on %s", - targetTypeTable[table_index].name, str); - + nv_warning_msg("No %ss on %s", targetTypeEntry->name, str); free(str); nv_free_ctrl_handles(h); return NV_FALSE; @@ -1411,7 +1428,7 @@ static int query_all_targets(const char *display_name, const int target_index) nv_msg(NULL, "%d %s%s on %s", h->targets[target_index].n, - targetTypeTable[table_index].name, + targetTypeEntry->name, (h->targets[target_index].n > 1) ? "s" : "", str); nv_msg(NULL, ""); @@ -1421,58 +1438,32 @@ static int query_all_targets(const char *display_name, const int target_index) /* print information per target */ for (i = 0; i < h->targets[target_index].n; i++) { - + char product_name[32]; + Bool is_x_name = NV_FALSE; + char *x_name = NULL; + t = &h->targets[target_index].t[i]; - + str = NULL; if (target_index == NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET) { - /* for 3D Vision Pro transceiver, create the product name */ - - product_name = malloc(32); snprintf(product_name, 32, "3D Vision Pro Transceiver %d", i); - } else if (target_index == THERMAL_SENSOR_TARGET) { - /* for sensor, create the product name */ - - product_name = malloc(32); snprintf(product_name, 32, "Thermal Sensor %d", i); - } else if (target_index == COOLER_TARGET) { - - /* for cooler, create the product name */ - - product_name = malloc(32); snprintf(product_name, 32, "Fan %d", i); - } else if (target_index == FRAMELOCK_TARGET) { - - /* for framelock, create the product name */ - - product_name = malloc(32); snprintf(product_name, 32, "Quadro Sync %d", i); - } else if (target_index == VCS_TARGET) { - - product_name = get_product_name(t->h, - NV_CTRL_STRING_VCSC_PRODUCT_NAME); - + x_name = get_product_name(t->h, NV_CTRL_STRING_VCSC_PRODUCT_NAME); + is_x_name = NV_TRUE; } else if (target_index == GVI_TARGET) { - - /* for gvi, create the product name */ - - product_name = malloc(32); snprintf(product_name, 32, "SDI Input %d", i); - } else if (target_index == DISPLAY_TARGET) { - - product_name = get_product_name(t->h, - NV_CTRL_STRING_DISPLAY_DEVICE_NAME); - + x_name = get_product_name(t->h, NV_CTRL_STRING_DISPLAY_DEVICE_NAME); + is_x_name = NV_TRUE; } else { - - /* for X_SCREEN_TARGET or GPU_TARGET, query the product name */ - product_name = get_product_name(t->h, NV_CTRL_STRING_PRODUCT_NAME); - + x_name = get_product_name(t->h, NV_CTRL_STRING_PRODUCT_NAME); + is_x_name = NV_TRUE; } /* @@ -1487,14 +1478,17 @@ static int query_all_targets(const char *display_name, const int target_index) name = "Not NVIDIA"; } - nv_msg(" ", "[%d] %s (%s)", i, name, product_name); + nv_msg(" ", "[%d] %s (%s)", i, name, + is_x_name ? x_name : product_name); nv_msg(NULL, ""); - - free(product_name); + + if (x_name) { + XFree(x_name); + } /* Print connectivity information */ if (__verbosity >= VERBOSITY_ALL) { - if (targetTypeTable[table_index].uses_display_devices) { + if (targetTypeEntry->uses_display_devices) { print_target_display_connections(t); } @@ -1732,12 +1726,13 @@ int nv_process_parsed_attribute(ParsedAttribute *a, CtrlHandles *h, int assign, int verbose, char *whence_fmt, ...) { - int i, target, start, end, bit, ret, val, target_type_index; - char *whence, *tmp_d_str0, *tmp_d_str1, *target_type_name; + int i, target, start, end, bit, ret, val; + char *whence, *tmp_d_str0, *tmp_d_str1; uint32 display_devices, mask; ReturnStatus status; NVCTRLAttributeValidValuesRec valid; CtrlHandleTarget *t; + TargetTypeEntry *targetTypeEntry; val = NV_FALSE; @@ -1760,30 +1755,24 @@ int nv_process_parsed_attribute(ParsedAttribute *a, CtrlHandles *h, * if a target was specified, make sure it is valid, and setup * the variables 'start', 'end', and 'target'. */ - + if (a->flags & NV_PARSER_HAS_TARGET) { - + char *target_type_name; + /* * look up the target index for the target type specified in * the ParsedAttribute */ - - target = -1; - target_type_name = "?"; - - for (i = 0; targetTypeTable[i].name; i++) { - if (targetTypeTable[i].nvctrl == a->target_type) { - target = targetTypeTable[i].target_index; - target_type_name = targetTypeTable[i].name; - break; - } - } - - if (target == -1) { + + targetTypeEntry = nv_get_target_type_entry_by_nvctrl(a->target_type); + if (!targetTypeEntry) { nv_error_msg("Invalid target specified %s.", whence); - goto done; + goto done; } + target = targetTypeEntry->target_index; + target_type_name = targetTypeEntry->name; + /* * If the target was named, match it to one of the probed targets * to obtain the target_id @@ -1858,7 +1847,7 @@ int nv_process_parsed_attribute(ParsedAttribute *a, CtrlHandles *h, end = a->target_id + 1; } else { - + /* * no target was specified; assume a target type of * X_SCREEN_TARGET, and assign 'start' and 'end' such that we @@ -1866,23 +1855,13 @@ int nv_process_parsed_attribute(ParsedAttribute *a, CtrlHandles *h, * correct default target type for each attribute and default * to that rather than assume X_SCREEN_TARGET. */ - + + targetTypeEntry = &(targetTypeTable[X_SCREEN_TARGET]); target = X_SCREEN_TARGET; start = 0; end = h->targets[target].n; } - /* find the target type index */ - - target_type_index = 0; - - for (i = 0; targetTypeTable[i].name; i++) { - if (targetTypeTable[i].target_index == target) { - target_type_index = i; - break; - } - } - /* loop over the requested targets */ for (i = start; i < end; i++) { @@ -2230,7 +2209,7 @@ int nv_process_parsed_attribute(ParsedAttribute *a, CtrlHandles *h, mask = (1 << bit); if (((mask & display_devices) == 0x0) && - (targetTypeTable[target_type_index].uses_display_devices) && + (targetTypeEntry->uses_display_devices) && (t->d)) { continue; } @@ -2288,9 +2267,9 @@ int nv_process_parsed_attribute(ParsedAttribute *a, CtrlHandles *h, * does not have display devices, then once through this loop * is enough. */ - + if ((!(valid.permissions & ATTRIBUTE_TYPE_DISPLAY)) || - (!(targetTypeTable[target_type_index].uses_display_devices)) || + (!(targetTypeEntry->uses_display_devices)) || (!(t->d))) { break; } @@ -189,7 +189,6 @@ GTK_SRC += gtk+-2.x/ctkopengl.c GTK_SRC += gtk+-2.x/ctkglx.c GTK_SRC += gtk+-2.x/ctkhelp.c GTK_SRC += gtk+-2.x/ctkimagesliders.c -GTK_SRC += gtk+-2.x/ctkdisplaydevice-tv.c GTK_SRC += gtk+-2.x/ctkdisplaydevice.c GTK_SRC += gtk+-2.x/ctkditheringcontrols.c GTK_SRC += gtk+-2.x/ctkthermal.c @@ -237,7 +236,6 @@ GTK_EXTRA_DIST += gtk+-2.x/ctkopengl.h GTK_EXTRA_DIST += gtk+-2.x/ctkglx.h GTK_EXTRA_DIST += gtk+-2.x/ctkhelp.h GTK_EXTRA_DIST += gtk+-2.x/ctkimagesliders.h -GTK_EXTRA_DIST += gtk+-2.x/ctkdisplaydevice-tv.h GTK_EXTRA_DIST += gtk+-2.x/ctkdisplaydevice.h GTK_EXTRA_DIST += gtk+-2.x/ctkditheringcontrols.h GTK_EXTRA_DIST += gtk+-2.x/ctkconstants.h diff --git a/src/version.mk b/src/version.mk index 2335952..1feef56 100644 --- a/src/version.mk +++ b/src/version.mk @@ -1 +1 @@ -NVIDIA_VERSION = 304.51 +NVIDIA_VERSION = 310.14 @@ -100,6 +100,15 @@ else LIBDL_LIBS = endif +# This variable controls which floating-point ABI is targeted. For ARM, it +# defaults to "gnueabi" for softfp. Another option is "gnueabihf" for +# hard(fp). This is necessary to pick up the correct rtld_test binary. +# All other architectures default to empty. +ifeq ($(TARGET_ARCH),armv7l) + TARGET_ARCH_ABI ?= gnueabi +endif +TARGET_ARCH_ABI ?= + OUTPUTDIR ?= _out/$(TARGET_OS)_$(TARGET_ARCH) NV_QUIET_COMMAND_REMOVED_TARGET_PREFIX ?= @@ -1 +1 @@ -NVIDIA_VERSION = 304.51 +NVIDIA_VERSION = 310.14 |