summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2010-09-28 13:10:09 -0700
committerAaron Plattner <aplattner@nvidia.com>2010-09-28 13:10:09 -0700
commitf74cb78f369bf98ae8fc6851c4e1879d708be141 (patch)
tree88166f5bf901836a928ffa54974a039c97326e0d
parent98d47fcfbb9dc1ae90e194c101c1370cf715d742 (diff)
260.19.06260.19.06
-rw-r--r--src/gtk+-2.x/ctkcolorcontrols.c180
-rw-r--r--src/gtk+-2.x/ctkcolorcontrols.h2
-rw-r--r--src/gtk+-2.x/ctkditheringcontrols.c290
-rw-r--r--src/gtk+-2.x/ctkditheringcontrols.h5
-rw-r--r--src/gtk+-2.x/ctkevent.c4
-rw-r--r--src/libXNVCtrl/NVCtrl.h26
-rw-r--r--src/parse.c4
-rw-r--r--version.mk2
8 files changed, 408 insertions, 105 deletions
diff --git a/src/gtk+-2.x/ctkcolorcontrols.c b/src/gtk+-2.x/ctkcolorcontrols.c
index 6a2c23a..188a3bf 100644
--- a/src/gtk+-2.x/ctkcolorcontrols.c
+++ b/src/gtk+-2.x/ctkcolorcontrols.c
@@ -45,7 +45,8 @@ static gboolean build_color_space_table(CtkColorControls *ctk_color_controls,
static gint map_nvctrl_value_to_table(CtkColorControls *ctk_color_controls,
gint val);
-static Bool update_color_space_menu_info(gpointer user_data);
+static
+gboolean update_color_space_menu_info(CtkColorControls *ctk_color_controls);
static void color_space_menu_changed(GtkOptionMenu *color_space_menu,
gpointer user_data);
@@ -54,7 +55,7 @@ static void color_range_menu_changed(GtkOptionMenu *color_range_menu,
static void color_control_update_received(GtkObject *object, gpointer arg1,
gpointer user_data);
-
+static gboolean setup_color_range_dropdown(CtkColorControls *ctk_color_controls);
static
void post_color_range_update(CtkColorControls *ctk_color_controls,
gint color_range);
@@ -188,11 +189,18 @@ GtkWidget* ctk_color_controls_new(NvCtrlAttributeHandle *handle,
(GTK_OPTION_MENU(ctk_color_controls->color_space_menu),
menu);
+ /* If dropdown only has one item, disable it */
+ if (ctk_color_controls->color_space_table_size > 1) {
+ gtk_widget_set_sensitive(ctk_color_controls->color_space_menu, True);
+ } else {
+ gtk_widget_set_sensitive(ctk_color_controls->color_space_menu, False);
+ }
+
+
g_signal_connect(G_OBJECT(ctk_color_controls->color_space_menu),
"changed", G_CALLBACK(color_space_menu_changed),
(gpointer) ctk_color_controls);
-
/* pack the label & drop down */
hbox = gtk_hbox_new(FALSE, 0);
gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 0, 1,
@@ -218,20 +226,8 @@ GtkWidget* ctk_color_controls_new(NvCtrlAttributeHandle *handle,
/* Build color widgets & pack them in table */
/* dropdown list for color range */
- menu = gtk_menu_new();
-
- menu_item = gtk_menu_item_new_with_label("Full");
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
- gtk_widget_show(menu_item);
-
- menu_item = gtk_menu_item_new_with_label("Limited");
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
- gtk_widget_show(menu_item);
ctk_color_controls->color_range_menu = gtk_option_menu_new();
- gtk_option_menu_set_menu
- (GTK_OPTION_MENU(ctk_color_controls->color_range_menu),
- menu);
g_signal_connect(G_OBJECT(ctk_color_controls->color_range_menu),
"changed", G_CALLBACK(color_range_menu_changed),
@@ -278,49 +274,21 @@ GtkWidget* ctk_color_controls_new(NvCtrlAttributeHandle *handle,
*/
void ctk_color_controls_setup(CtkColorControls *ctk_color_controls)
{
- gint val;
-
if (!ctk_color_controls) {
return;
}
- /* color range */
- if (NvCtrlSuccess !=
- NvCtrlGetDisplayAttribute(ctk_color_controls->handle,
- ctk_color_controls->display_device_mask,
- NV_CTRL_COLOR_RANGE, &val)) {
- val = NV_CTRL_COLOR_RANGE_FULL;
- }
-
- g_signal_handlers_block_by_func
- (G_OBJECT(ctk_color_controls->color_range_menu),
- G_CALLBACK(color_range_menu_changed),
- (gpointer) ctk_color_controls);
-
- gtk_option_menu_set_history
- (GTK_OPTION_MENU(ctk_color_controls->color_range_menu),
- val);
-
- g_signal_handlers_unblock_by_func
- (G_OBJECT(ctk_color_controls->color_range_menu),
- G_CALLBACK(color_range_menu_changed),
- (gpointer) ctk_color_controls);
-
/* color space */
- if (!update_color_space_menu_info
- ((gpointer)ctk_color_controls)) {
+ if (!update_color_space_menu_info(ctk_color_controls)) {
gtk_widget_set_sensitive(ctk_color_controls->color_controls_main,
FALSE);
gtk_widget_hide_all(ctk_color_controls->color_controls_main);
}
-
} /* ctk_color_controls_setup() */
-static Bool update_color_space_menu_info(gpointer user_data)
+static gboolean update_color_space_menu_info(CtkColorControls *ctk_color_controls)
{
- CtkColorControls *ctk_color_controls =
- CTK_COLOR_CONTROLS(user_data);
gint color_space = NV_CTRL_COLOR_SPACE_RGB;
/* color space */
@@ -350,6 +318,9 @@ static Bool update_color_space_menu_info(gpointer user_data)
G_CALLBACK(color_space_menu_changed),
(gpointer) ctk_color_controls);
+ /* dynamically regenerate color range dropdown */
+ setup_color_range_dropdown(ctk_color_controls);
+
return True;
} /* update_color_space_menu_info() */
@@ -358,8 +329,8 @@ void post_color_range_update(CtkColorControls *ctk_color_controls,
gint color_range)
{
static const char *color_range_table[] = {
- "Full", /* NV_CTRL_COLOR_RANGE_FULL */
- "Limited" /* NV_CTRL_COLOR_RANGE_LIMITED */
+ "Full", /* NV_CTRL_COLOR_RANGE_FULL */
+ "Limited", /* NV_CTRL_COLOR_RANGE_LIMITED */
};
ctk_config_statusbar_message(ctk_color_controls->ctk_config,
@@ -392,16 +363,7 @@ static void color_range_menu_changed(GtkOptionMenu *color_range_menu,
gint history, color_range = NV_CTRL_COLOR_RANGE_FULL;
history = gtk_option_menu_get_history(color_range_menu);
-
- switch (history) {
- case 1:
- color_range = NV_CTRL_COLOR_RANGE_LIMITED;
- break;
- default:
- case 0:
- color_range = NV_CTRL_COLOR_RANGE_FULL;
- break;
- }
+ color_range = ctk_color_controls->color_range_table[history];
NvCtrlSetDisplayAttribute(ctk_color_controls->handle,
ctk_color_controls->display_device_mask,
@@ -422,8 +384,7 @@ static void color_range_menu_changed(GtkOptionMenu *color_range_menu,
G_CALLBACK(color_range_menu_changed),
(gpointer) ctk_color_controls);
- /* reflecting the change in color range to other widgets & reset button */
- ctk_color_controls_setup(ctk_color_controls);
+ /* reflecting the change to statusbar message and the reset button */
post_color_range_update(ctk_color_controls, color_range);
gtk_widget_set_sensitive(ctk_color_controls->reset_button, TRUE);
@@ -566,6 +527,107 @@ static gboolean build_color_space_table(CtkColorControls *ctk_color_controls,
} /* build_color_space_table() */
+
+/*
+ * setup_color_range_dropdown() - dynamically generate dropdown list for
+ * color range depending on selected color space.
+ */
+static gboolean setup_color_range_dropdown(CtkColorControls *ctk_color_controls)
+{
+ gint i, n = 0, color_range_count = 0;
+ gint mask, val;
+ ReturnStatus ret;
+ GtkWidget *menu, *menu_item;
+ NVCTRLAttributeValidValuesRec valid;
+
+ ret = NvCtrlGetValidDisplayAttributeValues(ctk_color_controls->handle,
+ ctk_color_controls->display_device_mask,
+ NV_CTRL_COLOR_RANGE,
+ &valid);
+
+ if (valid.type != ATTRIBUTE_TYPE_INT_BITS) {
+ return FALSE;
+ }
+ mask = valid.u.bits.ints;
+ /* count no. of supported color space */
+ while(mask) {
+ mask = mask & (mask - 1);
+ color_range_count++;
+ }
+
+ if (ctk_color_controls->color_range_table) {
+ free(ctk_color_controls->color_range_table);
+ ctk_color_controls->color_range_table_size = 0;
+ }
+ ctk_color_controls->color_range_table_size = color_range_count;
+ ctk_color_controls->color_range_table =
+ calloc(color_range_count, sizeof(ctk_color_controls->color_range_table[0]));
+ if (!ctk_color_controls->color_range_table) {
+ return FALSE;
+ }
+
+ for (i = 0, n = 0; n < ctk_color_controls->color_range_table_size; i++) {
+ if (valid.u.bits.ints & (1 << i)) {
+ ctk_color_controls->color_range_table[n] = i;
+ n++;
+ }
+ }
+
+ /* dropdown list for color range */
+ menu = gtk_menu_new();
+
+ for (i = 0; i < ctk_color_controls->color_range_table_size; i++) {
+ switch (ctk_color_controls->color_range_table[i]) {
+ case NV_CTRL_COLOR_RANGE_FULL:
+ menu_item = gtk_menu_item_new_with_label("Full");
+ break;
+ default:
+ case NV_CTRL_COLOR_RANGE_LIMITED:
+ menu_item = gtk_menu_item_new_with_label("Limited");
+ break;
+ }
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ gtk_widget_show(menu_item);
+ }
+
+ /* color range */
+ if (NvCtrlSuccess !=
+ NvCtrlGetDisplayAttribute(ctk_color_controls->handle,
+ ctk_color_controls->display_device_mask,
+ NV_CTRL_COLOR_RANGE, &val)) {
+ val = NV_CTRL_COLOR_RANGE_FULL;
+ }
+
+ g_signal_handlers_block_by_func
+ (G_OBJECT(ctk_color_controls->color_range_menu),
+ G_CALLBACK(color_range_menu_changed),
+ (gpointer) ctk_color_controls);
+
+ gtk_option_menu_set_menu
+ (GTK_OPTION_MENU(ctk_color_controls->color_range_menu),
+ menu);
+
+ gtk_option_menu_set_history
+ (GTK_OPTION_MENU(ctk_color_controls->color_range_menu),
+ val);
+
+ /* If dropdown only has one item, disable it */
+ if (ctk_color_controls->color_range_table_size > 1) {
+ gtk_widget_set_sensitive(ctk_color_controls->color_range_menu, True);
+ } else {
+ gtk_widget_set_sensitive(ctk_color_controls->color_range_menu, False);
+ }
+
+ g_signal_handlers_unblock_by_func
+ (G_OBJECT(ctk_color_controls->color_range_menu),
+ G_CALLBACK(color_range_menu_changed),
+ (gpointer) ctk_color_controls);
+
+ return TRUE;
+
+} /* setup_color_range_dropdown() */
+
+
static gint map_nvctrl_value_to_table(CtkColorControls *ctk_color_controls,
gint val)
{
diff --git a/src/gtk+-2.x/ctkcolorcontrols.h b/src/gtk+-2.x/ctkcolorcontrols.h
index 5faa6ab..d48db26 100644
--- a/src/gtk+-2.x/ctkcolorcontrols.h
+++ b/src/gtk+-2.x/ctkcolorcontrols.h
@@ -70,6 +70,8 @@ struct _CtkColorControls
gint display_device_mask;
gint *color_space_table;
gint color_space_table_size;
+ gint *color_range_table;
+ gint color_range_table_size;
gint default_color_config;
gint default_color_space;
char *name;
diff --git a/src/gtk+-2.x/ctkditheringcontrols.c b/src/gtk+-2.x/ctkditheringcontrols.c
index 6b1de92..d3e4b60 100644
--- a/src/gtk+-2.x/ctkditheringcontrols.c
+++ b/src/gtk+-2.x/ctkditheringcontrols.c
@@ -45,8 +45,10 @@ static gboolean build_dithering_mode_table(CtkDitheringControls *ctk_dithering_c
static gint map_nvctrl_value_to_table(CtkDitheringControls *ctk_dithering_controls,
gint val);
-static Bool update_dithering_mode_menu_info(gpointer user_data);
+static Bool update_dithering_info(gpointer user_data);
+static void dithering_depth_menu_changed(GtkOptionMenu *dithering_depth_menu,
+ gpointer user_data);
static void dithering_mode_menu_changed(GtkOptionMenu *dithering_mode_menu,
gpointer user_data);
static void dithering_config_menu_changed(GtkOptionMenu *dithering_config_menu,
@@ -63,15 +65,21 @@ static
void post_dithering_mode_update(CtkDitheringControls *ctk_dithering_controls,
gint dithering_mode);
+static
+void post_dithering_depth_update(CtkDitheringControls *ctk_dithering_controls,
+ gint dithering_depth);
+
/* macros */
#define FRAME_PADDING 5
/* help text */
static const char * __dithering_help =
"The Dithering Controls show the current state of dithering and allow "
-"changing the dithering configuration and/or mode. Dithering will be "
-"performed when dithering is enabled here, and the panel's bitdepth is "
-"less than that of the GPU's internal pixel pipeline.";
+"changing the dithering configuration, mode and/or depth. Dithering will "
+"be performed when dithering is enabled here, and the panel's bitdepth is "
+"less than that of the GPU's internal pixel pipeline. The depth can be "
+"adjusted to 6 or 8 bits per channel depending on the type of display "
+"device.";
GType ctk_dithering_controls_get_type(void)
{
@@ -110,8 +118,8 @@ GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle,
CtkDitheringControls *ctk_dithering_controls;
GtkWidget *frame, *vbox, *hbox, *label, *eventbox;
GtkWidget *menu, *table, *menu_item = NULL, *separator;
- ReturnStatus ret1, ret2;
- NVCTRLAttributeValidValuesRec valid1, valid2;
+ ReturnStatus ret1, ret2, ret3;
+ NVCTRLAttributeValidValuesRec valid1, valid2, valid3;
gint i;
/* check if dithering configuration is supported */
@@ -121,10 +129,13 @@ GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle,
ret2 = NvCtrlGetValidDisplayAttributeValues(handle, display_device_mask,
NV_CTRL_DITHERING_MODE,
&valid2);
+ ret3 = NvCtrlGetValidDisplayAttributeValues(handle, display_device_mask,
+ NV_CTRL_DITHERING_DEPTH,
+ &valid3);
- if ((ret1 != NvCtrlSuccess) || (ret2 != NvCtrlSuccess) ||
- (valid1.type != ATTRIBUTE_TYPE_INTEGER) ||
- (valid2.type != ATTRIBUTE_TYPE_INT_BITS)) {
+ if ((ret1 != NvCtrlSuccess) || (valid1.type != ATTRIBUTE_TYPE_INTEGER) ||
+ (ret2 != NvCtrlSuccess) || (valid2.type != ATTRIBUTE_TYPE_INT_BITS) ||
+ (ret3 != NvCtrlSuccess) || (valid3.type != ATTRIBUTE_TYPE_INTEGER)) {
return NULL;
}
@@ -158,7 +169,7 @@ GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle,
gtk_box_pack_start(GTK_BOX(hbox), eventbox, FALSE, FALSE, 0);
ctk_config_set_tooltip(ctk_config, eventbox, __dithering_help);
- table = gtk_table_new(3, 4, FALSE);
+ table = gtk_table_new(5, 4, FALSE);
gtk_container_add(GTK_CONTAINER(frame), table);
gtk_table_set_row_spacings(GTK_TABLE(table), 5);
gtk_table_set_col_spacings(GTK_TABLE(table), 15);
@@ -221,7 +232,7 @@ GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle,
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- /* H-bar */
+ /* H-bar 1 */
vbox = gtk_vbox_new(FALSE, 0);
separator = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 0);
@@ -290,6 +301,70 @@ GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle,
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+ /* H-bar 2 */
+ vbox = gtk_vbox_new(FALSE, 0);
+ separator = gtk_hseparator_new();
+ gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 0);
+ gtk_table_attach(GTK_TABLE(table), vbox, 0, 4, 3, 4,
+ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
+
+ /* dithering depth */
+ menu = gtk_menu_new();
+
+ menu_item = gtk_menu_item_new_with_label("Auto");
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ gtk_widget_show(menu_item);
+
+ menu_item = gtk_menu_item_new_with_label("6 bpc");
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ gtk_widget_show(menu_item);
+
+ menu_item = gtk_menu_item_new_with_label("8 bpc");
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ gtk_widget_show(menu_item);
+
+ ctk_dithering_controls->dithering_depth_menu = gtk_option_menu_new();
+ gtk_option_menu_set_menu
+ (GTK_OPTION_MENU(ctk_dithering_controls->dithering_depth_menu),
+ menu);
+
+ g_signal_connect(G_OBJECT(ctk_dithering_controls->dithering_depth_menu),
+ "changed", G_CALLBACK(dithering_depth_menu_changed),
+ (gpointer) ctk_dithering_controls);
+
+ /* Packing label & dropdown */
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 4, 5,
+ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
+
+ label = gtk_label_new("Depth: ");
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new(FALSE, 0);
+ ctk_dithering_controls->dithering_depth_box = hbox;
+ gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 4, 5,
+ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
+ gtk_box_pack_start(GTK_BOX(hbox),
+ ctk_dithering_controls->dithering_depth_menu,
+ FALSE, FALSE, 0);
+
+ /* Build CurrentDitheringDepth widget */
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_table_attach(GTK_TABLE(table), hbox, 2, 3, 4, 5,
+ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
+ label = gtk_label_new("Current Depth: ");
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_table_attach(GTK_TABLE(table), hbox, 3, 4, 4, 5,
+ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0);
+ label = gtk_label_new(NULL);
+ ctk_dithering_controls->dithering_current_depth = label;
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
gtk_widget_show_all(GTK_WIDGET(object));
ctk_dithering_controls_setup(ctk_dithering_controls);
@@ -303,6 +378,10 @@ GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle,
G_CALLBACK(dithering_update_received),
(gpointer) ctk_dithering_controls);
g_signal_connect(G_OBJECT(ctk_event),
+ CTK_EVENT_NAME(NV_CTRL_DITHERING_DEPTH),
+ G_CALLBACK(dithering_update_received),
+ (gpointer) ctk_dithering_controls);
+ g_signal_connect(G_OBJECT(ctk_event),
CTK_EVENT_NAME(NV_CTRL_CURRENT_DITHERING),
G_CALLBACK(dithering_update_received),
(gpointer) ctk_dithering_controls);
@@ -310,6 +389,10 @@ GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle,
CTK_EVENT_NAME(NV_CTRL_CURRENT_DITHERING_MODE),
G_CALLBACK(dithering_update_received),
(gpointer) ctk_dithering_controls);
+ g_signal_connect(G_OBJECT(ctk_event),
+ CTK_EVENT_NAME(NV_CTRL_CURRENT_DITHERING_DEPTH),
+ G_CALLBACK(dithering_update_received),
+ (gpointer) ctk_dithering_controls);
return GTK_WIDGET(object);
@@ -351,8 +434,7 @@ void ctk_dithering_controls_setup(CtkDitheringControls *ctk_dithering_controls)
G_CALLBACK(dithering_config_menu_changed),
(gpointer) ctk_dithering_controls);
- if (!update_dithering_mode_menu_info
- ((gpointer)ctk_dithering_controls)) {
+ if (!update_dithering_info((gpointer)ctk_dithering_controls)) {
gtk_widget_set_sensitive(ctk_dithering_controls->dithering_controls_main,
FALSE);
gtk_widget_hide_all(ctk_dithering_controls->dithering_controls_main);
@@ -361,20 +443,42 @@ void ctk_dithering_controls_setup(CtkDitheringControls *ctk_dithering_controls)
} /* ctk_dithering_controls_setup() */
-static Bool update_dithering_mode_menu_info(gpointer user_data)
+static Bool update_dithering_info(gpointer user_data)
{
CtkDitheringControls *ctk_dithering_controls =
CTK_DITHERING_CONTROLS(user_data);
- gint val, dithering_mode = NV_CTRL_DITHERING_MODE_AUTO;
+ gint val, dithering_mode, dithering_depth;
+
+ /* current dithering */
+ if (NvCtrlSuccess !=
+ NvCtrlGetDisplayAttribute(ctk_dithering_controls->handle,
+ ctk_dithering_controls->display_device_mask,
+ NV_CTRL_CURRENT_DITHERING, &val)) {
+ val = NV_CTRL_CURRENT_DITHERING_DISABLED;
+ }
+
+ if (val == NV_CTRL_CURRENT_DITHERING_ENABLED) {
+ gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_current_config),
+ "Enabled");
+ gtk_widget_set_sensitive(ctk_dithering_controls->dithering_mode_box, TRUE);
+ gtk_widget_set_sensitive(ctk_dithering_controls->dithering_depth_box, TRUE);
+ gtk_widget_show(ctk_dithering_controls->dithering_mode_box);
+ gtk_widget_show(ctk_dithering_controls->dithering_depth_box);
+ } else if (val == NV_CTRL_CURRENT_DITHERING_DISABLED) {
+ gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_current_config),
+ "Disabled");
+ gtk_widget_set_sensitive(ctk_dithering_controls->dithering_mode_box, FALSE);
+ gtk_widget_set_sensitive(ctk_dithering_controls->dithering_depth_box, FALSE);
+ }
/* dithering mode */
+ dithering_mode = NV_CTRL_DITHERING_MODE_AUTO;
if (NvCtrlSuccess !=
NvCtrlGetDisplayAttribute(ctk_dithering_controls->handle,
ctk_dithering_controls->display_device_mask,
NV_CTRL_DITHERING_MODE,
&dithering_mode)) {
- free(ctk_dithering_controls->dithering_mode_table);
- return FALSE;
+ goto fail;
}
dithering_mode = map_nvctrl_value_to_table(ctk_dithering_controls,
@@ -394,25 +498,6 @@ static Bool update_dithering_mode_menu_info(gpointer user_data)
G_CALLBACK(dithering_mode_menu_changed),
(gpointer) ctk_dithering_controls);
- /* current dithering */
- if (NvCtrlSuccess !=
- NvCtrlGetDisplayAttribute(ctk_dithering_controls->handle,
- ctk_dithering_controls->display_device_mask,
- NV_CTRL_CURRENT_DITHERING, &val)) {
- val = NV_CTRL_CURRENT_DITHERING_DISABLED;
- }
-
- if (val == NV_CTRL_CURRENT_DITHERING_ENABLED) {
- gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_current_config),
- "Enabled");
- gtk_widget_set_sensitive(ctk_dithering_controls->dithering_mode_box, TRUE);
- gtk_widget_show(ctk_dithering_controls->dithering_mode_box);
- } else if (val == NV_CTRL_CURRENT_DITHERING_DISABLED) {
- gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_current_config),
- "Disabled");
- gtk_widget_set_sensitive(ctk_dithering_controls->dithering_mode_box, FALSE);
- }
-
/* current dithering mode */
dithering_mode = NV_CTRL_CURRENT_DITHERING_MODE_NONE;
if (NvCtrlSuccess !=
@@ -420,8 +505,7 @@ static Bool update_dithering_mode_menu_info(gpointer user_data)
ctk_dithering_controls->display_device_mask,
NV_CTRL_CURRENT_DITHERING_MODE,
&dithering_mode)) {
- free(ctk_dithering_controls->dithering_mode_table);
- return FALSE;
+ goto fail;
}
switch (dithering_mode) {
@@ -440,8 +524,62 @@ static Bool update_dithering_mode_menu_info(gpointer user_data)
break;
}
+ /* dithering depth */
+ dithering_depth = NV_CTRL_DITHERING_DEPTH_AUTO;
+ if (NvCtrlSuccess !=
+ NvCtrlGetDisplayAttribute(ctk_dithering_controls->handle,
+ ctk_dithering_controls->display_device_mask,
+ NV_CTRL_DITHERING_DEPTH,
+ &dithering_depth)) {
+ goto fail;
+ }
+
+ g_signal_handlers_block_by_func
+ (G_OBJECT(ctk_dithering_controls->dithering_depth_menu),
+ G_CALLBACK(dithering_depth_menu_changed),
+ (gpointer) ctk_dithering_controls);
+
+ gtk_option_menu_set_history
+ (GTK_OPTION_MENU(ctk_dithering_controls->dithering_depth_menu),
+ dithering_depth);
+
+ g_signal_handlers_unblock_by_func
+ (G_OBJECT(ctk_dithering_controls->dithering_depth_menu),
+ G_CALLBACK(dithering_depth_menu_changed),
+ (gpointer) ctk_dithering_controls);
+
+ /* current dithering depth */
+ dithering_depth = NV_CTRL_CURRENT_DITHERING_DEPTH_NONE;
+ if (NvCtrlSuccess !=
+ NvCtrlGetDisplayAttribute(ctk_dithering_controls->handle,
+ ctk_dithering_controls->display_device_mask,
+ NV_CTRL_CURRENT_DITHERING_DEPTH,
+ &dithering_depth)) {
+ goto fail;
+ }
+
+ switch (dithering_depth) {
+ case NV_CTRL_CURRENT_DITHERING_DEPTH_6_BITS:
+ gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_current_depth),
+ "6 bpc");
+ break;
+ case NV_CTRL_CURRENT_DITHERING_DEPTH_8_BITS:
+ gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_current_depth),
+ "8 bpc");
+ break;
+ default:
+ case NV_CTRL_CURRENT_DITHERING_DEPTH_NONE:
+ gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_current_depth),
+ "None");
+ break;
+ }
+
return True;
-} /* update_dithering_mode_menu_info() */
+
+ fail:
+ free(ctk_dithering_controls->dithering_mode_table);
+ return False;
+} /* update_dithering_info() */
static
void post_dithering_config_update(CtkDitheringControls *ctk_dithering_controls,
@@ -485,6 +623,27 @@ void post_dithering_mode_update(CtkDitheringControls *ctk_dithering_controls,
ctk_dithering_controls->name);
}
+static
+void post_dithering_depth_update(CtkDitheringControls *ctk_dithering_controls,
+ gint dithering_depth)
+{
+ static const char *dither_depth_table[] = {
+ "Auto", /* NV_CTRL_DITHERING_DEPTH_AUTO */
+ "6 bpc", /* NV_CTRL_DITHERING_DEPTH_6_BITS */
+ "8 bpc" /* NV_CTRL_DITHERING_DEPTH_8_BITS */
+ };
+
+ if (dithering_depth < NV_CTRL_DITHERING_DEPTH_AUTO ||
+ dithering_depth > NV_CTRL_DITHERING_DEPTH_8_BITS) {
+ return;
+ }
+
+ ctk_config_statusbar_message(ctk_dithering_controls->ctk_config,
+ "Dithering depth set to %s for %s.",
+ dither_depth_table[dithering_depth],
+ ctk_dithering_controls->name);
+}
+
static void dithering_config_menu_changed(GtkOptionMenu *dithering_config_menu,
gpointer user_data)
{
@@ -573,6 +732,54 @@ static void dithering_mode_menu_changed(GtkOptionMenu *dithering_mode_menu,
} /* dithering_mode_menu_changed() */
+static void dithering_depth_menu_changed(GtkOptionMenu *dithering_depth_menu,
+ gpointer user_data)
+{
+ CtkDitheringControls *ctk_dithering_controls =
+ CTK_DITHERING_CONTROLS(user_data);
+ gint history, dithering_depth = NV_CTRL_DITHERING_DEPTH_AUTO;
+
+ history = gtk_option_menu_get_history(dithering_depth_menu);
+
+ switch (history) {
+ case 2:
+ dithering_depth = NV_CTRL_DITHERING_DEPTH_8_BITS;
+ break;
+ case 1:
+ dithering_depth = NV_CTRL_DITHERING_DEPTH_6_BITS;
+ break;
+ default:
+ case 0:
+ dithering_depth = NV_CTRL_DITHERING_DEPTH_AUTO;
+ break;
+ }
+
+ NvCtrlSetDisplayAttribute(ctk_dithering_controls->handle,
+ ctk_dithering_controls->display_device_mask,
+ NV_CTRL_DITHERING_DEPTH,
+ dithering_depth);
+
+ g_signal_handlers_block_by_func
+ (G_OBJECT(ctk_dithering_controls->dithering_depth_menu),
+ G_CALLBACK(dithering_depth_menu_changed),
+ (gpointer) ctk_dithering_controls);
+
+ gtk_option_menu_set_history
+ (GTK_OPTION_MENU(ctk_dithering_controls->dithering_depth_menu),
+ dithering_depth);
+
+ g_signal_handlers_unblock_by_func
+ (G_OBJECT(ctk_dithering_controls->dithering_depth_menu),
+ G_CALLBACK(dithering_depth_menu_changed),
+ (gpointer) ctk_dithering_controls);
+
+ /* reflecting the change in configuration to other widgets & reset button */
+ ctk_dithering_controls_setup(ctk_dithering_controls);
+ post_dithering_depth_update(ctk_dithering_controls, dithering_depth);
+ gtk_widget_set_sensitive(ctk_dithering_controls->reset_button, TRUE);
+
+} /* dithering_depth_menu_changed() */
+
/*
* ctk_dithering_controls_reset() - Resets the dithering config (enabled/disabled)
@@ -594,6 +801,11 @@ void ctk_dithering_controls_reset(CtkDitheringControls *ctk_dithering_controls)
NV_CTRL_DITHERING_MODE,
NV_CTRL_DITHERING_MODE_AUTO);
+ NvCtrlSetDisplayAttribute(ctk_dithering_controls->handle,
+ ctk_dithering_controls->display_device_mask,
+ NV_CTRL_DITHERING_DEPTH,
+ NV_CTRL_DITHERING_DEPTH_AUTO);
+
ctk_dithering_controls_setup(ctk_dithering_controls);
} /* ctk_dithering_controls_reset() */
diff --git a/src/gtk+-2.x/ctkditheringcontrols.h b/src/gtk+-2.x/ctkditheringcontrols.h
index 72178a1..9b34844 100644
--- a/src/gtk+-2.x/ctkditheringcontrols.h
+++ b/src/gtk+-2.x/ctkditheringcontrols.h
@@ -62,17 +62,18 @@ struct _CtkDitheringControls
GtkWidget *reset_button;
GtkWidget *dithering_controls_main;
GtkWidget *dithering_mode_box;
+ GtkWidget *dithering_depth_box;
GtkWidget *dithering_config_menu;
GtkWidget *dithering_mode_menu;
+ GtkWidget *dithering_depth_menu;
GtkWidget *dithering_current_config;
GtkWidget *dithering_current_mode;
+ GtkWidget *dithering_current_depth;
gint display_device_mask;
gint *dithering_mode_table;
gint dithering_mode_table_size;
- gint default_dithering_config;
- gint default_dithering_mode;
char *name;
};
diff --git a/src/gtk+-2.x/ctkevent.c b/src/gtk+-2.x/ctkevent.c
index 7acaea6..cabef66 100644
--- a/src/gtk+-2.x/ctkevent.c
+++ b/src/gtk+-2.x/ctkevent.c
@@ -306,8 +306,10 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class)
MAKE_SIGNAL(NV_CTRL_COLOR_RANGE);
MAKE_SIGNAL(NV_CTRL_DITHERING);
MAKE_SIGNAL(NV_CTRL_DITHERING_MODE);
+ MAKE_SIGNAL(NV_CTRL_DITHERING_DEPTH);
MAKE_SIGNAL(NV_CTRL_CURRENT_DITHERING);
MAKE_SIGNAL(NV_CTRL_CURRENT_DITHERING_MODE);
+ MAKE_SIGNAL(NV_CTRL_CURRENT_DITHERING_DEPTH);
MAKE_SIGNAL(NV_CTRL_THERMAL_SENSOR_READING);
MAKE_SIGNAL(NV_CTRL_THERMAL_SENSOR_PROVIDER);
MAKE_SIGNAL(NV_CTRL_THERMAL_SENSOR_TARGET);
@@ -324,7 +326,7 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class)
* knows about.
*/
-#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_GPU_PCIE_MAX_LINK_SPEED
+#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_CURRENT_DITHERING_DEPTH
#warning "There are attributes that do not emit signals!"
#endif
diff --git a/src/libXNVCtrl/NVCtrl.h b/src/libXNVCtrl/NVCtrl.h
index 45d976d..e504816 100644
--- a/src/libXNVCtrl/NVCtrl.h
+++ b/src/libXNVCtrl/NVCtrl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008 NVIDIA, Corporation
+ * Copyright (c) 2010 NVIDIA, Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -3025,7 +3025,29 @@
#define NV_CTRL_GPU_PCIE_MAX_LINK_SPEED 361 /* R--GI */
-#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_GPU_PCIE_MAX_LINK_SPEED
+
+/*
+ * NV_CTRL_DITHERING_DEPTH - Controls the dithering depth when
+ * NV_CTRL_CURRENT_DITHERING is ENABLED. Some displays connected
+ * to the GPU via the DVI or LVDS interfaces cannot display the
+ * full color range of ten bits per channel, so the GPU will
+ * dither to either 6 or 8 bits per channel.
+ */
+#define NV_CTRL_DITHERING_DEPTH 368 /* RWDG */
+#define NV_CTRL_DITHERING_DEPTH_AUTO 0
+#define NV_CTRL_DITHERING_DEPTH_6_BITS 1
+#define NV_CTRL_DITHERING_DEPTH_8_BITS 2
+
+/*
+ * NV_CTRL_CURRENT_DITHERING_DEPTH - Returns the current dithering
+ * depth value.
+ */
+#define NV_CTRL_CURRENT_DITHERING_DEPTH 369 /* R-DG */
+#define NV_CTRL_CURRENT_DITHERING_DEPTH_NONE 0
+#define NV_CTRL_CURRENT_DITHERING_DEPTH_6_BITS 1
+#define NV_CTRL_CURRENT_DITHERING_DEPTH_8_BITS 2
+
+#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_CURRENT_DITHERING_DEPTH
/**************************************************************************/
diff --git a/src/parse.c b/src/parse.c
index 1232947..56fc147 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -278,6 +278,8 @@ AttributeTableEntry attributeTable[] = {
{ "CurrentDithering", NV_CTRL_CURRENT_DITHERING, 0, "Returns the current dithering state: enabled (1), disabled (0)." },
{ "DitheringMode", NV_CTRL_DITHERING_MODE, 0, "Controls the dithering mode when CurrentDithering=1; auto (0), temporally dynamic dithering pattern (1), temporally static dithering pattern (2)." },
{ "CurrentDitheringMode", NV_CTRL_CURRENT_DITHERING_MODE, 0, "Returns the current dithering mode: none (0), temporally dynamic dithering pattern (1), temporally static dithering pattern (2)." },
+ { "DitheringDepth", NV_CTRL_DITHERING_DEPTH, 0, "Controls the dithering depth when CurrentDithering=1; auto (0), 6 bits per channel (1), 8 bits per channel (2)." },
+ { "CurrentDitheringDepth", NV_CTRL_CURRENT_DITHERING_DEPTH, 0, "Returns the current dithering depth: none (0), 6 bits per channel (1), 8 bits per channel (2)." },
{ "DigitalVibrance", NV_CTRL_DIGITAL_VIBRANCE, 0, "Sets the digital vibrance level of the display device." },
{ "ImageSharpening", NV_CTRL_IMAGE_SHARPENING, 0, "Adjusts the sharpness of the display's image quality by amplifying high frequency content." },
{ "ImageSharpeningDefault", NV_CTRL_IMAGE_SHARPENING_DEFAULT, 0, "Returns default value of image sharpening." },
@@ -343,7 +345,7 @@ AttributeTableEntry attributeTable[] = {
* about.
*/
-#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_GPU_PCIE_MAX_LINK_SPEED
+#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_CURRENT_DITHERING_DEPTH
#warning "Have you forgotten to add a new integer attribute to attributeTable?"
#endif
diff --git a/version.mk b/version.mk
index 9a025b4..737097c 100644
--- a/version.mk
+++ b/version.mk
@@ -1 +1 @@
-NVIDIA_VERSION = 260.19.04
+NVIDIA_VERSION = 260.19.06