summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2008-02-12 21:29:01 -0800
committerAaron Plattner <aplattner@nvidia.com>2008-02-12 21:29:01 -0800
commitd5b457d81ca5e55e403d5a04d0982d6a75d5f924 (patch)
treef04f5c90b2a619700bcce0814bc161259fc46e3e
parent9d2899dd01e78209d5a6f0428bd52c22a9245b48 (diff)
169.09169.09
-rw-r--r--src/gtk+-2.x/ctkdisplayconfig.c17
-rw-r--r--src/gtk+-2.x/ctkframelock.c10
-rw-r--r--src/gtk+-2.x/ctkpowermizer.c196
-rw-r--r--src/gtk+-2.x/ctkpowermizer.h1
-rw-r--r--src/gtk+-2.x/ctkutils.c27
-rw-r--r--src/gtk+-2.x/ctkutils.h2
-rw-r--r--src/libXNVCtrl/NVCtrl.h27
-rw-r--r--src/libXNVCtrl/libXNVCtrl.abin17180 -> 17180 bytes
-rw-r--r--src/parse.c1
9 files changed, 261 insertions, 20 deletions
diff --git a/src/gtk+-2.x/ctkdisplayconfig.c b/src/gtk+-2.x/ctkdisplayconfig.c
index cdea7d9..9206323 100644
--- a/src/gtk+-2.x/ctkdisplayconfig.c
+++ b/src/gtk+-2.x/ctkdisplayconfig.c
@@ -6548,6 +6548,7 @@ static Bool add_monitor_to_xconfig(nvDisplayPtr display, XConfigPtr config,
char *v_source = NULL;
char *h_source = NULL;
float min, max;
+ unsigned int i, j, len;
monitor = (XConfigMonitorPtr)calloc(1, sizeof(XConfigMonitorRec));
if (!monitor) goto fail;
@@ -6555,8 +6556,20 @@ static Bool add_monitor_to_xconfig(nvDisplayPtr display, XConfigPtr config,
monitor->identifier = (char *)malloc(32);
snprintf(monitor->identifier, 32, "Monitor%d", monitor_id);
monitor->vendor = xconfigStrdup("Unknown"); /* XXX */
- monitor->modelname = xconfigStrdup(display->name);
-
+
+ /* Copy the model name string, stripping any '"' characters */
+
+ len = strlen(display->name);
+ monitor->modelname = (char *)malloc(len + 1);
+ for (i = 0, j = 0; i < len; i++, j++) {
+ if (display->name[i] == '\"') {
+ if (++i >= len)
+ break;
+ }
+ monitor->modelname[j] = display->name[i];
+ }
+ monitor->modelname[j] = '\0';
+
/* Get the Horizontal Sync ranges from nv-control */
ret = NvCtrlGetStringDisplayAttribute
diff --git a/src/gtk+-2.x/ctkframelock.c b/src/gtk+-2.x/ctkframelock.c
index 4b376c7..71898ed 100644
--- a/src/gtk+-2.x/ctkframelock.c
+++ b/src/gtk+-2.x/ctkframelock.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <assert.h>
+#include "ctkutils.h"
#include "ctkframelock.h"
#include "ctkhelp.h"
#include "ctkevent.h"
@@ -778,17 +779,12 @@ GtkWidget *my_toggle_button_new_with_label(const gchar *txt,
*/
void update_image(GtkWidget *container, GtkWidget *new_image)
{
- GList *list;
+ ctk_empty_container(container);
- list = gtk_container_get_children(GTK_CONTAINER(container));
- if (list) {
- gtk_container_remove(GTK_CONTAINER(container),
- (GtkWidget *)(list->data));
- g_list_free(list);
- }
gtk_box_pack_start(GTK_BOX(container),
ctk_image_dupe(GTK_IMAGE(new_image)),
FALSE, FALSE, 0);
+
gtk_widget_show_all(container);
}
diff --git a/src/gtk+-2.x/ctkpowermizer.c b/src/gtk+-2.x/ctkpowermizer.c
index c942656..3768b50 100644
--- a/src/gtk+-2.x/ctkpowermizer.c
+++ b/src/gtk+-2.x/ctkpowermizer.c
@@ -22,13 +22,21 @@
*
*/
+#include <stdlib.h>
+#include <string.h>
+
#include <gtk/gtk.h>
#include <NvCtrlAttributes.h>
+#include "msg.h"
+
+#include "ctkutils.h"
#include "ctkhelp.h"
#include "ctkpowermizer.h"
#include "ctkimage.h"
+
+
#define FRAME_PADDING 10
#define DEFAULT_UPDATE_POWERMIZER_INFO_TIME_INTERVAL 1000
@@ -88,6 +96,152 @@ GType ctk_powermizer_get_type(void)
} /* ctk_powermizer_get_type() */
+
+
+typedef struct {
+ gint perf_level;
+ gint nvclock;
+ gint memclock;
+} perfModeEntry, * perfModeEntryPtr;
+
+
+static void apply_perf_mode_token(char *token, char *value, void *data)
+{
+ perfModeEntryPtr pEntry = (perfModeEntryPtr) data;
+
+ if (!strcasecmp("perf", token)) {
+ pEntry->perf_level = atoi(value);
+ } else if (!strcasecmp("nvclock", token)) {
+ pEntry->nvclock = atoi(value);
+ } else if (!strcasecmp("memclock", token)) {
+ pEntry->memclock = atoi(value);
+ } else {
+ nv_warning_msg("Unknown Perf Mode token value pair: %s=%s",
+ token, value);
+ }
+}
+
+
+static void update_perf_mode_table(CtkPowermizer *ctk_powermizer,
+ gint perf_level)
+{
+ GtkWidget *table;
+ GtkWidget *label;
+ char *perf_modes = NULL;
+ char *tokens;
+ char tmp_str[24];
+ perfModeEntry entry;
+ gint ret;
+ gint row_idx; /* Where to insert into the perf mode table */
+ gboolean active;
+
+ /* Since table cell management in GTK lacks, just remove and rebuild
+ * the table from scratch.
+ */
+
+ /* Dump out the old table */
+
+ ctk_empty_container(ctk_powermizer->performance_table_hbox);
+
+ /* Generate a new table */
+
+ table = gtk_table_new(1, 3, FALSE);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 3);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 15);
+ gtk_container_set_border_width(GTK_CONTAINER(table), 5);
+
+ gtk_box_pack_start(GTK_BOX(ctk_powermizer->performance_table_hbox),
+ table, FALSE, FALSE, 0);
+
+ label = gtk_label_new("Performance Level");
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+ gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
+ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
+
+ label = gtk_label_new("NV Clock");
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+ gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1,
+ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
+
+ label = gtk_label_new("Memory Clock");
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+ gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1,
+ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
+
+ /* Get the current list of perf levels */
+
+ ret = NvCtrlGetStringAttribute(ctk_powermizer->attribute_handle,
+ NV_CTRL_STRING_PERFORMANCE_MODES,
+ &perf_modes);
+
+ if (ret != NvCtrlSuccess) {
+ gtk_widget_show_all(table);
+ /* Bail */
+ return;
+ }
+
+ /* Parse the perf levels and populate the table */
+
+ row_idx = 1;
+ for (tokens = strtok(perf_modes, ";");
+ tokens;
+ tokens = strtok(NULL, ";")) {
+
+ /* Invalidate perf mode entry */
+ entry.perf_level = -1;
+ entry.nvclock = -1;
+ entry.memclock = -1;
+
+ parse_token_value_pairs(tokens, apply_perf_mode_token,
+ &entry);
+
+ /* Only add complete perf mode entries */
+ if ((entry.perf_level != -1) &&
+ (entry.nvclock != -1) &&
+ (entry.memclock != -1)) {
+
+ active = (entry.perf_level == perf_level) ? TRUE : FALSE;
+
+ /* XXX Assume the perf levels are sorted by the server */
+
+ gtk_table_resize(GTK_TABLE(table), row_idx+1, 3);
+
+ g_snprintf(tmp_str, 24, "%d", entry.perf_level);
+ label = gtk_label_new(tmp_str);
+ gtk_widget_set_sensitive(label, active);
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+ gtk_table_attach(GTK_TABLE(table), label, 0, 1, row_idx, row_idx+1,
+ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
+
+ g_snprintf(tmp_str, 24, "%d MHz", entry.nvclock);
+ label = gtk_label_new(tmp_str);
+ gtk_widget_set_sensitive(label, active);
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+ gtk_table_attach(GTK_TABLE(table), label, 1, 2, row_idx, row_idx+1,
+ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
+
+ g_snprintf(tmp_str, 24, "%d MHz", entry.memclock);
+ label = gtk_label_new(tmp_str);
+ gtk_widget_set_sensitive(label, active);
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+ gtk_table_attach(GTK_TABLE(table), label, 2, 3, row_idx, row_idx+1,
+ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
+
+ row_idx++;
+ } else {
+ nv_warning_msg("Incomplete Perf Mode (perf=%d, nvclock=%d,"
+ " memclock=%d)",
+ entry.perf_level, entry.nvclock, entry.memclock);
+ }
+ }
+
+ gtk_widget_show_all(table);
+
+ XFree(perf_modes);
+}
+
+
+
static gboolean update_powermizer_info(gpointer user_data)
{
gint power_source, perf_mode, adaptive_clock, perf_level;
@@ -95,12 +249,14 @@ static gboolean update_powermizer_info(gpointer user_data)
CtkPowermizer *ctk_powermizer;
NvCtrlAttributeHandle *handle;
- gint ret; gchar *s;
+ gint ret;
+ gchar *s;
ctk_powermizer = CTK_POWERMIZER(user_data);
handle = ctk_powermizer->attribute_handle;
- ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE, &adaptive_clock);
+ ret = NvCtrlGetAttribute(handle, NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE,
+ &adaptive_clock);
if (ret != NvCtrlSuccess) {
return FALSE;
}
@@ -182,7 +338,10 @@ static gboolean update_powermizer_info(gpointer user_data)
gtk_label_set_text(GTK_LABEL(ctk_powermizer->performance_mode), s);
g_free(s);
+ /* update the perf table */
+ update_perf_mode_table(ctk_powermizer, perf_level);
+
return TRUE;
}
@@ -244,7 +403,7 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
/* set container properties for the CtkPowermizer widget */
- gtk_box_set_spacing(GTK_BOX(ctk_powermizer), 7);
+ gtk_box_set_spacing(GTK_BOX(ctk_powermizer), 5);
/* banner */
@@ -263,7 +422,7 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
hsep = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(hbox), hsep, TRUE, TRUE, 5);
- table = gtk_table_new(15, 2, FALSE);
+ table = gtk_table_new(17, 2, FALSE);
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
gtk_table_set_row_spacings(GTK_TABLE(table), 3);
gtk_table_set_col_spacings(GTK_TABLE(table), 15);
@@ -347,11 +506,10 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
ctk_config_set_tooltip(ctk_config, eventbox, __power_source_help);
ctk_powermizer->power_source = label;
-
/* Performance Level */
hbox2 = gtk_hbox_new(FALSE, 0);
- gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 13, 14,
+ gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 14, 15,
GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
label = gtk_label_new("Performance Level:");
@@ -359,7 +517,7 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
eventbox = gtk_event_box_new();
- gtk_table_attach(GTK_TABLE(table), eventbox, 1, 2, 13, 14,
+ gtk_table_attach(GTK_TABLE(table), eventbox, 1, 2, 14, 15,
GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
label = gtk_label_new(NULL);
@@ -371,7 +529,7 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
/* Performance Mode */
hbox2 = gtk_hbox_new(FALSE, 0);
- gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 14, 15,
+ gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 15, 16,
GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
label = gtk_label_new("Performance Mode:");
@@ -379,15 +537,33 @@ GtkWidget* ctk_powermizer_new(NvCtrlAttributeHandle *handle,
gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
eventbox = gtk_event_box_new();
- gtk_table_attach(GTK_TABLE(table), eventbox, 1, 2, 14, 15,
+ gtk_table_attach(GTK_TABLE(table), eventbox, 1, 2, 15, 16,
GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
label = gtk_label_new(NULL);
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(eventbox), label);
- ctk_config_set_tooltip(ctk_config, eventbox, __performance_mode_short_help);
+ ctk_config_set_tooltip(ctk_config, eventbox,
+ __performance_mode_short_help);
ctk_powermizer->performance_mode = label;
+ /* Available Performance Level Title */
+
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new("Performance Levels");
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+ hsep = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(hbox), hsep, TRUE, TRUE, 5);
+
+ /* Available Performance Level Table */
+
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+ ctk_powermizer->performance_table_hbox = hbox;
+
/* Register a timer callback to update the temperatures */
s = g_strdup_printf("PowerMizer Monitor (GPU %d)",
diff --git a/src/gtk+-2.x/ctkpowermizer.h b/src/gtk+-2.x/ctkpowermizer.h
index 175515b..fd25df1 100644
--- a/src/gtk+-2.x/ctkpowermizer.h
+++ b/src/gtk+-2.x/ctkpowermizer.h
@@ -64,6 +64,7 @@ struct _CtkPowermizer
GtkWidget *power_source;
GtkWidget *performance_level;
GtkWidget *performance_mode;
+ GtkWidget *performance_table_hbox;
};
struct _CtkPowermizerClass
diff --git a/src/gtk+-2.x/ctkutils.c b/src/gtk+-2.x/ctkutils.c
index c25e0f9..74867ca 100644
--- a/src/gtk+-2.x/ctkutils.c
+++ b/src/gtk+-2.x/ctkutils.c
@@ -141,3 +141,30 @@ void ctk_display_warning_msg(GtkWidget *parent, gchar * msg)
}
} /* ctk_display_warning_msg() */
+
+
+
+/** ctk_empty_container() ********************************************
+ *
+ * Removes all (non internal) children widgets from a container
+ *
+ * XXX It might be useful later on to allow a callback to be called
+ * for each widget that gets removed etc.
+ *
+ **/
+
+void ctk_empty_container(GtkWidget *container)
+{
+ GList *list;
+ GList *node;
+
+ list = gtk_container_get_children(GTK_CONTAINER(container));
+ node = list;
+ while (node) {
+ gtk_container_remove(GTK_CONTAINER(container),
+ (GtkWidget *)(node->data));
+ node = node->next;
+ }
+ g_list_free(list);
+
+} /* ctk_empty_container() */
diff --git a/src/gtk+-2.x/ctkutils.h b/src/gtk+-2.x/ctkutils.h
index bc387d6..148a0b0 100644
--- a/src/gtk+-2.x/ctkutils.h
+++ b/src/gtk+-2.x/ctkutils.h
@@ -40,6 +40,8 @@ void ctk_display_error_msg(GtkWidget *parent, gchar *msg);
void ctk_display_warning_msg(GtkWidget *parent, gchar *msg);
+void ctk_empty_container(GtkWidget *);
+
G_END_DECLS
#endif /* __CTK_UTILS_H__ */
diff --git a/src/libXNVCtrl/NVCtrl.h b/src/libXNVCtrl/NVCtrl.h
index 865d5c0..13398aa 100644
--- a/src/libXNVCtrl/NVCtrl.h
+++ b/src/libXNVCtrl/NVCtrl.h
@@ -3564,8 +3564,33 @@
#define NV_CTRL_STRING_SLI_MODE 28 /* R---*/
+/*
+ * NV_CTRL_STRING_PERFORMANCE_MODES - returns a string with all the
+ * performance modes defined for this GPU along with their associated
+ * NV Clock and Memory Clock values.
+ *
+ * Each performance modes are returned as a comma-separated list of
+ * "token=value" pairs. Each set of performance mode tokens are separated
+ * by a ";". Valid tokens:
+ *
+ * Token Value
+ * "perf" integer - the Performance level
+ * "nvClock" integer - the GPU clocks (in MHz) for the perf level
+ * "memClock" integer - the memory clocks (in MHz) for the perf level
+ *
+ *
+ * Example:
+ *
+ * perf=0, nvclock=500, memclock=505 ; perf=1, nvclock=650, memclock=505
+ *
+ * This attribute may be queried through XNVCTRLQueryTargetStringAttribute()
+ * using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target.
+ */
+
+#define NV_CTRL_STRING_PERFORMANCE_MODES 29 /* R--G */
+
#define NV_CTRL_STRING_LAST_ATTRIBUTE \
- NV_CTRL_STRING_SLI_MODE
+ NV_CTRL_STRING_PERFORMANCE_MODES
/**************************************************************************/
diff --git a/src/libXNVCtrl/libXNVCtrl.a b/src/libXNVCtrl/libXNVCtrl.a
index 092eacb..16d29e6 100644
--- a/src/libXNVCtrl/libXNVCtrl.a
+++ b/src/libXNVCtrl/libXNVCtrl.a
Binary files differ
diff --git a/src/parse.c b/src/parse.c
index 803ee89..ce0f7d8 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -208,6 +208,7 @@ AttributeTableEntry attributeTable[] = {
{ "GPU2DClockFreqs", NV_CTRL_GPU_2D_CLOCK_FREQS, N|P },
{ "GPU3DClockFreqs", NV_CTRL_GPU_3D_CLOCK_FREQS, N|P },
{ "GPUCurrentClockFreqs", NV_CTRL_GPU_CURRENT_CLOCK_FREQS, N|P },
+ { "GPUPerfModes", NV_CTRL_STRING_PERFORMANCE_MODES, S|N },
{ "NvidiaDriverVersion", NV_CTRL_STRING_NVIDIA_DRIVER_VERSION, S|N },
{ "NvControlVersion", NV_CTRL_STRING_NV_CONTROL_VERSION, S|N },