diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2011-01-24 07:42:02 -0800 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2011-01-24 07:42:02 -0800 |
commit | aacccb9ea4f67efbd44b9a8b6be591a7ed1bc4a1 (patch) | |
tree | d4e0f2b363bc4c563de7a0bb19c5c0210392ef4a | |
parent | 6f3dc02c4689d9413eb029fcc5723d687f44ff71 (diff) |
270.18270.18
58 files changed, 1951 insertions, 376 deletions
@@ -104,6 +104,7 @@ endif LDFLAGS += -lX11 -lXext -lm LDFLAGS += $(GTK_LDFLAGS) +LDFLAGS += $(LIBDL_LDFLAGS) MANPAGE_GZIP ?= 1 @@ -139,6 +140,7 @@ CFLAGS += -I src/xpm_data CFLAGS += -I src/gtk+-2.x CFLAGS += -I $(COMMON_UTILS_DIR) CFLAGS += -I $(OUTPUTDIR) +CFLAGS += -DPROGRAM_NAME=\"nvidia-setttings\" $(call BUILD_OBJECT_LIST,$(GTK_SRC)): CFLAGS += $(GTK_CFLAGS) diff --git a/samples/nv-control-events.c b/samples/nv-control-events.c index 43dade2..4b9e402 100644 --- a/samples/nv-control-events.c +++ b/samples/nv-control-events.c @@ -47,6 +47,7 @@ int main(void) int event_base, error_base; int num_screens, num_gpus, num_framelocks, num_vcs, i; int num_gvis, num_coolers, num_thermal_sensors; + int num_3d_vision_pro_transceivers; int sources; XEvent event; XNVCtrlAttributeChangedEvent *nvevent; @@ -149,6 +150,17 @@ int main(void) return 1; } + /* Query number of 3d Vision Pro Transceivers */ + + ret = XNVCTRLQueryTargetCount(dpy, NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER, + &num_3d_vision_pro_transceivers); + if (ret != True) { + fprintf(stderr, "Failed to query the number of 3D Vision Pro " + "Transceiver devices on '%s'.\n", + XDisplayName(NULL)); + return 1; + } + /* * register to receive NV-CONTROL events: whenever any NV-CONTROL * attribute is changed by an NV-CONTROL client, any other client @@ -341,6 +353,25 @@ int main(void) sources++; } + /* Register to receive on all 3D Vision Pro Transceiver targets */ + + for (i = 0; i < num_3d_vision_pro_transceivers; i++ ) { + + ret = XNVCtrlSelectTargetNotify(dpy, NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER, + i, TARGET_ATTRIBUTE_CHANGED_EVENT, + True); + if (ret != True) { + printf("- Unable to register to receive NV-CONTROL " + "target events for 3D Vision Pro Transceiver %d on '%s'.\n", + i, XDisplayName(NULL)); + continue; + } + + printf("+ Listening to TARGET_ATTRIBUTE_CHANGE_EVENTs on 3d Vision " + "Pro Transceiver %d.\n", i); + sources++; + } + /* * Report the number of sources (things that we have registered to * listen for NV-CONTROL X Events on.) @@ -442,6 +473,8 @@ static const char *target2str(int n) return "Cooler"; case NV_CTRL_TARGET_TYPE_THERMAL_SENSOR: return "Thermal Sensor"; + case NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER: + return "3D Vision Pro Transceiver"; default: snprintf(unknown, 24, "Unknown (%d)", n); return unknown; @@ -591,7 +624,7 @@ static AttrEntry attr_table[] = { MAKE_ENTRY(NV_CTRL_XINERAMA), MAKE_ENTRY(NV_CTRL_XINERAMA_STEREO), MAKE_ENTRY(NV_CTRL_BUS_RATE), - MAKE_ENTRY(NV_CTRL_SHOW_SLI_HUD), + MAKE_ENTRY(NV_CTRL_SHOW_SLI_VISUAL_INDICATOR), MAKE_ENTRY(NV_CTRL_XV_SYNC_TO_DISPLAY), MAKE_ENTRY(NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2), MAKE_ENTRY(NV_CTRL_GVO_OVERRIDE_HW_CSC), @@ -719,8 +752,25 @@ static AttrEntry attr_table[] = { MAKE_ENTRY(NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS), MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS), MAKE_ENTRY(NV_CTRL_GPU_PCIE_MAX_LINK_SPEED), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_RESET_TRANSCEIVER_TO_FACTORY_SETTINGS), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE), + MAKE_ENTRY(NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES), MAKE_ENTRY(NV_CTRL_DITHERING_DEPTH), MAKE_ENTRY(NV_CTRL_CURRENT_DITHERING_DEPTH), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_FREQUENCY), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_COUNT), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_PAIR_GLASSES), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_DISCOVER_GLASSES), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_IDENTIFY_GLASSES), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_SYNC_CYCLE), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_MISSED_SYNC_CYCLES), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL), MAKE_ENTRY(NV_CTRL_GVO_ANC_PARITY_COMPUTATION), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_PAIR_EVENT), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_UNPAIR_EVENT), { -1, NULL, NULL } }; diff --git a/samples/nv-control-info.c b/samples/nv-control-info.c index 83c7861..c86e736 100644 --- a/samples/nv-control-info.c +++ b/samples/nv-control-info.c @@ -28,12 +28,424 @@ */ #include <stdio.h> +#include <string.h> +#include <ctype.h> #include <X11/Xlib.h> #include "NVCtrl.h" #include "NVCtrlLib.h" +// Used to convert the NV-CONTROL #defines to human readable text. +#define MAKE_ENTRY(ATTRIBUTE) { ATTRIBUTE, #ATTRIBUTE, NULL } + +typedef struct { + int num; + char *str; + char *name; +} AttrEntry; + +static const char *attr2str(int n, AttrEntry *tbl) +{ + AttrEntry *entry; + + entry = tbl; + while (entry->str) { + if (entry->num == n) { + if (!entry->name) { + int len; + entry->name = strdup(entry->str + 8); + for (len = 0; len < strlen(entry->name); len++) { + entry->name[len] = tolower(entry->name[len]); + } + } + return entry->name; + } + entry++; + } + + return NULL; +} + +// Attribute -> String table, generated using: +// +// grep 'define.*\/\*' NVCtrl.h | sed 's/.*define \([^ ]*\).*/ MAKE_ENTRY(\1),/' > DATA | head DATA +// +static AttrEntry attr_int_table[] = { + MAKE_ENTRY(NV_CTRL_FLATPANEL_SCALING), + MAKE_ENTRY(NV_CTRL_FLATPANEL_DITHERING), + MAKE_ENTRY(NV_CTRL_DITHERING), + MAKE_ENTRY(NV_CTRL_DIGITAL_VIBRANCE), + MAKE_ENTRY(NV_CTRL_BUS_TYPE), + MAKE_ENTRY(NV_CTRL_VIDEO_RAM), + MAKE_ENTRY(NV_CTRL_IRQ), + MAKE_ENTRY(NV_CTRL_OPERATING_SYSTEM), + MAKE_ENTRY(NV_CTRL_SYNC_TO_VBLANK), + MAKE_ENTRY(NV_CTRL_LOG_ANISO), + MAKE_ENTRY(NV_CTRL_FSAA_MODE), + MAKE_ENTRY(NV_CTRL_TEXTURE_SHARPEN), + MAKE_ENTRY(NV_CTRL_UBB), + MAKE_ENTRY(NV_CTRL_OVERLAY), + MAKE_ENTRY(NV_CTRL_STEREO), + MAKE_ENTRY(NV_CTRL_EMULATE), + MAKE_ENTRY(NV_CTRL_TWINVIEW), + MAKE_ENTRY(NV_CTRL_CONNECTED_DISPLAYS), + MAKE_ENTRY(NV_CTRL_ENABLED_DISPLAYS), + MAKE_ENTRY(NV_CTRL_FRAMELOCK), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_MASTER), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_POLARITY), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_SYNC_DELAY), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_SYNC_INTERVAL), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_PORT0_STATUS), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_PORT1_STATUS), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_HOUSE_STATUS), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_SYNC), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_SYNC_READY), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_STEREO_SYNC), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_TEST_SIGNAL), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_ETHERNET_DETECTED), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_VIDEO_MODE), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_SYNC_RATE), + MAKE_ENTRY(NV_CTRL_FORCE_GENERIC_CPU), + MAKE_ENTRY(NV_CTRL_OPENGL_AA_LINE_GAMMA), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_TIMING), + MAKE_ENTRY(NV_CTRL_FLIPPING_ALLOWED), + MAKE_ENTRY(NV_CTRL_ARCHITECTURE), + MAKE_ENTRY(NV_CTRL_TEXTURE_CLAMPING), + MAKE_ENTRY(NV_CTRL_CURSOR_SHADOW), + MAKE_ENTRY(NV_CTRL_CURSOR_SHADOW_ALPHA), + MAKE_ENTRY(NV_CTRL_CURSOR_SHADOW_RED), + MAKE_ENTRY(NV_CTRL_CURSOR_SHADOW_GREEN), + MAKE_ENTRY(NV_CTRL_CURSOR_SHADOW_BLUE), + MAKE_ENTRY(NV_CTRL_CURSOR_SHADOW_X_OFFSET), + MAKE_ENTRY(NV_CTRL_CURSOR_SHADOW_Y_OFFSET), + MAKE_ENTRY(NV_CTRL_FSAA_APPLICATION_CONTROLLED), + MAKE_ENTRY(NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED), + MAKE_ENTRY(NV_CTRL_IMAGE_SHARPENING), + MAKE_ENTRY(NV_CTRL_TV_OVERSCAN), + MAKE_ENTRY(NV_CTRL_TV_FLICKER_FILTER), + MAKE_ENTRY(NV_CTRL_TV_BRIGHTNESS), + MAKE_ENTRY(NV_CTRL_TV_HUE), + MAKE_ENTRY(NV_CTRL_TV_CONTRAST), + MAKE_ENTRY(NV_CTRL_TV_SATURATION), + MAKE_ENTRY(NV_CTRL_TV_RESET_SETTINGS), + MAKE_ENTRY(NV_CTRL_GPU_CORE_TEMPERATURE), + MAKE_ENTRY(NV_CTRL_GPU_CORE_THRESHOLD), + MAKE_ENTRY(NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD), + MAKE_ENTRY(NV_CTRL_GPU_MAX_CORE_THRESHOLD), + MAKE_ENTRY(NV_CTRL_AMBIENT_TEMPERATURE), + MAKE_ENTRY(NV_CTRL_PBUFFER_SCANOUT_SUPPORTED), + MAKE_ENTRY(NV_CTRL_PBUFFER_SCANOUT_XID), + MAKE_ENTRY(NV_CTRL_GVO_SUPPORTED), + MAKE_ENTRY(NV_CTRL_GVO_SYNC_MODE), + MAKE_ENTRY(NV_CTRL_GVO_SYNC_SOURCE), + MAKE_ENTRY(NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT), + MAKE_ENTRY(NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT), + MAKE_ENTRY(NV_CTRL_GVO_DATA_FORMAT), + MAKE_ENTRY(NV_CTRL_GVO_DISPLAY_X_SCREEN), + MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED), + MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE), + MAKE_ENTRY(NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED), + MAKE_ENTRY(NV_CTRL_GVO_VIDEO_OUTPUTS), + MAKE_ENTRY(NV_CTRL_GVO_FIRMWARE_VERSION), + MAKE_ENTRY(NV_CTRL_GVO_SYNC_DELAY_PIXELS), + MAKE_ENTRY(NV_CTRL_GVO_SYNC_DELAY_LINES), + MAKE_ENTRY(NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE), + MAKE_ENTRY(NV_CTRL_GVO_GLX_LOCKED), + MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH), + MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_HEIGHT), + MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE), + MAKE_ENTRY(NV_CTRL_GVO_X_SCREEN_PAN_X), + MAKE_ENTRY(NV_CTRL_GVO_X_SCREEN_PAN_Y), + MAKE_ENTRY(NV_CTRL_GPU_OVERCLOCKING_STATE), + MAKE_ENTRY(NV_CTRL_GPU_2D_CLOCK_FREQS), + MAKE_ENTRY(NV_CTRL_GPU_3D_CLOCK_FREQS), + MAKE_ENTRY(NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS), + MAKE_ENTRY(NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS), + MAKE_ENTRY(NV_CTRL_GPU_CURRENT_CLOCK_FREQS), + MAKE_ENTRY(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS), + MAKE_ENTRY(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION), + MAKE_ENTRY(NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE), + MAKE_ENTRY(NV_CTRL_FLATPANEL_CHIP_LOCATION), + MAKE_ENTRY(NV_CTRL_FLATPANEL_LINK), + MAKE_ENTRY(NV_CTRL_FLATPANEL_SIGNAL), + MAKE_ENTRY(NV_CTRL_USE_HOUSE_SYNC), + MAKE_ENTRY(NV_CTRL_EDID_AVAILABLE), + MAKE_ENTRY(NV_CTRL_FORCE_STEREO), + MAKE_ENTRY(NV_CTRL_IMAGE_SETTINGS), + MAKE_ENTRY(NV_CTRL_XINERAMA), + MAKE_ENTRY(NV_CTRL_XINERAMA_STEREO), + MAKE_ENTRY(NV_CTRL_BUS_RATE), + MAKE_ENTRY(NV_CTRL_SHOW_SLI_VISUAL_INDICATOR), + MAKE_ENTRY(NV_CTRL_XV_SYNC_TO_DISPLAY), + MAKE_ENTRY(NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2), + MAKE_ENTRY(NV_CTRL_GVO_OVERRIDE_HW_CSC), + MAKE_ENTRY(NV_CTRL_GVO_CAPABILITIES), + MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_TERMINATION), + MAKE_ENTRY(NV_CTRL_ASSOCIATED_DISPLAY_DEVICES), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_SLAVES), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_MASTERABLE), + MAKE_ENTRY(NV_CTRL_PROBE_DISPLAYS), + MAKE_ENTRY(NV_CTRL_REFRESH_RATE), + MAKE_ENTRY(NV_CTRL_GVO_FLIP_QUEUE_SIZE), + MAKE_ENTRY(NV_CTRL_CURRENT_SCANLINE), + MAKE_ENTRY(NV_CTRL_INITIAL_PIXMAP_PLACEMENT), + MAKE_ENTRY(NV_CTRL_PCI_BUS), + MAKE_ENTRY(NV_CTRL_PCI_DEVICE), + MAKE_ENTRY(NV_CTRL_PCI_FUNCTION), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_FPGA_REVISION), + MAKE_ENTRY(NV_CTRL_MAX_SCREEN_WIDTH), + MAKE_ENTRY(NV_CTRL_MAX_SCREEN_HEIGHT), + MAKE_ENTRY(NV_CTRL_MAX_DISPLAYS), + MAKE_ENTRY(NV_CTRL_DYNAMIC_TWINVIEW), + MAKE_ENTRY(NV_CTRL_MULTIGPU_DISPLAY_OWNER), + MAKE_ENTRY(NV_CTRL_GPU_SCALING), + MAKE_ENTRY(NV_CTRL_FRONTEND_RESOLUTION), + MAKE_ENTRY(NV_CTRL_BACKEND_RESOLUTION), + MAKE_ENTRY(NV_CTRL_FLATPANEL_NATIVE_RESOLUTION), + MAKE_ENTRY(NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION), + MAKE_ENTRY(NV_CTRL_GPU_SCALING_ACTIVE), + MAKE_ENTRY(NV_CTRL_DFP_SCALING_ACTIVE), + MAKE_ENTRY(NV_CTRL_FSAA_APPLICATION_ENHANCED), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_SYNC_RATE_4), + MAKE_ENTRY(NV_CTRL_GVO_LOCK_OWNER), + MAKE_ENTRY(NV_CTRL_HWOVERLAY), + MAKE_ENTRY(NV_CTRL_NUM_GPU_ERRORS_RECOVERED), + MAKE_ENTRY(NV_CTRL_REFRESH_RATE_3), + MAKE_ENTRY(NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS), + MAKE_ENTRY(NV_CTRL_GPU_POWER_SOURCE), + MAKE_ENTRY(NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE), + MAKE_ENTRY(NV_CTRL_GLYPH_CACHE), + MAKE_ENTRY(NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL), + MAKE_ENTRY(NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE), + MAKE_ENTRY(NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED), + MAKE_ENTRY(NV_CTRL_GVO_SYNC_LOCK_STATUS), + MAKE_ENTRY(NV_CTRL_GVO_ANC_TIME_CODE_GENERATION), + MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE), + MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_ALPHA_KEY), + MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_LUMA_KEY_RANGE), + MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_CR_KEY_RANGE), + MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_CB_KEY_RANGE), + MAKE_ENTRY(NV_CTRL_GVO_COMPOSITE_NUM_KEY_RANGES), + MAKE_ENTRY(NV_CTRL_SWITCH_TO_DISPLAYS), + MAKE_ENTRY(NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT), + MAKE_ENTRY(NV_CTRL_NOTEBOOK_INTERNAL_LCD), + MAKE_ENTRY(NV_CTRL_DEPTH_30_ALLOWED), + MAKE_ENTRY(NV_CTRL_MODE_SET_EVENT), + MAKE_ENTRY(NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE), + MAKE_ENTRY(NV_CTRL_VCSC_HIGH_PERF_MODE), + MAKE_ENTRY(NV_CTRL_DISPLAYPORT_LINK_RATE), + MAKE_ENTRY(NV_CTRL_STEREO_EYES_EXCHANGE), + MAKE_ENTRY(NV_CTRL_NO_SCANOUT), + MAKE_ENTRY(NV_CTRL_GVO_CSC_CHANGED_EVENT), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_SLAVEABLE), + MAKE_ENTRY(NV_CTRL_GVO_SYNC_TO_DISPLAY), + MAKE_ENTRY(NV_CTRL_X_SERVER_UNIQUE_ID), + MAKE_ENTRY(NV_CTRL_PIXMAP_CACHE), + MAKE_ENTRY(NV_CTRL_PIXMAP_CACHE_ROUNDING_SIZE_KB), + MAKE_ENTRY(NV_CTRL_IS_GVO_DISPLAY), + MAKE_ENTRY(NV_CTRL_PCI_ID), + MAKE_ENTRY(NV_CTRL_GVO_FULL_RANGE_COLOR), + MAKE_ENTRY(NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE), + MAKE_ENTRY(NV_CTRL_GVO_ENABLE_RGB_DATA), + MAKE_ENTRY(NV_CTRL_IMAGE_SHARPENING_DEFAULT), + MAKE_ENTRY(NV_CTRL_PCI_DOMAIN), + MAKE_ENTRY(NV_CTRL_GVI_NUM_JACKS), + MAKE_ENTRY(NV_CTRL_GVI_MAX_LINKS_PER_STREAM), + MAKE_ENTRY(NV_CTRL_GVI_DETECTED_CHANNEL_BITS_PER_COMPONENT), + MAKE_ENTRY(NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT), + MAKE_ENTRY(NV_CTRL_GVI_DETECTED_CHANNEL_COMPONENT_SAMPLING), + MAKE_ENTRY(NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING), + MAKE_ENTRY(NV_CTRL_GVI_REQUESTED_STREAM_CHROMA_EXPAND), + MAKE_ENTRY(NV_CTRL_GVI_DETECTED_CHANNEL_COLOR_SPACE), + MAKE_ENTRY(NV_CTRL_GVI_DETECTED_CHANNEL_LINK_ID), + MAKE_ENTRY(NV_CTRL_GVI_DETECTED_CHANNEL_SMPTE352_IDENTIFIER), + MAKE_ENTRY(NV_CTRL_GVI_GLOBAL_IDENTIFIER), + MAKE_ENTRY(NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION), + MAKE_ENTRY(NV_CTRL_GPU_COOLER_MANUAL_CONTROL), + MAKE_ENTRY(NV_CTRL_THERMAL_COOLER_LEVEL), + MAKE_ENTRY(NV_CTRL_THERMAL_COOLER_LEVEL_SET_DEFAULT), + MAKE_ENTRY(NV_CTRL_THERMAL_COOLER_CONTROL_TYPE), + MAKE_ENTRY(NV_CTRL_THERMAL_COOLER_TARGET), + MAKE_ENTRY(NV_CTRL_GPU_ECC_SUPPORTED), + MAKE_ENTRY(NV_CTRL_GPU_ECC_STATUS), + MAKE_ENTRY(NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED), + MAKE_ENTRY(NV_CTRL_GPU_ECC_CONFIGURATION), + MAKE_ENTRY(NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION), + MAKE_ENTRY(NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS), + MAKE_ENTRY(NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS), + MAKE_ENTRY(NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS), + MAKE_ENTRY(NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS), + MAKE_ENTRY(NV_CTRL_GPU_ECC_RESET_ERROR_STATUS), + MAKE_ENTRY(NV_CTRL_GPU_POWER_MIZER_MODE), + MAKE_ENTRY(NV_CTRL_GVI_SYNC_OUTPUT_FORMAT), + MAKE_ENTRY(NV_CTRL_GVI_MAX_CHANNELS_PER_JACK), + MAKE_ENTRY(NV_CTRL_GVI_MAX_STREAMS), + MAKE_ENTRY(NV_CTRL_GVI_NUM_CAPTURE_SURFACES), + MAKE_ENTRY(NV_CTRL_OVERSCAN_COMPENSATION), + MAKE_ENTRY(NV_CTRL_GPU_PCIE_GENERATION), + MAKE_ENTRY(NV_CTRL_GVI_BOUND_GPU), + MAKE_ENTRY(NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3), + MAKE_ENTRY(NV_CTRL_ACCELERATE_TRAPEZOIDS), + MAKE_ENTRY(NV_CTRL_GPU_CORES), + MAKE_ENTRY(NV_CTRL_GPU_MEMORY_BUS_WIDTH), + MAKE_ENTRY(NV_CTRL_GVI_TEST_MODE), + MAKE_ENTRY(NV_CTRL_COLOR_SPACE), + MAKE_ENTRY(NV_CTRL_COLOR_RANGE), + MAKE_ENTRY(NV_CTRL_GPU_SCALING_DEFAULT_TARGET), + MAKE_ENTRY(NV_CTRL_GPU_SCALING_DEFAULT_METHOD), + MAKE_ENTRY(NV_CTRL_DITHERING_MODE), + MAKE_ENTRY(NV_CTRL_CURRENT_DITHERING), + MAKE_ENTRY(NV_CTRL_CURRENT_DITHERING_MODE), + MAKE_ENTRY(NV_CTRL_THERMAL_SENSOR_READING), + MAKE_ENTRY(NV_CTRL_THERMAL_SENSOR_PROVIDER), + MAKE_ENTRY(NV_CTRL_THERMAL_SENSOR_TARGET), + MAKE_ENTRY(NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR), + MAKE_ENTRY(NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS), + MAKE_ENTRY(NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS), + MAKE_ENTRY(NV_CTRL_GPU_PCIE_MAX_LINK_SPEED), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_RESET_TRANSCEIVER_TO_FACTORY_SETTINGS), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE), + MAKE_ENTRY(NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES), + MAKE_ENTRY(NV_CTRL_DITHERING_DEPTH), + MAKE_ENTRY(NV_CTRL_CURRENT_DITHERING_DEPTH), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_FREQUENCY), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_COUNT), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_PAIR_GLASSES), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_DISCOVER_GLASSES), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_IDENTIFY_GLASSES), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_SYNC_CYCLE), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_MISSED_SYNC_CYCLES), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL), + MAKE_ENTRY(NV_CTRL_GVO_ANC_PARITY_COMPUTATION), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_PAIR_EVENT), + MAKE_ENTRY(NV_CTRL_3D_VISION_PRO_GLASSES_UNPAIR_EVENT), + { -1, NULL, NULL } +}; + +static AttrEntry attr_str_table[] = { + MAKE_ENTRY(NV_CTRL_STRING_PRODUCT_NAME), + MAKE_ENTRY(NV_CTRL_STRING_VBIOS_VERSION), + MAKE_ENTRY(NV_CTRL_STRING_NVIDIA_DRIVER_VERSION), + MAKE_ENTRY(NV_CTRL_STRING_DISPLAY_DEVICE_NAME), + MAKE_ENTRY(NV_CTRL_STRING_TV_ENCODER_NAME), + MAKE_ENTRY(NV_CTRL_STRING_GVIO_FIRMWARE_VERSION), + MAKE_ENTRY(NV_CTRL_STRING_GVO_FIRMWARE_VERSION), + MAKE_ENTRY(NV_CTRL_STRING_CURRENT_MODELINE), + MAKE_ENTRY(NV_CTRL_STRING_ADD_MODELINE), + MAKE_ENTRY(NV_CTRL_STRING_DELETE_MODELINE), + MAKE_ENTRY(NV_CTRL_STRING_CURRENT_METAMODE), + MAKE_ENTRY(NV_CTRL_STRING_ADD_METAMODE), + MAKE_ENTRY(NV_CTRL_STRING_DELETE_METAMODE), + MAKE_ENTRY(NV_CTRL_STRING_VCSC_PRODUCT_NAME), + MAKE_ENTRY(NV_CTRL_STRING_VCSC_PRODUCT_ID), + MAKE_ENTRY(NV_CTRL_STRING_VCSC_SERIAL_NUMBER), + MAKE_ENTRY(NV_CTRL_STRING_VCSC_BUILD_DATE), + MAKE_ENTRY(NV_CTRL_STRING_VCSC_FIRMWARE_VERSION), + MAKE_ENTRY(NV_CTRL_STRING_VCSC_FIRMWARE_REVISION), + MAKE_ENTRY(NV_CTRL_STRING_VCSC_HARDWARE_VERSION), + MAKE_ENTRY(NV_CTRL_STRING_VCSC_HARDWARE_REVISION), + MAKE_ENTRY(NV_CTRL_STRING_MOVE_METAMODE), + MAKE_ENTRY(NV_CTRL_STRING_VALID_HORIZ_SYNC_RANGES), + MAKE_ENTRY(NV_CTRL_STRING_VALID_VERT_REFRESH_RANGES), + MAKE_ENTRY(NV_CTRL_STRING_XINERAMA_SCREEN_INFO), + MAKE_ENTRY(NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER), + MAKE_ENTRY(NV_CTRL_STRING_SLI_MODE), + MAKE_ENTRY(NV_CTRL_STRING_PERFORMANCE_MODES), + MAKE_ENTRY(NV_CTRL_STRING_VCSC_FAN_STATUS), + MAKE_ENTRY(NV_CTRL_STRING_VCSC_TEMPERATURES), + MAKE_ENTRY(NV_CTRL_STRING_VCSC_PSU_INFO), + MAKE_ENTRY(NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME), + MAKE_ENTRY(NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME), + MAKE_ENTRY(NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS), + MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_HARDWARE_REVISION), + MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_A), + MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_A), + MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_B), + MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_B), + MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_ADDRESS), + MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_VERSION_A), + MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_DATE_A), + MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_GLASSES_ADDRESS), + MAKE_ENTRY(NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME), + { -1, NULL, NULL } +}; + +static AttrEntry attr_bin_table[] = { + MAKE_ENTRY(NV_CTRL_BINARY_DATA_EDID), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_MODELINES), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_METAMODES), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_GPUS_USED_BY_XSCREEN), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_DISPLAY_VIEWPORT), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_GPUS_USING_VCSC), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU), + MAKE_ENTRY(NV_CTRL_BINARY_DATA_GLASSES_PAIRED_TO_3D_VISION_PRO_TRANSCEIVER), + { -1, NULL, NULL } +}; + + +static AttrEntry attr_strop_table[] = { + MAKE_ENTRY(NV_CTRL_STRING_OPERATION_ADD_METAMODE), + MAKE_ENTRY(NV_CTRL_STRING_OPERATION_GTF_MODELINE), + MAKE_ENTRY(NV_CTRL_STRING_OPERATION_CVT_MODELINE), + MAKE_ENTRY(NV_CTRL_STRING_OPERATION_BUILD_MODEPOOL), + MAKE_ENTRY(NV_CTRL_STRING_OPERATION_GVI_CONFIGURE_STREAMS), + { -1, NULL, NULL } +}; + + +void print_perms(NVCTRLAttributePermissionsRec *perms) +{ + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_READ) ? 'R' : '_'); + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_WRITE) ? 'W' : '_'); + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_DISPLAY) ? 'D' : '_'); + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_GPU) ? 'G' : '_'); + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_FRAMELOCK) ? 'F' : '_'); + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_X_SCREEN) ? 'X' : '_'); + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_XINERAMA) ? 'I' : '_'); + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_VCSC) ? 'V' : '_'); + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_GVI) ? 'S' : '_'); + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_COOLER) ? 'C' : '_'); + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_THERMAL_SENSOR) ? 'T' : '_'); + printf("%c", (perms->permissions & ATTRIBUTE_TYPE_3D_VISION_PRO_TRANSCEIVER) ? '3' : '_'); +} + +/* Used to stringify NV_CTRL_XXX #defines */ + +#define ADD_NVCTRL_CASE(FMT) \ +case (FMT): \ + return #FMT; + +const char *GetAttrTypeName(value) +{ + switch (value) { + ADD_NVCTRL_CASE(ATTRIBUTE_TYPE_UNKNOWN); + ADD_NVCTRL_CASE(ATTRIBUTE_TYPE_INTEGER); + ADD_NVCTRL_CASE(ATTRIBUTE_TYPE_BITMASK); + ADD_NVCTRL_CASE(ATTRIBUTE_TYPE_BOOL); + ADD_NVCTRL_CASE(ATTRIBUTE_TYPE_RANGE); + ADD_NVCTRL_CASE(ATTRIBUTE_TYPE_INT_BITS); + ADD_NVCTRL_CASE(ATTRIBUTE_TYPE_64BIT_INTEGER); + ADD_NVCTRL_CASE(ATTRIBUTE_TYPE_STRING); + ADD_NVCTRL_CASE(ATTRIBUTE_TYPE_BINARY_DATA); + ADD_NVCTRL_CASE(ATTRIBUTE_TYPE_STRING_OPERATION); + default: + return "Invalid Value"; + } +} + + + int main(void) { Display *dpy; @@ -125,7 +537,83 @@ int main(void) } } } - + + /* + * print attribute permission and type information. + */ + + printf("Attributes (Integers):\n"); + for (i = 0; i < NV_CTRL_LAST_ATTRIBUTE; i++) { + const char *name = attr2str(i, attr_int_table); + if (name) { + NVCTRLAttributePermissionsRec perms; + + printf(" (%3d) [Perms: ", i); + + memset(&perms, 0, sizeof(NVCTRLAttributePermissionsRec)); + + XNVCTRLQueryAttributePermissions(dpy, i, &perms); + print_perms(&perms); + printf("] [ "); + printf("%-32s", GetAttrTypeName(perms.type)); + printf("] - %s\n", name); + } + } + + printf("Attributes (Strings):\n"); + for (i = 0; i < NV_CTRL_STRING_LAST_ATTRIBUTE; i++) { + const char *name = attr2str(i, attr_str_table); + if (name) { + NVCTRLAttributePermissionsRec perms; + + printf(" (%3d) [Perms: ", i); + + memset(&perms, 0, sizeof(NVCTRLAttributePermissionsRec)); + + XNVCTRLQueryStringAttributePermissions(dpy, i, &perms); + print_perms(&perms); + printf("] [ "); + printf("%-32s", GetAttrTypeName(perms.type)); + printf("] - %s\n", name); + } + } + + printf("Attributes (Binary Data):\n"); + for (i = 0; i < NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE; i++) { + const char *name = attr2str(i, attr_bin_table); + if (name) { + NVCTRLAttributePermissionsRec perms; + + printf(" (%3d) [Perms: ", i); + + memset(&perms, 0, sizeof(NVCTRLAttributePermissionsRec)); + + XNVCTRLQueryBinaryDataAttributePermissions(dpy, i, &perms); + print_perms(&perms); + printf("] [ "); + printf("%-32s", GetAttrTypeName(perms.type)); + printf("] - %s\n", name); + } + } + + printf("Attributes (String Operations):\n"); + for (i = 0; i < NV_CTRL_STRING_OPERATION_LAST_ATTRIBUTE; i++) { + const char *name = attr2str(i, attr_strop_table); + if (name) { + NVCTRLAttributePermissionsRec perms; + + printf(" (%3d) [Perms: ", i); + + memset(&perms, 0, sizeof(NVCTRLAttributePermissionsRec)); + + XNVCTRLQueryStringOperationAttributePermissions(dpy, i, &perms); + print_perms(&perms); + printf("] [ "); + printf("%-32s", GetAttrTypeName(perms.type)); + printf("] - %s\n", name); + } + } + /* * close the display connection */ diff --git a/src/command-line.c b/src/command-line.c index 8fe3843..8b21c46 100644 --- a/src/command-line.c +++ b/src/command-line.c @@ -38,12 +38,12 @@ #include "NvCtrlAttributes.h" +#include "common-utils.h" /* local prototypes */ static void print_attribute_help(char *attr); static void print_help(void); -static char *nvstrcat(const char *str, ...); /* * verbosity, controls output of errors, warnings and other @@ -236,7 +236,7 @@ Options *parse_command_line(int argc, char *argv[], char *dpy) int n, c; char *strval; - op = (Options *) malloc(sizeof (Options)); + op = malloc(sizeof(Options)); memset(op, 0, sizeof (Options)); op->config = DEFAULT_RC_FILE; @@ -265,6 +265,7 @@ Options *parse_command_line(int argc, char *argv[], char *dpy) case 'n': op->no_load = 1; break; case 'r': op->rewrite = 1; break; case 'c': op->ctrl_display = strval; break; + case 'p': op->page = strval; break; case 'V': __verbosity = VERBOSITY_DEFAULT; if (!strval) { @@ -315,105 +316,3 @@ Options *parse_command_line(int argc, char *argv[], char *dpy) } /* parse_command_line() */ - - -/* - * tilde_expansion() - do tilde expansion on the given path name; - * based loosely on code snippets found in the comp.unix.programmer - * FAQ. The tilde expansion rule is: if a tilde ('~') is alone or - * followed by a '/', then substitute the current user's home - * directory; if followed by the name of a user, then substitute that - * user's home directory. - */ - -char *tilde_expansion(const char *str) -{ - char *prefix = NULL; - const char *replace; - char *user, *ret; - struct passwd *pw; - int len; - - if ((!str) || (str[0] != '~')) return strdup(str); - - if ((str[1] == '/') || (str[1] == '\0')) { - - /* expand to the current user's home directory */ - - prefix = getenv("HOME"); - if (!prefix) { - - /* $HOME isn't set; get the home directory from /etc/passwd */ - - pw = getpwuid(getuid()); - if (pw) prefix = pw->pw_dir; - } - - replace = str + 1; - - } else { - - /* expand to the specified user's home directory */ - - replace = strchr(str, '/'); - if (!replace) replace = str + strlen(str); - - len = replace - str; - user = malloc(len + 1); - strncpy(user, str+1, len-1); - user[len] = '\0'; - pw = getpwnam(user); - if (pw) prefix = pw->pw_dir; - free (user); - } - - if (!prefix) return strdup(str); - - ret = malloc(strlen(prefix) + strlen(replace) + 1); - strcpy(ret, prefix); - strcat(ret, replace); - - return ret; - -} /* tilde_expansion() */ - - -/* XXX useful utility function... where should this go? */ - -/* - * nvstrcat() - allocate a new string, copying all given strings - * into it. taken from glib - */ - -static char *nvstrcat(const char *str, ...) -{ - unsigned int l; - va_list args; - char *s; - char *concat; - - l = 1 + strlen(str); - va_start(args, str); - s = va_arg(args, char *); - - while (s) { - l += strlen(s); - s = va_arg(args, char *); - } - va_end(args); - - concat = malloc(l); - concat[0] = 0; - - strcat(concat, str); - va_start(args, str); - s = va_arg(args, char *); - while (s) { - strcat(concat, s); - s = va_arg(args, char *); - } - va_end(args); - - return concat; - -} /* nvstrcat() */ diff --git a/src/command-line.h b/src/command-line.h index 9e062be..307f767 100644 --- a/src/command-line.h +++ b/src/command-line.h @@ -93,10 +93,14 @@ typedef struct { * to the configuration file and exit. */ + char *page; /* + * The default page to display in the GUI + * when started. + */ + } Options; Options *parse_command_line(int argc, char *argv[], char *dpy); -char *tilde_expansion(const char *str); #endif /* __COMMAND_LINE_H__ */ diff --git a/src/common-utils/common-utils.c b/src/common-utils/common-utils.c new file mode 100644 index 0000000..31f790f --- /dev/null +++ b/src/common-utils/common-utils.c @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2010 NVIDIA Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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, write to the: + * + * Free Software Foundation, Inc. + * 59 Temple Place - Suite 330 + * Boston, MA 02111-1307, USA + */ + + +#include <stdio.h> +#include <stdarg.h> + +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <fcntl.h> +#include <ctype.h> +#include <pwd.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <sys/ioctl.h> +#include <sys/termios.h> + +#include "common-utils.h" + + +/****************************************************************************/ +/* Memory allocation helper functions */ +/****************************************************************************/ + +/* + * nvalloc() - calloc wrapper that checks for errors; if an error + * occurs, an error is printed to stderr and exit is called -- this + * function will only return on success. + */ + +void *nvalloc(size_t size) +{ + void *m = calloc(1, size); + + if (!m) { + fprintf(stderr, "%s: memory allocation failure (%s)! \n", + PROGRAM_NAME, strerror(errno)); + exit(1); + } + return m; + +} /* nvalloc() */ + + + +/* + * nvstrcat() - allocate a new string, copying all given strings + * into it. taken from glib + */ + +char *nvstrcat(const char *str, ...) +{ + unsigned int l; + va_list args; + char *s; + char *concat; + + l = 1 + strlen(str); + va_start(args, str); + s = va_arg(args, char *); + + while (s) { + l += strlen(s); + s = va_arg(args, char *); + } + va_end(args); + + concat = nvalloc(l); + concat[0] = 0; + + strcat(concat, str); + va_start(args, str); + s = va_arg(args, char *); + while (s) { + strcat(concat, s); + s = va_arg(args, char *); + } + va_end(args); + + return concat; + +} /* nvstrcat() */ + + + +/* + * nvrealloc() - realloc wrapper that checks for errors; if an error + * occurs, an error is printed to stderr and exit is called -- this + * function will only return on success. + */ + +void *nvrealloc(void *ptr, size_t size) +{ + void *m; + + if (ptr == NULL) return nvalloc(size); + + m = realloc(ptr, size); + if (!m) { + fprintf(stderr, "%s: memory re-allocation failure (%s)! \n", + PROGRAM_NAME, strerror(errno)); + exit(1); + } + return m; + +} /* nvrealloc() */ + + + +/* + * nvstrdup() - wrapper for strdup() that checks the return value; if + * an error occurs, an error is printed to stderr and exit is called + * -- this function will only return on success. + */ + +char *nvstrdup(const char *s) +{ + char *m; + + if (!s) return NULL; + + m = strdup(s); + + if (!m) { + fprintf(stderr, "%s: memory allocation failure during strdup (%s)! \n", + PROGRAM_NAME, strerror(errno)); + exit(1); + } + return m; + +} /* nvstrdup() */ + + + +/* + * nvstrtolower() - convert the given string to lowercase. + */ + +char *nvstrtolower(char *s) +{ + char *start = s; + + if (s == NULL) return NULL; + + while (*s) { + *s = tolower(*s); + s++; + } + + return start; + +} /* nvstrtolower() */ + + + +/* + * nvfree() - frees memory allocated with nvalloc(), provided + * a non-NULL pointer is provided. + */ +void nvfree(void *s) +{ + if (s) free(s); + +} /* nvfree() */ + + + +/****************************************************************************/ +/* misc */ +/****************************************************************************/ + +/* + * tilde_expansion() - do tilde expansion on the given path name; + * based loosely on code snippets found in the comp.unix.programmer + * FAQ. The tilde expansion rule is: if a tilde ('~') is alone or + * followed by a '/', then substitute the current user's home + * directory; if followed by the name of a user, then substitute that + * user's home directory. + * + * Returns NULL if its argument is NULL; otherwise, returns a malloced + * and tilde-expanded string. + */ + +char *tilde_expansion(const char *str) +{ + char *prefix = NULL; + const char *replace; + char *user, *ret; + struct passwd *pw; + int len; + + if (!str) return NULL; + + if (str[0] != '~') return strdup(str); + + if ((str[1] == '/') || (str[1] == '\0')) { + + /* expand to the current user's home directory */ + + prefix = getenv("HOME"); + if (!prefix) { + + /* $HOME isn't set; get the home directory from /etc/passwd */ + + pw = getpwuid(getuid()); + if (pw) prefix = pw->pw_dir; + } + + replace = str + 1; + + } else { + + /* expand to the specified user's home directory */ + + replace = strchr(str, '/'); + if (!replace) replace = str + strlen(str); + + len = replace - str; + user = malloc(len + 1); + strncpy(user, str+1, len-1); + user[len] = '\0'; + pw = getpwnam(user); + if (pw) prefix = pw->pw_dir; + free (user); + } + + if (!prefix) return strdup(str); + + ret = malloc(strlen(prefix) + strlen(replace) + 1); + strcpy(ret, prefix); + strcat(ret, replace); + + return ret; + +} /* tilde_expansion() */ diff --git a/src/common-utils/common-utils.h b/src/common-utils/common-utils.h new file mode 100644 index 0000000..f1b0d4e --- /dev/null +++ b/src/common-utils/common-utils.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 NVIDIA Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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, write to the: + * + * Free Software Foundation, Inc. + * 59 Temple Place - Suite 330 + * Boston, MA 02111-1307, USA + */ + +#ifndef __COMMON_UTILS_H__ +#define __COMMON_UTILS_H__ + +#if !defined(TRUE) +#define TRUE 1 +#endif + +#if !defined(FALSE) +#define FALSE 0 +#endif + +void *nvalloc(size_t size); +char *nvstrcat(const char *str, ...); +void *nvrealloc(void *ptr, size_t size); +char *nvstrdup(const char *s); +char *nvstrtolower(char *s); +void nvfree(void *s); + +char *tilde_expansion(const char *str); + +#endif /* __COMMON_UTILS_H__ */ diff --git a/src/common-utils/src.mk b/src/common-utils/src.mk index b93479e..14e4131 100644 --- a/src/common-utils/src.mk +++ b/src/common-utils/src.mk @@ -1,7 +1,9 @@ # makefile fragment included by nvidia-xconfig, nvidia-settings, and nvidia-installer COMMON_UTILS_SRC += nvgetopt.c +COMMON_UTILS_SRC += common-utils.c COMMON_UTILS_EXTRA_DIST += nvgetopt.h +COMMON_UTILS_EXTRA_DIST += common-utils.h COMMON_UTILS_EXTRA_DIST += src.mk diff --git a/src/config-file.c b/src/config-file.c index e63e672..8230d3f 100644 --- a/src/config-file.c +++ b/src/config-file.c @@ -110,6 +110,14 @@ int nv_read_config_file(const char *file, const char *display_name, struct stat stat_buf; char *buf, *locale; ParsedAttributeWrapper *w = NULL; + + if (!file) { + /* + * file is NULL, likely because tilde_expansion() failed and + * returned NULL; silently fail + */ + return NV_FALSE; + } /* open the file */ @@ -218,6 +226,11 @@ int nv_write_config_file(const char *filename, CtrlHandles *h, const char *tmp; char *locale = "C"; + if (!filename) { + nv_error_msg("Unable to open configuration file for writing."); + return NV_FALSE; + } + stream = fopen(filename, "w"); if (!stream) { nv_error_msg("Unable to open file '%s' for writing.", filename); diff --git a/src/gtk+-2.x/ctk3dvisionpro.c b/src/gtk+-2.x/ctk3dvisionpro.c index cede791..c2d48d7 100644 --- a/src/gtk+-2.x/ctk3dvisionpro.c +++ b/src/gtk+-2.x/ctk3dvisionpro.c @@ -695,7 +695,7 @@ static void svp_config_changed(GtkObject *object, gpointer arg1, case NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL: if (HTU(0)->channel_num != event_struct->value) { HTU(0)->channel_num = event_struct->value; - snprintf(temp, sizeof(temp), "Current Channel ID: %d", HTU(0)->channel_num); + snprintf(temp, sizeof(temp), "%d", HTU(0)->channel_num); gtk_label_set_text(ctk_3d_vision_pro->channel_num_label, temp); gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->channel_num_label)); } @@ -1287,32 +1287,32 @@ static void rename_button_clicked(GtkButton *button, gpointer user_data) } } if (i == HTU(0)->num_glasses) { - goto new_unique_name_set; + if (dlg->glasses_selected_index >= 0 && + dlg->glasses_selected_index < HTU(0)->num_glasses) { + Bool ret; + unsigned int glasses_id = HTU(0)->glasses_info[dlg->glasses_selected_index]->glasses_id; + + ret = XNVCTRLSetTargetStringAttribute(NvCtrlGetDisplayPtr(ctk_3d_vision_pro->handle), + NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER, + 0, glasses_id, + NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME, + dlg->glasses_new_name); + + if (ret == False) { + continue; + } + strncpy(HTU(0)->glasses_info[dlg->glasses_selected_index]->name, dlg->glasses_new_name, + sizeof(HTU(0)->glasses_info[dlg->glasses_selected_index]->name)); + HTU(0)->glasses_info[dlg->glasses_selected_index]->name[GLASSES_NAME_MAX_LENGTH - 1] = '\0'; + + update_glasses_info_data_table(&(ctk_3d_vision_pro->table), HTU(0)->glasses_info); + gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->table.data_table)); + } + break; } } } while (result != GTK_RESPONSE_REJECT); - goto no_name_set; - -new_unique_name_set: - if (dlg->glasses_selected_index >= 0 && - dlg->glasses_selected_index < HTU(0)->num_glasses) { - unsigned int glasses_id = HTU(0)->glasses_info[dlg->glasses_selected_index]->glasses_id; - - XNVCTRLSetTargetStringAttribute(NvCtrlGetDisplayPtr(ctk_3d_vision_pro->handle), - NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER, - 0, glasses_id, - NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME, - dlg->glasses_new_name); - - strncpy(HTU(0)->glasses_info[dlg->glasses_selected_index]->name, dlg->glasses_new_name, - sizeof(HTU(0)->glasses_info[dlg->glasses_selected_index]->name)); - HTU(0)->glasses_info[dlg->glasses_selected_index]->name[GLASSES_NAME_MAX_LENGTH - 1] = '\0'; - - update_glasses_info_data_table(&(ctk_3d_vision_pro->table), HTU(0)->glasses_info); - gtk_widget_show_all(GTK_WIDGET(ctk_3d_vision_pro->table.data_table)); - } -no_name_set: gtk_widget_hide(dlg->dlg_rename_glasses); @@ -1846,7 +1846,8 @@ GtkTextBuffer *ctk_3d_vision_pro_create_help(GtkTextTagTable *table) ctk_help_para(b, &i, __goggle_info_tooltip); ctk_help_heading(b, &i, "Glasses Name"); - ctk_help_para(b, &i, "Each pair of glasses has an unique name. " + ctk_help_para(b, &i, "Each pair of glasses has an unique name and the name should " + "start and end with an alpha-numeric character. " "Glasses can be renamed using Rename button."); ctk_help_heading(b, &i, "Battery Level"); diff --git a/src/gtk+-2.x/ctkcolorcorrection.c b/src/gtk+-2.x/ctkcolorcorrection.c index 464905d..b882db3 100644 --- a/src/gtk+-2.x/ctkcolorcorrection.c +++ b/src/gtk+-2.x/ctkcolorcorrection.c @@ -186,6 +186,7 @@ GtkWidget* ctk_color_correction_new(NvCtrlAttributeHandle *handle, { GObject *object; CtkColorCorrection *ctk_color_correction; + GtkRequisition requisition; GtkWidget *menu; GtkWidget *image; @@ -502,7 +503,24 @@ GtkWidget* ctk_color_correction_new(NvCtrlAttributeHandle *handle, /* finally, show the widget */ gtk_widget_show_all(GTK_WIDGET(object)); - + + /* + * lock the size of the confirm button, so that it is not resized + * when we change the button text later. + * + * Note: this assumes that the initial size of the button is the + * largest size needed for any text placed in the button. In the + * case of the confirm button, this works out: + * + * "Confirm Current Changes" <-- initial value + * "%d Seconds to Confirm" + */ + + gtk_widget_size_request(ctk_color_correction->confirm_button, + &requisition); + gtk_widget_set_size_request(ctk_color_correction->confirm_button, + requisition.width, -1); + return GTK_WIDGET(object); } @@ -704,8 +722,10 @@ static void reset_button_clicked( FALSE); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); /* kill the timer */ - g_source_remove(ctk_color_correction->confirm_timer); - ctk_color_correction->confirm_timer = 0; + if (ctk_color_correction->confirm_timer) { + g_source_remove(ctk_color_correction->confirm_timer); + ctk_color_correction->confirm_timer = 0; + } /* Reset confirm button text */ gtk_button_set_label(GTK_BUTTON(ctk_color_correction->confirm_button), diff --git a/src/gtk+-2.x/ctkdisplayconfig-utils.c b/src/gtk+-2.x/ctkdisplayconfig-utils.c index 2ec51c1..4199429 100644 --- a/src/gtk+-2.x/ctkdisplayconfig-utils.c +++ b/src/gtk+-2.x/ctkdisplayconfig-utils.c @@ -38,6 +38,7 @@ #include "msg.h" #include "parse.h" #include "command-line.h" +#include "common-utils.h" #include "ctkdisplayconfig-utils.h" #include "ctkutils.h" @@ -1880,8 +1881,7 @@ nvDisplayPtr gpu_add_display_from_server(nvGpuPtr gpu, gpu->num_gvo_modes += count_number_of_bits(valid2); gpu->num_gvo_modes += count_number_of_bits(valid3); if (gpu->num_gvo_modes > 0) { - gpu->gvo_mode_data = (GvoModeData *)calloc(gpu->num_gvo_modes, - sizeof(GvoModeData)); + gpu->gvo_mode_data = calloc(gpu->num_gvo_modes, sizeof(GvoModeData)); } if (!gpu->gvo_mode_data) { gpu->num_gvo_modes = 0; @@ -2097,7 +2097,7 @@ static int gpu_add_screen_from_server(nvGpuPtr gpu, int screen_id, nv_warning_msg(*err_str); goto fail; } - screen->dynamic_twinview = val ? TRUE : FALSE; + screen->dynamic_twinview = !!val; /* See if the screen is set to not scanout */ @@ -2109,7 +2109,7 @@ static int gpu_add_screen_from_server(nvGpuPtr gpu, int screen_id, nv_warning_msg(*err_str); goto fail; } - screen->no_scanout = (val == NV_CTRL_NO_SCANOUT_ENABLED) ? TRUE : FALSE; + screen->no_scanout = (val == NV_CTRL_NO_SCANOUT_ENABLED); /* XXX Currently there is no support for screens that are scanning @@ -2134,7 +2134,7 @@ static int gpu_add_screen_from_server(nvGpuPtr gpu, int screen_id, } ret = NvCtrlGetAttribute(screen->handle, - NV_CTRL_SHOW_SLI_HUD, + NV_CTRL_SHOW_SLI_VISUAL_INDICATOR, &tmp); screen->sli = (ret == NvCtrlSuccess); @@ -2395,8 +2395,7 @@ static Bool layout_add_gpu_from_server(nvLayoutPtr layout, unsigned int gpu_id, goto fail; } - get_bus_related_info(gpu->handle, NULL, &(gpu->pci_bus_id)); - + get_bus_id_str(gpu->handle, &(gpu->pci_bus_id)); ret = NvCtrlGetAttribute(gpu->handle, NV_CTRL_MAX_SCREEN_WIDTH, (int *)&(gpu->max_width)); @@ -2966,9 +2965,8 @@ static void update_xconfig_save_buffer(SaveXConfDlg *dlg) G_CALLBACK(xconfig_update_buffer), (gpointer) dlg); gtk_widget_set_sensitive(dlg->btn_xconfig_merge, - (dlg->merge_toggleable && mergeable) ? - TRUE : FALSE); - + dlg->merge_toggleable && mergeable); + /* We're done with the user's X config, so do some cleanup, * but make sure to handle the case where the generation @@ -3254,7 +3252,7 @@ SaveXConfDlg *create_save_xconfig_dialog(GtkWidget *parent, gchar *filename; const char *tmp_filename; - dlg = (SaveXConfDlg *) malloc (sizeof(SaveXConfDlg)); + dlg = malloc(sizeof(SaveXConfDlg)); if (!dlg) return NULL; dlg->parent = parent; diff --git a/src/gtk+-2.x/ctkdisplayconfig.c b/src/gtk+-2.x/ctkdisplayconfig.c index f9bd9f0..4dbcefa 100644 --- a/src/gtk+-2.x/ctkdisplayconfig.c +++ b/src/gtk+-2.x/ctkdisplayconfig.c @@ -2204,8 +2204,7 @@ static void setup_display_refresh_dropdown(CtkDisplayConfig *ctk_object) ctk_object->refresh_table_len = 0; } ctk_object->refresh_table = - (nvModeLinePtr *)calloc(1, display->num_modelines - * sizeof(nvModeLinePtr)); + calloc(display->num_modelines, sizeof(nvModeLinePtr)); if (!ctk_object->refresh_table) { goto fail; } @@ -2440,8 +2439,7 @@ static void setup_display_resolution_dropdown(CtkDisplayConfig *ctk_object) ctk_object->resolution_table_len = 0; } ctk_object->resolution_table = - (nvModeLinePtr *)calloc(1, (display->num_modelines +1) - *sizeof(nvModeLinePtr)); + calloc(display->num_modelines + 1, sizeof(nvModeLinePtr)); if (!ctk_object->resolution_table) { goto fail; } @@ -2590,7 +2588,7 @@ static GtkWidget* generate_display_modelname_dropdown } ctk_object->display_model_table = - (nvDisplayPtr *)calloc(1, display_count * sizeof(nvDisplayPtr)); + calloc(display_count, sizeof(nvDisplayPtr)); if (!ctk_object->display_model_table) { gtk_option_menu_remove_menu @@ -2749,9 +2747,8 @@ static void setup_display_position_relative(CtkDisplayConfig *ctk_object) display->screen->num_displays -1; ctk_object->display_position_table = - (nvDisplayPtr *)calloc(1, ctk_object->display_position_table_len * - sizeof(nvDisplayPtr)); - + calloc(ctk_object->display_position_table_len, sizeof(nvDisplayPtr)); + if (!ctk_object->display_position_table) { goto fail; } @@ -3316,9 +3313,8 @@ static void setup_screen_position_relative(CtkDisplayConfig *ctk_object) free(ctk_object->screen_position_table); } ctk_object->screen_position_table = - (nvScreenPtr *)calloc(1, ctk_object->screen_position_table_len * - sizeof(nvScreenPtr)); - + calloc(ctk_object->screen_position_table_len, sizeof(nvScreenPtr)); + if (!ctk_object->screen_position_table) { goto fail; } @@ -6693,14 +6689,14 @@ static Bool add_monitor_to_xconfig(nvDisplayPtr display, XConfigPtr config, monitor = (XConfigMonitorPtr)calloc(1, sizeof(XConfigMonitorRec)); if (!monitor) goto fail; - monitor->identifier = (char *)malloc(32); + monitor->identifier = malloc(32); snprintf(monitor->identifier, 32, "Monitor%d", monitor_id); monitor->vendor = xconfigStrdup("Unknown"); /* XXX */ /* Copy the model name string, stripping any '"' characters */ len = strlen(display->name); - monitor->modelname = (char *)malloc(len + 1); + monitor->modelname = malloc(len + 1); for (i = 0, j = 0; i < len; i++, j++) { if (display->name[i] == '\"') { if (++i >= len) @@ -6842,7 +6838,7 @@ static XConfigDevicePtr add_device_to_xconfig(nvGpuPtr gpu, XConfigPtr config, /* Fill out the device information */ - device->identifier = (char *)malloc(32); + device->identifier = malloc(32); snprintf(device->identifier, 32, "Device%d", device_id); device->driver = xconfigStrdup("nvidia"); @@ -6938,7 +6934,7 @@ static int add_screen_to_xconfig(CtkDisplayConfig *ctk_object, /* Fill out the screen information */ - conf_screen->identifier = (char *)malloc(32); + conf_screen->identifier = malloc(32); snprintf(conf_screen->identifier, 32, "Screen%d", screen->scrnum); diff --git a/src/gtk+-2.x/ctkdisplaylayout.c b/src/gtk+-2.x/ctkdisplaylayout.c index d43737a..c116b59 100644 --- a/src/gtk+-2.x/ctkdisplaylayout.c +++ b/src/gtk+-2.x/ctkdisplaylayout.c @@ -195,7 +195,7 @@ static void zorder_layout(CtkDisplayLayout *ctk_object) /* Create the Z-order buffer */ - ctk_object->Zorder = (ZNode *)calloc(ctk_object->Zcount, sizeof(ZNode)); + ctk_object->Zorder = calloc(ctk_object->Zcount, sizeof(ZNode)); if (!ctk_object->Zorder) { ctk_object->Zcount = 0; return; @@ -2215,8 +2215,7 @@ ZNode *get_screen_zorder_move_data(CtkDisplayLayout *ctk_object, /* Only move screen if it is not moving to the same location */ if (move_to != i) { - tmpzo = (ZNode *)malloc((1 + screen->num_displays) * - sizeof(ZNode)); + tmpzo = malloc((1 + screen->num_displays) * sizeof(ZNode)); if (!tmpzo) return NULL; memcpy(tmpzo, @@ -2872,8 +2871,7 @@ GtkWidget* ctk_display_layout_new(NvCtrlAttributeHandle *handle, gdk_color_parse(LAYOUT_IMG_SELECT_COLOR, &(ctk_object->select_color)); /* Parse the device color palettes */ - ctk_object->color_palettes = - (GdkColor *)calloc(1, NUM_COLORS * sizeof(GdkColor)); + ctk_object->color_palettes = calloc(NUM_COLORS, sizeof(GdkColor)); for (i = 0; i < NUM_COLORS; i++) { gdk_color_parse(__palettes_color_names[i], &(ctk_object->color_palettes[i])); diff --git a/src/gtk+-2.x/ctkditheringcontrols.c b/src/gtk+-2.x/ctkditheringcontrols.c index d3e4b60..3ff91e0 100644 --- a/src/gtk+-2.x/ctkditheringcontrols.c +++ b/src/gtk+-2.x/ctkditheringcontrols.c @@ -250,6 +250,9 @@ GtkWidget* ctk_dithering_controls_new(NvCtrlAttributeHandle *handle, case NV_CTRL_DITHERING_MODE_STATIC_2X2: menu_item = gtk_menu_item_new_with_label("Static 2X2"); break; + case NV_CTRL_DITHERING_MODE_TEMPORAL: + menu_item = gtk_menu_item_new_with_label("Temporal"); + break; default: case NV_CTRL_DITHERING_MODE_AUTO: menu_item = gtk_menu_item_new_with_label("Auto"); @@ -517,6 +520,10 @@ static Bool update_dithering_info(gpointer user_data) gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_current_mode), "Static 2x2"); break; + case NV_CTRL_CURRENT_DITHERING_MODE_TEMPORAL: + gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_current_mode), + "Temporal"); + break; default: case NV_CTRL_CURRENT_DITHERING_MODE_NONE: gtk_label_set_text(GTK_LABEL(ctk_dithering_controls->dithering_current_mode), @@ -609,11 +616,12 @@ void post_dithering_mode_update(CtkDitheringControls *ctk_dithering_controls, static const char *dither_mode_table[] = { "Auto", /* NV_CTRL_DITHERING_MODE_AUTO */ "Dynamic 2x2", /* NV_CTRL_DITHERING_MODE_DYNAMIC_2X2 */ - "Static 2x2" /* NV_CTRL_DITHERING_MODE_STATIC_2X2 */ + "Static 2x2", /* NV_CTRL_DITHERING_MODE_STATIC_2X2 */ + "Temporal", /* NV_CTRL_DITHERING_MODE_TEMPORAL */ }; if (dithering_mode < NV_CTRL_DITHERING_MODE_AUTO || - dithering_mode > NV_CTRL_DITHERING_MODE_STATIC_2X2) { + dithering_mode > NV_CTRL_DITHERING_MODE_TEMPORAL) { return; } diff --git a/src/gtk+-2.x/ctkecc.c b/src/gtk+-2.x/ctkecc.c index a31b4dd..167fc02 100644 --- a/src/gtk+-2.x/ctkecc.c +++ b/src/gtk+-2.x/ctkecc.c @@ -50,7 +50,7 @@ static const char *__ecc_status_help = static const char *__dbit_error_help = "Returns the number of double-bit ECC errors detected by " -"the targeted GPU since the last POST."; +"the targeted GPU since the last system reboot."; static const char *__aggregate_dbit_error_help = "Returns the number of double-bit ECC errors detected by the " @@ -58,18 +58,20 @@ static const char *__aggregate_dbit_error_help = static const char *__configuration_status_help = "Returns the current ECC configuration setting or specifies new " -"settings. A new setting do not take effect until the next POST."; +"settings. Changes to these settings do not take effect until the next " +"system reboot."; static const char *__clear_button_help = -"This button is used to clear the ECC errors detected since last POST."; +"This button is used to clear the ECC errors detected since the last system reboot."; static const char *__clear_aggregate_button_help = -"This button is used to reset aggregate ECC errors counter."; +"This button is used to reset the aggregate ECC errors counter."; static const char *__reset_default_config_button_help = "The button is used to restore the GPU's default ECC configuration setting."; static void ecc_config_button_toggled(GtkWidget *, gpointer); +static void show_ecc_toggle_warning_dlg(CtkEcc *); GType ctk_ecc_get_type(void) { @@ -230,6 +232,11 @@ static void reset_default_config_button_clicked(GtkWidget *widget, NvCtrlSetAttribute(ctk_ecc->handle, NV_CTRL_GPU_ECC_CONFIGURATION, status); + + /* show popup dialog*/ + show_ecc_toggle_warning_dlg(ctk_ecc); + + gtk_widget_set_sensitive(ctk_ecc->reset_default_config_button, FALSE); ctk_config_statusbar_message(ctk_ecc->ctk_config, "Set to default configuration."); @@ -277,6 +284,30 @@ static void clear_aggregate_ecc_errors_button_clicked(GtkWidget *widget, +static void show_ecc_toggle_warning_dlg(CtkEcc *ctk_ecc) +{ + GtkWidget *dlg, *parent; + + /* return early if message dialog already shown */ + if (ctk_ecc->ecc_toggle_warning_dlg_shown) { + return; + } + ctk_ecc->ecc_toggle_warning_dlg_shown = TRUE; + parent = ctk_get_parent_window(GTK_WIDGET(ctk_ecc)); + + dlg = gtk_message_dialog_new (GTK_WINDOW(parent), + GTK_DIALOG_MODAL, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Changes to the ECC setting " + "require a system reboot before " + "taking effect."); + gtk_dialog_run(GTK_DIALOG(dlg)); + gtk_widget_destroy (dlg); +} + + + /* * ecc_config_button_toggled() - callback function for * enable ECC checkbox. @@ -289,9 +320,16 @@ static void ecc_config_button_toggled(GtkWidget *widget, CtkEcc *ctk_ecc = CTK_ECC(user_data); 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); + + gtk_widget_set_sensitive(ctk_ecc->reset_default_config_button, TRUE); + ctk_config_statusbar_message(ctk_ecc->ctk_config, "ECC %s.", enabled ? "enabled" : "disabled"); @@ -314,6 +352,7 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle, gboolean dbit_error_available; gboolean aggregate_dbit_error_available; gboolean ecc_enabled; + gboolean ecc_default_status; ReturnStatus ret; gchar *ecc_enabled_string; @@ -339,6 +378,7 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle, ctk_ecc = CTK_ECC(object); ctk_ecc->handle = handle; ctk_ecc->ctk_config = ctk_config; + ctk_ecc->ecc_toggle_warning_dlg_shown = FALSE; dbit_error_available = TRUE; aggregate_dbit_error_available = TRUE; @@ -359,6 +399,17 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle, } ctk_ecc->ecc_enabled = ecc_enabled; + /* get default status */ + ret = NvCtrlGetAttribute(handle, + NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION, + &val); + if (ret != NvCtrlSuccess || + val == NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION_DISABLED) { + ecc_default_status = FALSE; + } else { + ecc_default_status = TRUE; + } + /* Query ECC errors */ ret = NvCtrlGetAttribute64(handle, NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS, @@ -512,7 +563,8 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle, ctk_config_set_tooltip(ctk_config, ctk_ecc->reset_default_config_button, __reset_default_config_button_help); gtk_widget_set_sensitive(ctk_ecc->reset_default_config_button, - ecc_config_supported && ecc_enabled); + ecc_config_supported && + (ecc_enabled != ecc_default_status)); g_signal_connect(G_OBJECT(ctk_ecc->reset_default_config_button), "clicked", G_CALLBACK(reset_default_config_button_clicked), @@ -534,7 +586,7 @@ GtkWidget* ctk_ecc_new(NvCtrlAttributeHandle *handle, } GtkTextBuffer *ctk_ecc_create_help(GtkTextTagTable *table, - CtkEcc *ctk_ecc) + CtkEcc *ctk_ecc) { GtkTextIter i; GtkTextBuffer *b; @@ -575,7 +627,6 @@ GtkTextBuffer *ctk_ecc_create_help(GtkTextTagTable *table, ctk_help_heading(b, &i, "Reset Default Configuration"); ctk_help_para(b, &i, __reset_default_config_button_help); - ctk_help_finish(b); return b; diff --git a/src/gtk+-2.x/ctkecc.h b/src/gtk+-2.x/ctkecc.h index b301ea7..97f72f9 100644 --- a/src/gtk+-2.x/ctkecc.h +++ b/src/gtk+-2.x/ctkecc.h @@ -69,6 +69,7 @@ struct _CtkEcc GtkWidget* configuration_status; gboolean ecc_enabled; + gboolean ecc_toggle_warning_dlg_shown; gboolean dbit_error_available; gboolean aggregate_dbit_error_available; diff --git a/src/gtk+-2.x/ctkevent.c b/src/gtk+-2.x/ctkevent.c index c1d6841..c175a8c 100644 --- a/src/gtk+-2.x/ctkevent.c +++ b/src/gtk+-2.x/ctkevent.c @@ -214,7 +214,7 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) MAKE_SIGNAL(NV_CTRL_IMAGE_SETTINGS); MAKE_SIGNAL(NV_CTRL_XINERAMA_STEREO); MAKE_SIGNAL(NV_CTRL_BUS_RATE); - MAKE_SIGNAL(NV_CTRL_SHOW_SLI_HUD); + MAKE_SIGNAL(NV_CTRL_SHOW_SLI_VISUAL_INDICATOR); MAKE_SIGNAL(NV_CTRL_XV_SYNC_TO_DISPLAY); MAKE_SIGNAL(NV_CTRL_GVO_OVERRIDE_HW_CSC); MAKE_SIGNAL(NV_CTRL_GVO_COMPOSITE_TERMINATION); @@ -313,11 +313,13 @@ static void ctk_event_class_init(CtkEventClass *ctk_event_class) MAKE_SIGNAL(NV_CTRL_THERMAL_SENSOR_READING); MAKE_SIGNAL(NV_CTRL_THERMAL_SENSOR_PROVIDER); MAKE_SIGNAL(NV_CTRL_THERMAL_SENSOR_TARGET); + MAKE_SIGNAL(NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR); MAKE_SIGNAL(NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS); MAKE_SIGNAL(NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS); MAKE_SIGNAL(NV_CTRL_GPU_PCIE_MAX_LINK_SPEED); MAKE_SIGNAL(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL); MAKE_SIGNAL(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE); + MAKE_SIGNAL(NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES); MAKE_SIGNAL(NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY); MAKE_SIGNAL(NV_CTRL_3D_VISION_PRO_GLASSES_MISSED_SYNC_CYCLES); MAKE_SIGNAL(NV_CTRL_GVO_ANC_PARITY_COMPUTATION); diff --git a/src/gtk+-2.x/ctkframelock.c b/src/gtk+-2.x/ctkframelock.c index d0c3e01..ef610e0 100644 --- a/src/gtk+-2.x/ctkframelock.c +++ b/src/gtk+-2.x/ctkframelock.c @@ -281,6 +281,10 @@ static const char * __show_extra_info_button_help = "The Show Extra Info button displays extra information and settings " "for various devices."; +static const char * __expand_all_button_help = +"This button expands or collapses all the entries in the framelock device " +"list."; + static const char * __use_house_sync_button_help = "The Use House Sync if Present checkbox tells the server G-Sync device to " "generate the master frame lock signal from the incoming house sync signal " @@ -341,6 +345,7 @@ static GtkWidget *create_enable_confirm_dialog(CtkFramelock *); static void add_devices_response(GtkWidget *, gint, gpointer); static void add_devices_repond_ok(GtkWidget *, gpointer); static void remove_devices_response(GtkWidget *, gint, gpointer); +static void expand_all_clicked(GtkWidget *, gpointer); static void error_msg(CtkFramelock *, const gchar *, ...); @@ -359,6 +364,7 @@ static gboolean check_for_ethernet(gpointer); static void update_framelock_controls(CtkFramelock *); static void update_house_sync_controls(CtkFramelock *); +static void update_expand_all_button_status(CtkFramelock *); static void apply_parsed_attribute_list(CtkFramelock *ctk_framelock, ParsedAttribute *list); @@ -1228,26 +1234,19 @@ static void list_entry_update_display_controls(CtkFramelock *ctk_framelock, (GTK_TOGGLE_BUTTON(data->client_checkbox)); /* Server Checkbox is unavailable when framelock is enabled, - * this display is set as client, this display cannot be master + * this display cannot be master * (display is driven by GPU that is connected through a - * secondary connector.), or another server is already selected. + * secondary connector.). */ - sensitive = (!framelock_enabled && - !client_checked && - data->masterable && - (!server_entry || data == server_entry->data)); + sensitive = (!framelock_enabled && data->masterable); gtk_widget_set_sensitive(data->server_label, sensitive); gtk_widget_set_sensitive(data->server_checkbox, sensitive); /* When a server is selected, this display can only become a - * client if its refresh rate matches that of the client, - * and the X server reports that it can frame lock this client - * correctly. + * client if the X server reports that it can frame lock this + * client correctly. */ - sensitive = (!framelock_enabled && - !server_checked && - data->slaveable && - (!server_data || data->rate == server_data->rate)); + sensitive = (!framelock_enabled && data->slaveable); gtk_widget_set_sensitive(data->client_label, sensitive); gtk_widget_set_sensitive(data->client_checkbox, sensitive); @@ -1362,7 +1361,7 @@ static void update_framelock_controls(CtkFramelock *ctk_framelock) /* G-Sync Buttons */ gtk_widget_set_sensitive(ctk_framelock->remove_devices_button, - (tree->selected_entry==NULL)?FALSE:TRUE); + tree->selected_entry != NULL); gtk_widget_set_sensitive(ctk_framelock->extra_info_button, tree->nentries); @@ -1413,6 +1412,9 @@ static void update_framelock_controls(CtkFramelock *ctk_framelock) /* House Sync */ update_house_sync_controls(ctk_framelock); + + /* Update the expand/collapse all button status */ + update_expand_all_button_status(ctk_framelock); } @@ -1670,6 +1672,8 @@ static void expander_button_clicked(GtkWidget *widget, gpointer user_data) } entry->expanded = !(entry->expanded); + + update_expand_all_button_status(entry->tree->ctk_framelock); } @@ -2660,6 +2664,134 @@ static void toggle_extra_info(GtkWidget *widget, gpointer data) (enabled ? "Showing" : "Hiding")); } +/** update_expand_all_button_status() ************************ + * + * This function updates the state of expand all button based + * on entries in the device list tree & user interaction. + */ +static void update_expand_all_button_status(CtkFramelock *ctk_framelock) +{ + nvListTreePtr tree = (nvListTreePtr) ctk_framelock->tree; + nvListEntryPtr entry, child; + + if (!tree) { + return; + } + + /* + * This is set between !tree & !tree->entries checks because, we will + * have to disable "Expand All" button in case there are no entries in the + * tree, before we return from here because of NULL tree->entries value. + */ + gtk_widget_set_sensitive(ctk_framelock->expand_all_button, + tree->nentries); + + if (!tree->entries) { + return; + } + + ctk_framelock->is_expanded = TRUE; + for (entry = tree->entries; entry && ctk_framelock->is_expanded; + entry = entry->next_sibling) { + + /* if any top-level entry is not expanded, then advertise "Expand All" */ + + if (!entry->expanded) { + ctk_framelock->is_expanded = FALSE; + break; + } + + /* if any child entry is not expanded, then advertise "Expand All" */ + + child = entry->children; + while (child) { + if (!child->expanded) { + ctk_framelock->is_expanded = FALSE; + break; + } + child = child->next_sibling; + } + } + + /* based on the status of the entries, advertise "Expand/Collapse All" */ + + if (ctk_framelock->is_expanded) { + gtk_button_set_label(GTK_BUTTON(ctk_framelock->expand_all_button), + "Collapse All"); + } else { + gtk_button_set_label(GTK_BUTTON(ctk_framelock->expand_all_button), + "Expand All"); + } +} + + +/** list_entry_expand_collapse() ********************************************** + * + * This function expands/collapses the entry & all the corresponding + * child entries. + */ +static void list_entry_expand_collapse(nvListEntryPtr entry, gboolean expand) +{ + if (!entry || !entry->expander_button || !entry->child_vbox) { + return; + } + + gtk_container_remove(GTK_CONTAINER(entry->expander_button), + entry->expander_button_image); + + if (expand) { + /* Expand */ + entry->expander_button_image = + gtk_image_new_from_stock(GTK_STOCK_REMOVE, + GTK_ICON_SIZE_SMALL_TOOLBAR); + } else { + /* Collapse */ + entry->expander_button_image = + gtk_image_new_from_stock(GTK_STOCK_ADD, + GTK_ICON_SIZE_SMALL_TOOLBAR); + } + + gtk_widget_set_size_request(entry->expander_button, 20, 20); + gtk_container_add(GTK_CONTAINER(entry->expander_button), + entry->expander_button_image); + + gtk_widget_show_all(entry->expander_button); + + if (expand) { + /* Expand */ + gtk_widget_show(entry->child_vbox); + entry->expanded = TRUE; + } else { + /* Collapse */ + gtk_widget_hide(entry->child_vbox); + entry->expanded = FALSE; + } + + list_entry_expand_collapse(entry->children, expand); + + list_entry_expand_collapse(entry->next_sibling, expand); +} + +/** expand_all_clicked() ********************************************** + * + * Callback function for the 'Expand/Collapse All' button. + * This button expands/collapses framelock list entries. + */ +static void expand_all_clicked(GtkWidget *widget, gpointer data) +{ + CtkFramelock *ctk_framelock = CTK_FRAMELOCK(data); + nvListTreePtr tree = (nvListTreePtr) ctk_framelock->tree; + + if (!tree->entries && !tree->nentries) { + return; + } + + /* expand or collapse all the entries */ + list_entry_expand_collapse(tree->entries, !ctk_framelock->is_expanded); + + /* update the expand_all button stattus */ + update_expand_all_button_status(ctk_framelock); +} /** toggle_server() ************************************************** @@ -2671,7 +2803,10 @@ static void toggle_extra_info(GtkWidget *widget, gpointer data) static void toggle_server(GtkWidget *widget, gpointer data) { nvListEntryPtr entry = (nvListEntryPtr)data; + nvListEntryPtr server_entry = NULL; nvDisplayDataPtr display_data = (nvDisplayDataPtr)(entry->data); + nvDisplayDataPtr server_entry_display_data = NULL; + nvListTreePtr tree = (nvListTreePtr)(entry->tree); nvGPUDataPtr gpu_data = (nvGPUDataPtr)(entry->parent->data); gboolean server_checked; @@ -2682,6 +2817,23 @@ static void toggle_server(GtkWidget *widget, gpointer data) server_checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(display_data->server_checkbox)); + /* + * If the device is selected as server, uncheck the client box for + * that device & also uncheck server box for any other device if + * it was selected as server before. + */ + if (server_checked) { + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON(display_data->client_checkbox), FALSE); + server_entry = get_display_server_entry(tree); + if (server_entry) { + server_entry_display_data = (nvDisplayDataPtr)server_entry->data; + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON(server_entry_display_data->server_checkbox), + FALSE); + } + } + entry->tree->server_entry = (server_checked ? entry : NULL); gpu_data->server_mask = (server_checked ? display_data->device_mask : 0); @@ -2728,6 +2880,14 @@ static void toggle_client(GtkWidget *widget, gpointer data) if (client_checked) { gpu_data->clients_mask |= display_data->device_mask; + + /* + * if the device is selected as client, uncheck the server box + * for the same. + */ + + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON(display_data->server_checkbox), FALSE); } else { gpu_data->clients_mask &= ~(display_data->device_mask); } @@ -2797,8 +2957,8 @@ static gboolean set_enable_sync_clients(nvListEntryPtr entry_list, nvListEntryPtr entry; nvListEntryPtr server_gpu_entry; - gint framelock_enabled = 0; - gint something_enabled = 0; + gboolean framelock_enabled = FALSE; + gboolean something_enabled = FALSE; ReturnStatus ret; @@ -2838,10 +2998,10 @@ static gboolean set_enable_sync_clients(nvListEntryPtr entry_list, if (ret != NvCtrlSuccess) continue; data->enabled = something_enabled; - framelock_enabled = framelock_enabled ? 1 : something_enabled; + framelock_enabled = (framelock_enabled || something_enabled); } - return framelock_enabled?TRUE:FALSE; + return framelock_enabled; } @@ -4432,6 +4592,13 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, __show_extra_info_button_help); ctk_framelock->extra_info_button = button; + button = my_button_new_with_label("Expand All", 15, 0); + g_signal_connect(G_OBJECT(button), + "clicked", G_CALLBACK(expand_all_clicked), + (gpointer) ctk_framelock); + ctk_config_set_tooltip(ctk_config, button, + __expand_all_button_help); + ctk_framelock->expand_all_button = button; button = gtk_check_button_new_with_label("Use House Sync if Present"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); @@ -4588,6 +4755,8 @@ GtkWidget* ctk_framelock_new(NvCtrlAttributeHandle *handle, gtk_container_add(GTK_CONTAINER(vp), vbox); hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_end(GTK_BOX(hbox), ctk_framelock->expand_all_button, + FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(hbox), ctk_framelock->extra_info_button, FALSE, FALSE, 0); // XXX Add me later.... @@ -5434,7 +5603,7 @@ static gint add_devices(CtkFramelock *ctk_framelock, */ /* +2 extra characters in case we need to append ":0" */ - server_name = (char *) malloc(strlen(display_name) +3); + server_name = malloc(strlen(display_name) + 3); if (!server_name) { goto done; } diff --git a/src/gtk+-2.x/ctkframelock.h b/src/gtk+-2.x/ctkframelock.h index 96398ee..e538cf7 100644 --- a/src/gtk+-2.x/ctkframelock.h +++ b/src/gtk+-2.x/ctkframelock.h @@ -73,6 +73,8 @@ struct _CtkFramelock GtkWidget *remove_devices_button; GtkWidget *short_labels_button; GtkWidget *extra_info_button; + GtkWidget *expand_all_button; + gboolean is_expanded; /* House sync */ GtkWidget *house_sync_frame; diff --git a/src/gtk+-2.x/ctkglx.c b/src/gtk+-2.x/ctkglx.c index 3cf1c9b..895b399 100644 --- a/src/gtk+-2.x/ctkglx.c +++ b/src/gtk+-2.x/ctkglx.c @@ -35,6 +35,7 @@ #include "ctkutils.h" #include "ctkconfig.h" #include "ctkhelp.h" +#include "ctkconstants.h" #include <GL/glx.h> /* GLX #defines */ @@ -44,6 +45,8 @@ /* FBConfig tooltips */ +static const char * __show_fbc_help = + "Show the GLX Frame Buffer Configurations table in a new window."; static const char * __fid_help = "fid (Frame buffer ID) - Frame Buffer Configuration ID."; static const char * __vid_help = @@ -167,6 +170,51 @@ static void dummy_button_signal(GtkWidget *widget, } +/* + * show_fbc_toggled() - called when the show GLX Frame Buffer Configurations + * button has been toggled. + */ + +static void show_fbc_toggled(GtkWidget *widget, gpointer user_data) +{ + CtkGLX *ctk_glx = user_data; + gboolean enabled; + + /* get the enabled state */ + + enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + + if (enabled) { + gtk_widget_show_all(ctk_glx->fbc_window); + } else { + gtk_widget_hide(ctk_glx->fbc_window); + } + + ctk_config_statusbar_message(ctk_glx->ctk_config, + "Show GLX Frame Buffer Configurations button %s.", + enabled ? "enabled" : "disabled"); + +} /* show_fbc_toggled() */ + + +/* + * fbc_window_destroy() - called when the window displaying the + * GLX Frame Buffer Configurations table is closed. + */ +static gboolean +fbc_window_destroy(GtkWidget *widget, GdkEvent *event, gpointer user_data) +{ + CtkGLX *ctk_glx = user_data; + + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON(ctk_glx->show_fbc_button), + FALSE); + + return TRUE; + +} /* fbc_window_destroy() */ + + /* Creates the GLX information widget * * NOTE: The GLX information other than the FBConfigs will @@ -188,13 +236,14 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle, GtkWidget *label; GtkWidget *banner; GtkWidget *hseparator; - GtkWidget *hbox, *hbox1; + GtkWidget *hbox; GtkWidget *vbox, *vbox2; GtkWidget *scrollWin; GtkWidget *event; /* For setting the background color to white */ GtkWidget *data_table, *header_table; GtkWidget *data_viewport, *full_viewport; - GtkWidget *vscrollbar, *hscrollbar, *vpan; + GtkWidget *vscrollbar, *hscrollbar; + GtkWidget *show_fbc_button, *window; GtkRequisition req; ReturnStatus ret; @@ -300,18 +349,31 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle, goto fail; } - - /* Create clist in a scroll box */ - hbox1 = gtk_hbox_new(FALSE, 0); - label = gtk_label_new("Frame Buffer Configurations"); - hseparator = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox1), hseparator, TRUE, TRUE, 5); + show_fbc_button = gtk_toggle_button_new_with_label( + "Show GLX Frame Buffer Configurations"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_fbc_button), FALSE); + ctk_config_set_tooltip(ctk_config, show_fbc_button, __show_fbc_help); + g_signal_connect(G_OBJECT(show_fbc_button), + "clicked", G_CALLBACK(show_fbc_toggled), + (gpointer) ctk_glx); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(window), "GLX Frame Buffer Configurations"); + gtk_container_set_border_width(GTK_CONTAINER(window), CTK_WINDOW_PAD); + gtk_widget_set_size_request(window, 400, 200); + g_signal_connect(G_OBJECT(window), "destroy-event", + G_CALLBACK(fbc_window_destroy), + (gpointer) ctk_glx); + g_signal_connect(G_OBJECT(window), "delete-event", + G_CALLBACK(fbc_window_destroy), + (gpointer) ctk_glx); + + ctk_glx->fbc_window = window; + ctk_glx->show_fbc_button = show_fbc_button; hbox = gtk_hbox_new(FALSE, 0); vbox = gtk_vbox_new(FALSE, 10); vbox2 = gtk_vbox_new(FALSE, 10); - vpan = gtk_vpaned_new(); data_viewport = gtk_viewport_new(NULL, NULL); gtk_widget_set_size_request(data_viewport, 400, 50); @@ -377,13 +439,21 @@ GtkWidget* ctk_glx_new(NvCtrlAttributeHandle *handle, gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), vscrollbar, FALSE, FALSE, 0); + gtk_container_add(GTK_CONTAINER(window), hbox); + vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); - - gtk_paned_pack1 (GTK_PANED (vpan), scrollWin, TRUE, FALSE); - gtk_paned_pack2 (GTK_PANED (vpan), vbox, TRUE, FALSE); - gtk_box_pack_start(GTK_BOX(ctk_glx), vpan, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), show_fbc_button, FALSE, FALSE, 0); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); + + hseparator = gtk_hseparator_new(); + + vbox = gtk_vbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox), scrollWin, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hseparator, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + gtk_box_pack_start(GTK_BOX(ctk_glx), vbox, TRUE, TRUE, 0); /* Fill the data table */ @@ -879,8 +949,10 @@ GtkTextBuffer *ctk_glx_create_help(GtkTextTagTable *table, "by this driver." ); + ctk_help_heading(b, &i, "Show GLX Frame Buffer Configurations"); + ctk_help_para(b, &i, __show_fbc_help); - ctk_help_heading(b, &i, "Frame Buffer Configurations"); + ctk_help_heading(b, &i, "GLX Frame Buffer Configurations"); ctk_help_para(b, &i, "This table lists the supported frame buffer " "configurations for the display."); ctk_help_para(b, &i, diff --git a/src/gtk+-2.x/ctkglx.h b/src/gtk+-2.x/ctkglx.h index 2390ef1..9d595cc 100644 --- a/src/gtk+-2.x/ctkglx.h +++ b/src/gtk+-2.x/ctkglx.h @@ -60,6 +60,8 @@ struct _CtkGLX GtkWidget *glxinfo_vpane; Bool glxinfo_initialized; + GtkWidget *show_fbc_button; + GtkWidget *fbc_window; }; struct _CtkGLXClass diff --git a/src/gtk+-2.x/ctkgpu.c b/src/gtk+-2.x/ctkgpu.c index c03e302..7879770 100644 --- a/src/gtk+-2.x/ctkgpu.c +++ b/src/gtk+-2.x/ctkgpu.c @@ -122,8 +122,8 @@ static gchar *make_display_device_list(NvCtrlAttributeHandle *handle, } /* make_display_device_list() */ -static void get_bus_type_str(NvCtrlAttributeHandle *handle, - gchar **bus) +void get_bus_type_str(NvCtrlAttributeHandle *handle, + gchar **bus) { int tmp, ret, bus_type; gchar *bus_type_str, *bus_rate, *pcie_gen; @@ -180,19 +180,14 @@ static void get_bus_type_str(NvCtrlAttributeHandle *handle, } } -void get_bus_related_info(NvCtrlAttributeHandle *handle, - gchar **bus, - gchar **pci_bus_id) +void get_bus_id_str(NvCtrlAttributeHandle *handle, + gchar **pci_bus_id) { int ret; int pci_domain, pci_bus, pci_device, pci_func; gchar *bus_id; const gchar *__pci_bus_id_unknown = "?@?:?:?"; - if (bus) { - get_bus_type_str(handle, bus); - } - /* NV_CTRL_PCI_DOMAIN & NV_CTRL_PCI_BUS & * NV_CTRL_PCI_DEVICE & NV__CTRL_PCI_FUNCTION */ @@ -317,7 +312,7 @@ GtkWidget* ctk_gpu_new( /* Get Bus related information */ - get_bus_related_info(handle, NULL, &pci_bus_id); + get_bus_id_str(handle, &pci_bus_id); /* NV_CTRL_PCI_ID */ @@ -416,7 +411,7 @@ GtkWidget* ctk_gpu_new( } ret = NvCtrlGetAttribute(screen_handle, - NV_CTRL_SHOW_SLI_HUD, + NV_CTRL_SHOW_SLI_VISUAL_INDICATOR, &tmp); if (ret == NvCtrlSuccess) { tmp_str = g_strdup_printf("%s (SLI)", screens); diff --git a/src/gtk+-2.x/ctkgpu.h b/src/gtk+-2.x/ctkgpu.h index 723d4e0..d08bca6 100644 --- a/src/gtk+-2.x/ctkgpu.h +++ b/src/gtk+-2.x/ctkgpu.h @@ -82,9 +82,10 @@ GtkWidget* ctk_gpu_new (NvCtrlAttributeHandle *handle, CtkEvent *ctk_event, CtkConfig *ctk_config); -void get_bus_related_info(NvCtrlAttributeHandle *handle, - gchar **bus, - gchar **pci_bus_id); +void get_bus_type_str(NvCtrlAttributeHandle *handle, + gchar **bus); +void get_bus_id_str(NvCtrlAttributeHandle *handle, + gchar **pci_bus_id); GtkTextBuffer *ctk_gpu_create_help(GtkTextTagTable *, CtkGpu *); diff --git a/src/gtk+-2.x/ctkgvi.c b/src/gtk+-2.x/ctkgvi.c index d2a89d5..9db4443 100755..100644 --- a/src/gtk+-2.x/ctkgvi.c +++ b/src/gtk+-2.x/ctkgvi.c @@ -553,7 +553,8 @@ GtkWidget* ctk_gvi_new(NvCtrlAttributeHandle *handle, /* Get Bus related information */ - get_bus_related_info(handle, &bus, &pci_bus_id); + get_bus_type_str(handle, &bus); + get_bus_id_str(handle, &pci_bus_id); /* NV_CTRL_IRQ */ diff --git a/src/gtk+-2.x/ctkgvi.h b/src/gtk+-2.x/ctkgvi.h index cff6e2e..cff6e2e 100755..100644 --- a/src/gtk+-2.x/ctkgvi.h +++ b/src/gtk+-2.x/ctkgvi.h diff --git a/src/gtk+-2.x/ctkgvo-banner.c b/src/gtk+-2.x/ctkgvo-banner.c index 9e13c04..508eeb3 100644 --- a/src/gtk+-2.x/ctkgvo-banner.c +++ b/src/gtk+-2.x/ctkgvo-banner.c @@ -176,7 +176,7 @@ GtkWidget* ctk_gvo_banner_new(NvCtrlAttributeHandle *handle, /* handle GVO devices that share the sync input differently */ ctk_gvo_banner->shared_sync_bnc = - (caps & NV_CTRL_GVO_CAPABILITIES_SHARED_SYNC_BNC) ? TRUE : FALSE; + !!(caps & NV_CTRL_GVO_CAPABILITIES_SHARED_SYNC_BNC); /* create the banner image */ diff --git a/src/gtk+-2.x/ctkgvo-csc.c b/src/gtk+-2.x/ctkgvo-csc.c index e511968..5daaead 100644 --- a/src/gtk+-2.x/ctkgvo-csc.c +++ b/src/gtk+-2.x/ctkgvo-csc.c @@ -753,7 +753,7 @@ static void make_entry(CtkGvoCsc *ctk_gvo_csc, 1.0, // upper 0.001, // step incr 0.1, // page incr - 0.1); // page size + 0); // page size *widget = gtk_spin_button_new(adj, // adjustment 0.001, // climb rate diff --git a/src/gtk+-2.x/ctkgvo-sync.c b/src/gtk+-2.x/ctkgvo-sync.c index 4ddd876..0404ca3 100644 --- a/src/gtk+-2.x/ctkgvo-sync.c +++ b/src/gtk+-2.x/ctkgvo-sync.c @@ -842,7 +842,7 @@ static void init_composite_termination(CtkGvoSync *ctk_gvo_sync) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ctk_gvo_sync->composite_termination_button), - ((val == NV_CTRL_GVO_COMPOSITE_TERMINATION_ENABLE) ? TRUE : FALSE)); + val == NV_CTRL_GVO_COMPOSITE_TERMINATION_ENABLE); } /* init_composite_termination() */ @@ -916,8 +916,7 @@ static void update_gvo_sync_sensitivity(CtkGvoSync *ctk_gvo_sync) /* Allow selection of the sync format if we're not free-running */ - sensitive = (ctk_gvo_sync->sync_mode != - NV_CTRL_GVO_SYNC_MODE_FREE_RUNNING) ? TRUE : FALSE; + sensitive = (ctk_gvo_sync->sync_mode != NV_CTRL_GVO_SYNC_MODE_FREE_RUNNING); gtk_widget_set_sensitive(ctk_gvo_sync->sync_format_menu, sensitive); diff --git a/src/gtk+-2.x/ctkgvo.c b/src/gtk+-2.x/ctkgvo.c index 417f51f..738b305 100644 --- a/src/gtk+-2.x/ctkgvo.c +++ b/src/gtk+-2.x/ctkgvo.c @@ -459,8 +459,7 @@ guint ctk_gvo_video_format_valid(CtkGvo *ctk_gvo, const gint format) if ((refresh_rate != input_refresh_rate) && (!(ctk_gvo->caps & NV_CTRL_GVO_CAPABILITIES_MULTIRATE_SYNC) || - (((refresh_rate % 1000) ? TRUE : FALSE) != - ((input_refresh_rate % 1000) ? TRUE : FALSE)))) { + ((refresh_rate % 1000 == 0) != (input_refresh_rate % 1000 == 0)))) { valid &= ~(GVO_VIDEO_FORMAT_REFRESH_VALID); } } @@ -503,7 +502,7 @@ gboolean ctk_gvo_data_format_valid(const gint format) for (i = 0; dataFormatNames[i].name; i++) { if (dataFormatNames[i].format == format) { /* Only the first three formats are valid */ - return (i < 3) ? TRUE : FALSE; + return (i < 3); } } @@ -1152,7 +1151,7 @@ static void fill_output_data_format_menu(CtkGvo *ctk_gvo) g_free(str); } - gtk_widget_set_sensitive(label, (valid ? TRUE : FALSE)); + gtk_widget_set_sensitive(label, valid); } } /* fill_output_data_format_menu() */ @@ -1647,7 +1646,7 @@ static void post_clone_mode_button_toggled(CtkGvo *ctk_gvo) g_list_free(children); enabled = - (ctk_gvo->lock_owner == NV_CTRL_GVO_LOCK_OWNER_CLONE) ? TRUE : FALSE; + (ctk_gvo->lock_owner == NV_CTRL_GVO_LOCK_OWNER_CLONE); if (enabled) { gtk_container_add(GTK_CONTAINER(ctk_gvo->toggle_clone_mode_button), diff --git a/src/gtk+-2.x/ctkmultisample.c b/src/gtk+-2.x/ctkmultisample.c index 530518d..6ef7646 100644 --- a/src/gtk+-2.x/ctkmultisample.c +++ b/src/gtk+-2.x/ctkmultisample.c @@ -792,8 +792,8 @@ static void fsaa_setting_menu_changed(GtkWidget *widget, gpointer user_data) * 2 == enhance */ - override = (idx > 0) ? TRUE : FALSE; - enhance = (idx == 2) ? TRUE : FALSE; + override = (idx > 0); + enhance = (idx == 2); update_fsaa_setting(ctk_multisample, override, enhance); diff --git a/src/gtk+-2.x/ctkopengl.c b/src/gtk+-2.x/ctkopengl.c index a3f444f..d22f0e6 100644 --- a/src/gtk+-2.x/ctkopengl.c +++ b/src/gtk+-2.x/ctkopengl.c @@ -41,7 +41,11 @@ static void post_allow_flipping_button_toggled(CtkOpenGL *, gboolean); static void post_force_stereo_button_toggled(CtkOpenGL *, gboolean); -static void post_show_sli_hud_button_toggled(CtkOpenGL *, gboolean); +static void post_show_sli_visual_indicator_button_toggled(CtkOpenGL *, + gboolean); + +static void post_show_multigpu_visual_indicator_button_toggled(CtkOpenGL *, + gboolean); static void post_xinerama_stereo_button_toggled(CtkOpenGL *, gboolean); @@ -59,7 +63,9 @@ static void stereo_eyes_exchange_button_toggled (GtkWidget *, gpointer); static void aa_line_gamma_toggled (GtkWidget *, gpointer); -static void show_sli_hud_button_toggled (GtkWidget *, gpointer); +static void show_sli_visual_indicator_button_toggled (GtkWidget *, gpointer); + +static void show_multigpu_visual_indicator_button_toggled (GtkWidget *, gpointer); static void value_changed (GtkObject *, gpointer, gpointer); @@ -122,13 +128,20 @@ static const char *__xinerama_stereo_help = "stereo flipping on multiple X screens configured " "with Xinerama. This option is applied immediately."; -static const char *__show_sli_hud_help = +static const char *__show_sli_visual_indicator_help = "Enabling this option causes OpenGL to draw " "information about the current SLI mode on the " "screen. This option is applied to OpenGL " "applications that are started after this option is " "set."; +static const char *__show_multigpu_visual_indicator_help = +"Enabling this option causes OpenGL to draw " +"information about the current Multi-GPU mode on the " +"screen. This option is applied to OpenGL " +"applications that are started after this option is " +"set."; + static const char *__stereo_eyes_exchange_help = "Enabling this option causes OpenGL to draw the left " "eye image in the right eye and vice versa for stereo " @@ -142,8 +155,9 @@ static const char *__stereo_eyes_exchange_help = #define __FORCE_STEREO (1 << 6) #define __IMAGE_SETTINGS (1 << 7) #define __XINERAMA_STEREO (1 << 8) -#define __SHOW_SLI_HUD (1 << 9) +#define __SHOW_SLI_VISUAL_INDICATOR (1 << 9) #define __STEREO_EYES_EXCHANGE (1 << 10) +#define __SHOW_MULTIGPU_VISUAL_INDICATOR (1 << 11) @@ -197,7 +211,8 @@ GtkWidget* ctk_opengl_new(NvCtrlAttributeHandle *handle, NVCTRLAttributeValidValuesRec image_settings_valid; gint image_settings_value; gint aa_line_gamma; - gint show_sli_hud; + gint show_sli_visual_indicator; + gint show_multigpu_visual_indicator; ReturnStatus ret_sync_to_vblank; ReturnStatus ret_flipping_allowed; @@ -206,7 +221,8 @@ GtkWidget* ctk_opengl_new(NvCtrlAttributeHandle *handle, ReturnStatus ret_stereo_eyes_exchange; ReturnStatus ret_image_settings; ReturnStatus ret_aa_line_gamma; - ReturnStatus ret_show_sli_hud; + ReturnStatus ret_show_sli_visual_indicator; + ReturnStatus ret_show_multigpu_visual_indicator; /* Query OpenGL settings */ @@ -241,8 +257,12 @@ GtkWidget* ctk_opengl_new(NvCtrlAttributeHandle *handle, ret_aa_line_gamma = NvCtrlGetAttribute(handle, NV_CTRL_OPENGL_AA_LINE_GAMMA, &aa_line_gamma); - ret_show_sli_hud = NvCtrlGetAttribute(handle, NV_CTRL_SHOW_SLI_HUD, - &show_sli_hud); + ret_show_sli_visual_indicator = NvCtrlGetAttribute(handle, + NV_CTRL_SHOW_SLI_VISUAL_INDICATOR, + &show_sli_visual_indicator); + ret_show_multigpu_visual_indicator = NvCtrlGetAttribute(handle, + NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR, + &show_multigpu_visual_indicator); /* There are no OpenGL settings to change (OpenGL disabled?) */ if ((ret_sync_to_vblank != NvCtrlSuccess) && @@ -252,7 +272,8 @@ GtkWidget* ctk_opengl_new(NvCtrlAttributeHandle *handle, (ret_stereo_eyes_exchange != NvCtrlSuccess) && (ret_image_settings != NvCtrlSuccess) && (ret_aa_line_gamma != NvCtrlSuccess) && - (ret_show_sli_hud != NvCtrlSuccess)) { + (ret_show_sli_visual_indicator != NvCtrlSuccess) && + (ret_show_multigpu_visual_indicator != NvCtrlSuccess)) { return NULL; } @@ -550,33 +571,61 @@ GtkWidget* ctk_opengl_new(NvCtrlAttributeHandle *handle, (GTK_TOGGLE_BUTTON(check_button))); } - if (ret_show_sli_hud == NvCtrlSuccess) { + if (ret_show_sli_visual_indicator == NvCtrlSuccess) { - label = gtk_label_new("Enable SLI Heads-Up-Display"); + label = gtk_label_new("Enable SLI Visual Indicator"); check_button = gtk_check_button_new(); gtk_container_add(GTK_CONTAINER(check_button), label); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button), - show_sli_hud); + show_sli_visual_indicator); gtk_box_pack_start(GTK_BOX(vbox), check_button, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(check_button), "toggled", - G_CALLBACK(show_sli_hud_button_toggled), - (gpointer) ctk_opengl); + G_CALLBACK(show_sli_visual_indicator_button_toggled), + (gpointer) ctk_opengl); g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_SHOW_SLI_HUD), + CTK_EVENT_NAME(NV_CTRL_SHOW_SLI_VISUAL_INDICATOR), G_CALLBACK(value_changed), (gpointer) ctk_opengl); - ctk_config_set_tooltip(ctk_config, check_button, __show_sli_hud_help); + ctk_config_set_tooltip(ctk_config, + check_button, __show_sli_visual_indicator_help); - ctk_opengl->active_attributes |= __SHOW_SLI_HUD; + ctk_opengl->active_attributes |= __SHOW_SLI_VISUAL_INDICATOR; - ctk_opengl->show_sli_hud_button = check_button; + ctk_opengl->show_sli_visual_indicator_button = check_button; } + if (ret_show_multigpu_visual_indicator == NvCtrlSuccess) { + + label = gtk_label_new("Enable Multi-GPU Visual Indicator"); + + check_button = gtk_check_button_new(); + gtk_container_add(GTK_CONTAINER(check_button), label); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button), + show_multigpu_visual_indicator); + + gtk_box_pack_start(GTK_BOX(vbox), check_button, FALSE, FALSE, 0); + + g_signal_connect(G_OBJECT(check_button), "toggled", + G_CALLBACK(show_multigpu_visual_indicator_button_toggled), + (gpointer) ctk_opengl); + + g_signal_connect(G_OBJECT(ctk_event), + CTK_EVENT_NAME(NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR), + G_CALLBACK(value_changed), (gpointer) ctk_opengl); + + ctk_config_set_tooltip(ctk_config, check_button, + __show_multigpu_visual_indicator_help); + + ctk_opengl->active_attributes |= __SHOW_MULTIGPU_VISUAL_INDICATOR; + + ctk_opengl->show_multigpu_visual_indicator_button = check_button; + } gtk_widget_show_all(GTK_WIDGET(object)); @@ -610,11 +659,20 @@ static void post_force_stereo_button_toggled(CtkOpenGL *ctk_opengl, enabled ? "forced" : "not forced"); } -static void post_show_sli_hud_button_toggled(CtkOpenGL *ctk_opengl, - gboolean enabled) +static void post_show_sli_visual_indicator_button_toggled(CtkOpenGL *ctk_opengl, + gboolean enabled) { ctk_config_statusbar_message(ctk_opengl->ctk_config, - "OpenGL SLI HUD %s.", + "OpenGL SLI Visual Indicator %s.", + enabled ? "enabled" : "disabled"); +} + +static void +post_show_multigpu_visual_indicator_button_toggled(CtkOpenGL *ctk_opengl, + gboolean enabled) +{ + ctk_config_statusbar_message(ctk_opengl->ctk_config, + "OpenGL Multi-GPU Visual Indicator %s.", enabled ? "enabled" : "disabled"); } @@ -691,7 +749,7 @@ static void force_stereo_button_toggled(GtkWidget *widget, post_force_stereo_button_toggled(ctk_opengl, enabled); } -static void show_sli_hud_button_toggled(GtkWidget *widget, +static void show_sli_visual_indicator_button_toggled(GtkWidget *widget, gpointer user_data) { CtkOpenGL *ctk_opengl; @@ -701,8 +759,24 @@ static void show_sli_hud_button_toggled(GtkWidget *widget, enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); - NvCtrlSetAttribute(ctk_opengl->handle, NV_CTRL_SHOW_SLI_HUD, enabled); - post_show_sli_hud_button_toggled(ctk_opengl, enabled); + NvCtrlSetAttribute(ctk_opengl->handle, + NV_CTRL_SHOW_SLI_VISUAL_INDICATOR, enabled); + post_show_sli_visual_indicator_button_toggled(ctk_opengl, enabled); +} + +static void show_multigpu_visual_indicator_button_toggled(GtkWidget *widget, + gpointer user_data) +{ + CtkOpenGL *ctk_opengl; + gboolean enabled; + + ctk_opengl = CTK_OPENGL(user_data); + + enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + + NvCtrlSetAttribute(ctk_opengl->handle, + NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR, enabled); + post_show_multigpu_visual_indicator_button_toggled(ctk_opengl, enabled); } static void xinerama_stereo_button_toggled(GtkWidget *widget, @@ -808,10 +882,18 @@ static void value_changed(GtkObject *object, gpointer arg1, gpointer user_data) gtk_widget_set_sensitive(ctk_opengl->aa_line_gamma_scale, event_struct->value); break; - case NV_CTRL_SHOW_SLI_HUD: - button = GTK_TOGGLE_BUTTON(ctk_opengl->show_sli_hud_button); - func = G_CALLBACK(show_sli_hud_button_toggled); - post_show_sli_hud_button_toggled(ctk_opengl, event_struct->value); + case NV_CTRL_SHOW_SLI_VISUAL_INDICATOR: + button = GTK_TOGGLE_BUTTON(ctk_opengl->show_sli_visual_indicator_button); + func = G_CALLBACK(show_sli_visual_indicator_button_toggled); + post_show_sli_visual_indicator_button_toggled(ctk_opengl, + event_struct->value); + break; + case NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR: + button = + GTK_TOGGLE_BUTTON(ctk_opengl->show_multigpu_visual_indicator_button); + func = G_CALLBACK(show_multigpu_visual_indicator_button_toggled); + post_show_multigpu_visual_indicator_button_toggled(ctk_opengl, + event_struct->value); break; default: return; @@ -1124,8 +1206,8 @@ GtkTextBuffer *ctk_opengl_create_help(GtkTextTagTable *table, ctk_help_para(b, &i, __aa_line_gamma_slider_help); } - if (ctk_opengl->active_attributes & __SHOW_SLI_HUD) { - ctk_help_heading(b, &i, "SLI Heads-Up-Display"); + if (ctk_opengl->active_attributes & __SHOW_SLI_VISUAL_INDICATOR) { + ctk_help_heading(b, &i, "SLI Visual Indicator"); ctk_help_para(b, &i, "This option draws information about the current " "SLI mode on top of OpenGL windows. Its behavior " "depends on which SLI mode is in use:"); @@ -1148,6 +1230,30 @@ GtkTextBuffer *ctk_opengl_create_help(GtkTextTagTable *table, "SLIAA and single-GPU AA modes."); } + if (ctk_opengl->active_attributes & __SHOW_MULTIGPU_VISUAL_INDICATOR) { + ctk_help_heading(b, &i, "Multi-GPU Visual Indicator"); + ctk_help_para(b, &i, "This option draws information about the current " + "Multi-GPU mode on top of OpenGL windows. Its behavior " + "depends on which Multi-GPU mode is in use:"); + ctk_help_term(b, &i, "Alternate Frame Rendering"); + ctk_help_para(b, &i, "In AFR mode, a vertical green bar displays the " + "amount of scaling currently being achieved. A longer " + "bar indicates more scaling."); + ctk_help_term(b, &i, "Split-Frame Rendering"); + ctk_help_para(b, &i, "In this mode, OpenGL draws a horizontal green " + "line showing where the screen is split. Everything " + "above the line is drawn on one GPU and everything " + "below is drawn on the other."); + ctk_help_term(b, &i, "Multi-GPU Antialiasing"); + ctk_help_para(b, &i, "In this mode, OpenGL draws a horizontal green " + "line one third of the way across the screen. Above " + "this line, the images from both GPUs are blended to " + "produce the currently selected multi-GPU AA mode. Below the " + "line, the image from just one GPU is displayed without " + "blending. This allows easy comparison between the " + "multi-GPU AA and single-GPU AA modes."); + } + ctk_help_finish(b); return b; diff --git a/src/gtk+-2.x/ctkopengl.h b/src/gtk+-2.x/ctkopengl.h index 0a693dc..465d615 100644 --- a/src/gtk+-2.x/ctkopengl.h +++ b/src/gtk+-2.x/ctkopengl.h @@ -66,7 +66,8 @@ struct _CtkOpenGL GtkWidget *image_settings_scale; GtkWidget *aa_line_gamma_button; GtkWidget *aa_line_gamma_scale; - GtkWidget *show_sli_hud_button; + GtkWidget *show_sli_visual_indicator_button; + GtkWidget *show_multigpu_visual_indicator_button; unsigned int active_attributes; }; diff --git a/src/gtk+-2.x/ctkpowermizer.c b/src/gtk+-2.x/ctkpowermizer.c index 716b5ab..7d0d574 100644 --- a/src/gtk+-2.x/ctkpowermizer.c +++ b/src/gtk+-2.x/ctkpowermizer.c @@ -239,7 +239,7 @@ static void update_perf_mode_table(CtkPowermizer *ctk_powermizer, (entry.nvclock != -1) && (entry.memclock != -1)) { - active = (entry.perf_level == perf_level) ? TRUE : FALSE; + active = (entry.perf_level == perf_level); /* XXX Assume the perf levels are sorted by the server */ diff --git a/src/gtk+-2.x/ctkslimm.c b/src/gtk+-2.x/ctkslimm.c index fc8f896..5c7ff84 100644 --- a/src/gtk+-2.x/ctkslimm.c +++ b/src/gtk+-2.x/ctkslimm.c @@ -522,7 +522,7 @@ static void setup_display_refresh_dropdown(CtkSLIMM *ctk_object) ctk_object->refresh_table_len = 0; } ctk_object->refresh_table = - (nvModeLinePtr *)calloc(ctk_object->num_modelines, sizeof(nvModeLinePtr)); + calloc(ctk_object->num_modelines, sizeof(nvModeLinePtr)); if (!ctk_object->refresh_table) { goto fail; } @@ -694,8 +694,7 @@ static void setup_display_resolution_dropdown(CtkSLIMM *ctk_object) ctk_object->resolution_table_len = 0; } ctk_object->resolution_table = - (nvModeLinePtr *)calloc((ctk_object->num_modelines + 1), - sizeof(nvModeLinePtr)); + calloc((ctk_object->num_modelines + 1), sizeof(nvModeLinePtr)); if (!ctk_object->resolution_table) { goto fail; } @@ -859,7 +858,7 @@ static Bool parse_slimm_layout(CtkSLIMM *ctk_slimm, gridConfigs[loc_idx].rows * gridConfigs[loc_idx].columns; } } - locs = (DpyLoc *)malloc(max_locs * sizeof(DpyLoc)); + locs = malloc(max_locs * sizeof(DpyLoc)); if (!locs) { err_msg = "Out of memory."; goto fail; diff --git a/src/gtk+-2.x/ctkthermal.c b/src/gtk+-2.x/ctkthermal.c index 4b5782c..42b2b23 100644 --- a/src/gtk+-2.x/ctkthermal.c +++ b/src/gtk+-2.x/ctkthermal.c @@ -1187,9 +1187,8 @@ GtkWidget* ctk_thermal_new(NvCtrlAttributeHandle *handle, ctk_thermal->show_fan_control_frame = FALSE; value = NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE; } - - cooler_control_enabled = - (value==NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE)?TRUE:FALSE; + + cooler_control_enabled = (value == NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE); can_access_cooler_level = TRUE; ctk_thermal->cooler_control_enabled = cooler_control_enabled; diff --git a/src/gtk+-2.x/ctkui.c b/src/gtk+-2.x/ctkui.c index 2f43d60..ad77c8f 100644 --- a/src/gtk+-2.x/ctkui.c +++ b/src/gtk+-2.x/ctkui.c @@ -42,14 +42,19 @@ char *ctk_get_display(void) return gdk_get_display(); } -void ctk_main(ParsedAttribute *p, ConfigProperties *conf, - CtrlHandles *h) +void ctk_main(ParsedAttribute *p, + ConfigProperties *conf, + CtrlHandles *h, + const char *page) { int i, has_nv_control = FALSE; GList *list = NULL; + GtkWidget *window; + list = g_list_append (list, gdk_pixbuf_from_pixdata(&nvidia_icon_pixdata, TRUE, NULL)); gtk_window_set_default_icon_list(list); - ctk_window_new(p, conf, h); + window = ctk_window_new(p, conf, h); + for (i = 0; i < h->targets[X_SCREEN_TARGET].n; i++) { if (h->targets[X_SCREEN_TARGET].t[i].h) { has_nv_control = TRUE; @@ -71,5 +76,7 @@ void ctk_main(ParsedAttribute *p, ConfigProperties *conf, gtk_widget_destroy (dlg); } + ctk_window_set_active_page(CTK_WINDOW(window), page); + gtk_main(); } diff --git a/src/gtk+-2.x/ctkui.h b/src/gtk+-2.x/ctkui.h index 08e3b01..f0a73b1 100644 --- a/src/gtk+-2.x/ctkui.h +++ b/src/gtk+-2.x/ctkui.h @@ -35,7 +35,8 @@ char *ctk_get_display(void); void ctk_main(ParsedAttribute*, ConfigProperties*, - CtrlHandles*); + CtrlHandles*, + const char *page); #endif /* __CTK_UI_H__ */ diff --git a/src/gtk+-2.x/ctkwindow.c b/src/gtk+-2.x/ctkwindow.c index f638326..370392d 100644 --- a/src/gtk+-2.x/ctkwindow.c +++ b/src/gtk+-2.x/ctkwindow.c @@ -33,6 +33,7 @@ #include <gdk/gdkkeysyms.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "ctkwindow.h" @@ -73,6 +74,10 @@ #include "ctkevent.h" #include "ctkconstants.h" +#include "msg.h" +#include "common-utils.h" + + /* column enumeration */ enum { @@ -847,7 +852,7 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, NULL, ctk_ecc_start_timer, ctk_ecc_stop_timer); } /* display devices */ - data = (UpdateDisplaysData *)calloc(1, sizeof(UpdateDisplaysData)); + data = calloc(1, sizeof(UpdateDisplaysData)); data->window = ctk_window; data->event = ctk_event; data->gpu_handle = gpu_handle; @@ -1083,6 +1088,85 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, /* + * Set the currently active page to be the page that matches the + * specified label. + * + * Note that child pages of X screens and GPUs cannot be uniquely + * identified by their label alone (e.g., each GPU has a "PowerMizer" + * page). To allow explicit control over which instance of a child + * page is selected, the label can have the optional format + * + * "[PARENT LABEL], [CHILD LABEL]" + * + * E.g., + * + * "GPU 0 - (GeForce 7600 GT), PowerMizer" + */ + +typedef struct { + CtkWindow *ctk_window; + const gchar *label; +} ctk_window_set_active_page_args; + +static gboolean ctk_window_set_active_page_callback(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + GtkTreeIter parent; + gboolean valid; + gchar *iter_label; + gchar *parent_label = "no parent"; + gchar *qualified_label; + ctk_window_set_active_page_args *args = data; + + /* get the parent's label, if there is a parent */ + + valid = gtk_tree_model_iter_parent(model, &parent, iter); + if (valid) { + gtk_tree_model_get(model, &parent, + CTK_WINDOW_LABEL_COLUMN, &parent_label, -1); + } + + gtk_tree_model_get(model, iter, CTK_WINDOW_LABEL_COLUMN, &iter_label, -1); + + qualified_label = nvstrcat(parent_label, ", ", iter_label, NULL); + + if ((strcmp(iter_label, args->label) == 0) || + (strcmp(qualified_label, args->label) == 0)) { + GtkTreeSelection* selection; + selection = gtk_tree_view_get_selection(args->ctk_window->treeview); + gtk_tree_selection_select_iter(selection, iter); + free(qualified_label); + return TRUE; /* stop walking the tree */ + } + + free(qualified_label); + + return FALSE; /* keep walking the tree */ +} + + +void ctk_window_set_active_page(CtkWindow *ctk_window, const gchar *label) +{ + GtkTreeModel *model = GTK_TREE_MODEL(ctk_window->tree_store); + + ctk_window_set_active_page_args args; + + if (!label) return; + + args.ctk_window = ctk_window; + args.label = label; + + gtk_tree_model_foreach(model, + ctk_window_set_active_page_callback, + &args); + +} /* ctk_window_set_active_page() */ + + + +/* * add_page() - add a new page to ctk_window's tree_store, using iter * as a parent; the new child iter is written in pchild_iter, if * provided. @@ -1229,26 +1313,34 @@ static void quit_response(GtkWidget *button, gint response, gpointer user_data) * saved to the config file. */ +static gboolean add_special_config_file_attributes_callback(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + GtkWidget *widget; + config_file_attributes_func_t func; + CtkWindow *ctk_window = data; + + gtk_tree_model_get(model, iter, + CTK_WINDOW_WIDGET_COLUMN, &widget, + CTK_WINDOW_CONFIG_FILE_ATTRIBUTES_FUNC_COLUMN, + &func, -1); + + if (func) (*func)(widget, ctk_window->attribute_list); + + return FALSE; /* keep iterating over nodes in the tree */ +} + + void add_special_config_file_attributes(CtkWindow *ctk_window) { GtkTreeModel *model = GTK_TREE_MODEL(ctk_window->tree_store); - GtkTreeIter iter; - gboolean valid; - config_file_attributes_func_t func; - GtkWidget *widget; - - valid = gtk_tree_model_get_iter_first(model, &iter); - while (valid) { - - gtk_tree_model_get(model, &iter, - CTK_WINDOW_WIDGET_COLUMN, &widget, - CTK_WINDOW_CONFIG_FILE_ATTRIBUTES_FUNC_COLUMN, - &func, -1); - - if (func) (*func)(widget, ctk_window->attribute_list); - - valid = gtk_tree_model_iter_next(model, &iter); - } + + gtk_tree_model_foreach(model, + add_special_config_file_attributes_callback, + ctk_window); + } /* add_special_config_file_attributes() */ @@ -1292,8 +1384,7 @@ static void add_display_devices(CtkWindow *ctk_window, GtkTreeIter *iter, if (data->display_iters) { free(data->display_iters); } - data->display_iters = - (GtkTreeIter *)calloc(1, n * sizeof(GtkTreeIter)); + data->display_iters = calloc(n, sizeof(GtkTreeIter)); data->num_displays = 0; if (!data->display_iters) return; diff --git a/src/gtk+-2.x/ctkwindow.h b/src/gtk+-2.x/ctkwindow.h index bd04b32..d23995a 100644 --- a/src/gtk+-2.x/ctkwindow.h +++ b/src/gtk+-2.x/ctkwindow.h @@ -93,6 +93,8 @@ struct _CtkWindowClass GType ctk_window_get_type (void) G_GNUC_CONST; GtkWidget* ctk_window_new (ParsedAttribute *, ConfigProperties *conf, CtrlHandles *h); +void ctk_window_set_active_page(CtkWindow *ctk_window, + const gchar *label); void add_special_config_file_attributes(CtkWindow *ctk_window); diff --git a/src/libXNVCtrl/NVCtrl.c b/src/libXNVCtrl/NVCtrl.c index c9276c1..6eacc95 100644 --- a/src/libXNVCtrl/NVCtrl.c +++ b/src/libXNVCtrl/NVCtrl.c @@ -741,6 +741,91 @@ Bool XNVCTRLQueryValidAttributeValues ( } +static Bool QueryAttributePermissionsInternal ( + Display *dpy, + unsigned int attribute, + NVCTRLAttributePermissionsRec *permissions, + unsigned int reqType +){ + XExtDisplayInfo *info = find_display (dpy); + xnvCtrlQueryAttributePermissionsReply rep; + xnvCtrlQueryAttributePermissionsReq *req; + Bool exists; + + if(!XextHasExtension(info)) + return False; + + XNVCTRLCheckExtension (dpy, info, False); + + LockDisplay(dpy); + GetReq(nvCtrlQueryAttributePermissions, req); + req->reqType = info->codes->major_opcode; + req->nvReqType = reqType; + req->attribute = attribute; + if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { + UnlockDisplay (dpy); + SyncHandle(); + return False; + } + exists = rep.flags; + if (exists && permissions) { + permissions->type = rep.attr_type; + permissions->permissions = rep.perms; + } + UnlockDisplay(dpy); + SyncHandle(); + return exists; +} + + +Bool XNVCTRLQueryAttributePermissions ( + Display *dpy, + unsigned int attribute, + NVCTRLAttributePermissionsRec *permissions +){ + return QueryAttributePermissionsInternal(dpy, + attribute, + permissions, + X_nvCtrlQueryAttributePermissions); +} + + +Bool XNVCTRLQueryStringAttributePermissions ( + Display *dpy, + unsigned int attribute, + NVCTRLAttributePermissionsRec *permissions +){ + return QueryAttributePermissionsInternal(dpy, + attribute, + permissions, + X_nvCtrlQueryStringAttributePermissions); +} + + +Bool XNVCTRLQueryBinaryDataAttributePermissions ( + Display *dpy, + unsigned int attribute, + NVCTRLAttributePermissionsRec *permissions +){ + return QueryAttributePermissionsInternal(dpy, + attribute, + permissions, + X_nvCtrlQueryBinaryDataAttributePermissions); +} + + +Bool XNVCTRLQueryStringOperationAttributePermissions ( + Display *dpy, + unsigned int attribute, + NVCTRLAttributePermissionsRec *permissions +){ + return QueryAttributePermissionsInternal(dpy, + attribute, + permissions, + X_nvCtrlQueryStringOperationAttributePermissions); +} + + void XNVCTRLSetGvoColorConversion ( Display *dpy, int screen, diff --git a/src/libXNVCtrl/NVCtrl.h b/src/libXNVCtrl/NVCtrl.h index 2825f45..7210fb9 100644 --- a/src/libXNVCtrl/NVCtrl.h +++ b/src/libXNVCtrl/NVCtrl.h @@ -145,7 +145,7 @@ * ratio correct) * * USAGE NOTE: This attribute has been deprecated in favor of the new - * NV_CTRL_FLATPANEL_GPU_SCALING attribute. + * NV_CTRL_GPU_SCALING attribute. */ #define NV_CTRL_FLATPANEL_SCALING 2 /* RWDG */ @@ -1621,11 +1621,21 @@ /* * NV_CTRL_SHOW_SLI_HUD - when TRUE, OpenGL will draw information about the * current SLI mode. + * Renamed this attribute to NV_CTRL_SHOW_SLI_VISUAL_INDICATOR */ -#define NV_CTRL_SHOW_SLI_HUD 225 /* RW-X */ -#define NV_CTRL_SHOW_SLI_HUD_FALSE 0 -#define NV_CTRL_SHOW_SLI_HUD_TRUE 1 +#define NV_CTRL_SHOW_SLI_HUD NV_CTRL_SHOW_SLI_VISUAL_INDICATOR +#define NV_CTRL_SHOW_SLI_HUD_FALSE NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_FALSE +#define NV_CTRL_SHOW_SLI_HUD_TRUE NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_TRUE + +/* + * NV_CTRL_SHOW_SLI_VISUAL_INDICATOR - when TRUE, OpenGL will draw information + * about the current SLI mode. + */ + +#define NV_CTRL_SHOW_SLI_VISUAL_INDICATOR 225 /* RW-X */ +#define NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_FALSE 0 +#define NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_TRUE 1 /* * NV_CTRL_XV_SYNC_TO_DISPLAY - this control is valid when TwinView and @@ -1878,8 +1888,8 @@ /* - * NV_CTRL_MULTIGPU_DISPLAY_OWNER - Returns the GPU ID of the GPU - * that has the display device(s) used for showing the X Screen. + * NV_CTRL_MULTIGPU_DISPLAY_OWNER - Returns the (NV-CONTROL) GPU ID of + * the GPU that has the display device(s) used for showing the X Screen. */ #define NV_CTRL_MULTIGPU_DISPLAY_OWNER 247 /* R-- */ @@ -2213,7 +2223,7 @@ * * Range # (11 bits), (Enabled 1 bit), min value (10 bits), max value (10 bits) * - * To query the current values, pass the range # throught he display_mask + * To query the current values, pass the range # throught the display_mask * variable. */ @@ -2920,11 +2930,16 @@ * STATIC_2X2: use a 2x2 matrix to dither from the GPU's pixel * pipeline to the bit depth of the flat panel. The matrix values * do not change from frame to frame. + * + * TEMPORAL: use a pseudorandom value from a uniform distribution calculated at + * every pixel to achieve stochastic dithering. This method produces a better + * visual result than 2x2 matrix approaches. */ #define NV_CTRL_DITHERING_MODE 352 /* RWDG */ #define NV_CTRL_DITHERING_MODE_AUTO 0 #define NV_CTRL_DITHERING_MODE_DYNAMIC_2X2 1 #define NV_CTRL_DITHERING_MODE_STATIC_2X2 2 +#define NV_CTRL_DITHERING_MODE_TEMPORAL 3 /* * NV_CTRL_CURRENT_DITHERING - Returns the current dithering state. @@ -2941,6 +2956,7 @@ #define NV_CTRL_CURRENT_DITHERING_MODE_NONE 0 #define NV_CTRL_CURRENT_DITHERING_MODE_DYNAMIC_2X2 1 #define NV_CTRL_CURRENT_DITHERING_MODE_STATIC_2X2 2 +#define NV_CTRL_CURRENT_DITHERING_MODE_TEMPORAL 3 /* * NV_CTRL_THERMAL_SENSOR_READING - Returns the thermal sensor's current @@ -3061,6 +3077,27 @@ #define NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_COUNT 4 /* + * NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES - controls whether updates to the color + * lookup table (LUT) are synchronous with respect to X rendering. For example, + * if an X client sends XStoreColors followed by XFillRectangle, the driver will + * guarantee that the FillRectangle request is not processed until after the + * updated LUT colors are actually visible on the screen if + * NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES is enabled. Otherwise, the rendering may + * occur first. + * + * This makes a difference for applications that use the LUT to animate, such as + * XPilot. If you experience flickering in applications that use LUT + * animations, try enabling this attribute. + * + * When synchronous updates are enabled, XStoreColors requests will be processed + * at your screen's refresh rate. + */ + +#define NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES 367 /* RWDG */ +#define NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES_DISABLE 0 +#define NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES_ENABLE 1 + +/* * 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 @@ -3159,9 +3196,12 @@ */ #define NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL 380 /* R--T */ -/* NV_CTRL_GVO_ANC_PARITY_COMPUTATION - Controls the SDI device's computation + +/* + * NV_CTRL_GVO_ANC_PARITY_COMPUTATION - Controls the SDI device's computation * of the parity bit (bit 8) for ANC data words. */ + #define NV_CTRL_GVO_ANC_PARITY_COMPUTATION 381 /* RW--- */ #define NV_CTRL_GVO_ANC_PARITY_COMPUTATION_AUTO 0 #define NV_CTRL_GVO_ANC_PARITY_COMPUTATION_ON 1 @@ -3776,6 +3816,7 @@ * NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME - Controls the name the * glasses should use. * Use the display_mask parameter to specify the glasses id. + * Glasses' name should start and end with an alpha-numeric character. */ #define NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME 44 /* RW-T */ @@ -4306,6 +4347,18 @@ * value, etc). This is useful for attributes like NV_CTRL_FSAA_MODE, * which can only have certain values, depending on GPU. * + * ATTRIBUTE_TYPE_64BIT_INTEGER : the attribute is a 64 bit integer value; + * there is no fixed range of valid values. + * + * ATTRIBUTE_TYPE_STRING : the attribute is a string value; there is no fixed + * range of valid values. + * + * ATTRIBUTE_TYPE_BINARY_DATA : the attribute is binary data; there is + * no fixed range of valid values. + * + * ATTRIBUTE_TYPE_STRING_OPERATION : the attribute is a string; there is + * no fixed range of valid values. + * * * The permissions field of NVCTRLAttributeValidValuesRec is a bitmask * that may contain: @@ -4330,14 +4383,16 @@ * file for a description of what these permission bits mean. */ -#define ATTRIBUTE_TYPE_UNKNOWN 0 -#define ATTRIBUTE_TYPE_INTEGER 1 -#define ATTRIBUTE_TYPE_BITMASK 2 -#define ATTRIBUTE_TYPE_BOOL 3 -#define ATTRIBUTE_TYPE_RANGE 4 -#define ATTRIBUTE_TYPE_INT_BITS 5 -#define ATTRIBUTE_TYPE_64BIT_INTEGER 6 -#define ATTRIBUTE_TYPE_STRING 7 +#define ATTRIBUTE_TYPE_UNKNOWN 0 +#define ATTRIBUTE_TYPE_INTEGER 1 +#define ATTRIBUTE_TYPE_BITMASK 2 +#define ATTRIBUTE_TYPE_BOOL 3 +#define ATTRIBUTE_TYPE_RANGE 4 +#define ATTRIBUTE_TYPE_INT_BITS 5 +#define ATTRIBUTE_TYPE_64BIT_INTEGER 6 +#define ATTRIBUTE_TYPE_STRING 7 +#define ATTRIBUTE_TYPE_BINARY_DATA 8 +#define ATTRIBUTE_TYPE_STRING_OPERATION 9 #define ATTRIBUTE_TYPE_READ 0x001 #define ATTRIBUTE_TYPE_WRITE 0x002 @@ -4366,6 +4421,11 @@ typedef struct _NVCTRLAttributeValidValues { unsigned int permissions; } NVCTRLAttributeValidValuesRec; +typedef struct _NVCTRLAttributePermissions { + int type; + unsigned int permissions; +} NVCTRLAttributePermissionsRec; + /**************************************************************************/ diff --git a/src/libXNVCtrl/NVCtrlLib.h b/src/libXNVCtrl/NVCtrlLib.h index 6636270..6bad9ba 100644 --- a/src/libXNVCtrl/NVCtrlLib.h +++ b/src/libXNVCtrl/NVCtrlLib.h @@ -417,6 +417,66 @@ Bool XNVCTRLQueryValidTargetAttributeValues ( /* + * XNVCTRLQueryAttributePermissions - + * + * Returns True if the attribute exists. Returns False otherwise. If + * XNVCTRLQueryAttributePermissions returns True, permissions will + * indicate the permission flags for the attribute. + */ + +Bool XNVCTRLQueryAttributePermissions ( + Display *dpy, + unsigned int attribute, + NVCTRLAttributePermissionsRec *permissions +); + + +/* + * XNVCTRLQueryStringAttributePermissions - + * + * Returns True if the attribute exists. Returns False otherwise. If + * XNVCTRLQueryStringAttributePermissions returns True, permissions will + * indicate the permission flags for the attribute. + */ + + Bool XNVCTRLQueryStringAttributePermissions ( + Display *dpy, + unsigned int attribute, + NVCTRLAttributePermissionsRec *permissions +); + + +/* + * XNVCTRLQueryBinaryDataAttributePermissions - + * + * Returns True if the attribute exists. Returns False otherwise. If + * XNVCTRLQueryBinaryDataAttributePermissions returns True, permissions + * will indicate the permission flags for the attribute. + */ + + Bool XNVCTRLQueryBinaryDataAttributePermissions ( + Display *dpy, + unsigned int attribute, + NVCTRLAttributePermissionsRec *permissions +); + + +/* + * XNVCTRLQueryStringOperationAttributePermissions - + * + * Returns True if the attribute exists. Returns False otherwise. If + * XNVCTRLQueryStringOperationAttributePermissions returns True, + * permissions will indicate the permission flags for the attribute. + */ + + Bool XNVCTRLQueryStringOperationAttributePermissions ( + Display *dpy, + unsigned int attribute, + NVCTRLAttributePermissionsRec *permissions +); + + +/* * XNVCTRLSetGvoColorConversion - * * Sets the color conversion matrix, offset, and scale that should be diff --git a/src/libXNVCtrl/nv_control.h b/src/libXNVCtrl/nv_control.h index 6d10389..d944b3c 100644 --- a/src/libXNVCtrl/nv_control.h +++ b/src/libXNVCtrl/nv_control.h @@ -51,6 +51,7 @@ * 1.24 Fixed a bug where SLI_MOSAIC_MODE_AVAILABLE attribute would * report false positives via the GPU and X screen target types * 1.25 Added 3D_VISION_PRO_TRANSCEIVER TargetType + * 1.26 Added XNVCTRLQueryXXXAttributePermissions. */ #ifndef __NVCONTROL_H @@ -61,7 +62,7 @@ #define NV_CONTROL_NAME "NV-CONTROL" #define NV_CONTROL_MAJOR 1 -#define NV_CONTROL_MINOR 25 +#define NV_CONTROL_MINOR 26 #define X_nvCtrlQueryExtension 0 #define X_nvCtrlIsNv 1 @@ -92,7 +93,12 @@ #define X_nvCtrlQueryValidAttributeValues64 26 #define X_nvCtrlQueryAttribute64 27 #define X_nvCtrlQueryValidStringAttributeValues 28 -#define X_nvCtrlLastRequest (X_nvCtrlQueryValidStringAttributeValues + 1) +#define X_nvCtrlQueryAttributePermissions 29 +#define X_nvCtrlQueryStringAttributePermissions 30 +#define X_nvCtrlQueryBinaryDataAttributePermissions 31 +#define X_nvCtrlQueryStringOperationAttributePermissions 32 + +#define X_nvCtrlLastRequest (X_nvCtrlQueryStringOperationAttributePermissions + 1) /* Define 32 bit floats */ @@ -337,6 +343,29 @@ typedef struct { #define sz_xnvCtrlQueryValidAttributeValues64Reply 48 #define sz_xnvCtrlQueryValidAttributeValues64Reply_extra ((48 - 32) >> 2) +typedef struct { + CARD8 reqType; + CARD8 nvReqType; + CARD16 length B16; + CARD32 attribute B32; +} xnvCtrlQueryAttributePermissionsReq; +#define sz_xnvCtrlQueryAttributePermissionsReq 8 + +typedef struct { + BYTE type; + BYTE pad0; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 flags B32; + INT32 attr_type B32; + CARD32 perms B32; + CARD32 pad5 B32; + CARD32 pad6 B32; + CARD32 pad7 B32; + CARD32 pad8 B32; +} xnvCtrlQueryAttributePermissionsReply; +#define sz_xnvCtrlQueryAttributePermissionsReply 32 + /* Set GVO Color Conversion request (deprecated) */ typedef struct { CARD8 reqType; diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c b/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c index 0f38ba7..13514b5 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesGlx.c @@ -135,7 +135,7 @@ static Bool open_libgl(void) /* Initialize bookkeeping structure */ if ( !__libGL ) { - __libGL = (__libGLInfo *) calloc(1, sizeof(__libGLInfo)); + __libGL = calloc(1, sizeof(__libGLInfo)); if ( !__libGL ) { error_str = "Could not allocate memory."; goto fail; diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c b/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c index ccbb9ba..b800cbf 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c @@ -73,8 +73,7 @@ NvCtrlInitNvControlAttributes (NvCtrlAttributePrivateHandle *h) } } - nv = (NvCtrlNvControlAttributes *) - calloc(1, sizeof (NvCtrlNvControlAttributes)); + nv = calloc(1, sizeof(NvCtrlNvControlAttributes)); ret = XNVCtrlSelectTargetNotify(h->dpy, h->target_type, h->target_id, TARGET_ATTRIBUTE_CHANGED_EVENT, True); diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesVidMode.c b/src/libXNVCtrlAttributes/NvCtrlAttributesVidMode.c index c445a6a..1e6be08 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesVidMode.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesVidMode.c @@ -87,7 +87,7 @@ NvCtrlInitVidModeAttributes(NvCtrlAttributePrivateHandle *h) ret = XF86VidModeQueryExtension(h->dpy, &event, &vidModeErrorBase); if (ret != True) goto failed; - vm = (NvCtrlVidModeAttributes *) malloc(sizeof(NvCtrlVidModeAttributes)); + vm = malloc(sizeof(NvCtrlVidModeAttributes)); ret = XF86VidModeQueryVersion(h->dpy, &(vm->major_version), &(vm->minor_version)); if (ret != True) goto failed; @@ -120,9 +120,9 @@ NvCtrlInitVidModeAttributes(NvCtrlAttributePrivateHandle *h) if (ret != True) goto failed; - vm->lut[RED] = (unsigned short *) malloc(sizeof(unsigned short) * vm->n); - vm->lut[GREEN] = (unsigned short *) malloc(sizeof(unsigned short) * vm->n); - vm->lut[BLUE] = (unsigned short *) malloc(sizeof(unsigned short) * vm->n); + vm->lut[RED] = malloc(sizeof(unsigned short) * vm->n); + vm->lut[GREEN] = malloc(sizeof(unsigned short) * vm->n); + vm->lut[BLUE] = malloc(sizeof(unsigned short) * vm->n); ret = XF86VidModeGetGammaRamp(h->dpy, h->target_id, vm->n, vm->lut[RED], vm->lut[GREEN], vm->lut[BLUE]); diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c b/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c index 164d77b..26766dd 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesXrandr.c @@ -115,7 +115,7 @@ static Bool open_libxrandr(void) /* Initialize bookkeeping structure */ if ( !__libXrandr ) { - __libXrandr = (__libXrandrInfo *) calloc(1, sizeof(__libXrandrInfo)); + __libXrandr = calloc(1, sizeof(__libXrandrInfo)); if ( !__libXrandr ) { error_str = "Could not allocate memory."; goto fail; @@ -288,7 +288,7 @@ NvCtrlInitXrandrAttributes (NvCtrlAttributePrivateHandle *h) /* Create storage for XRandR attributes */ xrandr = - (NvCtrlXrandrAttributes *) calloc(1, sizeof(NvCtrlXrandrAttributes)); + calloc(1, sizeof(NvCtrlXrandrAttributes)); if ( !xrandr ) { goto fail; } diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesXv.c b/src/libXNVCtrlAttributes/NvCtrlAttributesXv.c index 55c5aa1..70bb59c 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesXv.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesXv.c @@ -77,7 +77,7 @@ static Bool open_libxv(void) /* Initialize bookkeeping structure */ if ( !__libXv ) { - __libXv = (__libXvInfo *) calloc(1, sizeof(__libXvInfo)); + __libXv = calloc(1, sizeof(__libXvInfo)); if ( !__libXv ) { error_str = "Could not allocate memory."; goto fail; @@ -201,8 +201,7 @@ NvCtrlXvAttributes * NvCtrlInitXvAttributes(NvCtrlAttributePrivateHandle *h) /* Allocate the attributes structure */ - xv = (NvCtrlXvAttributes *) - calloc(1, sizeof (NvCtrlXvAttributes)); + xv = calloc(1, sizeof(NvCtrlXvAttributes)); if ( xv == NULL ) { error_str = "Out of memory."; goto fail; @@ -230,8 +229,7 @@ NvCtrlXvAttributes * NvCtrlInitXvAttributes(NvCtrlAttributePrivateHandle *h) NvCtrlXvOverlayAttributes *attrs; - attrs = (NvCtrlXvOverlayAttributes *) - malloc(sizeof(NvCtrlXvOverlayAttributes)); + attrs = malloc(sizeof(NvCtrlXvOverlayAttributes)); if ( !attrs ) { error_str = "Out of memory."; goto fail; @@ -273,8 +271,7 @@ NvCtrlXvAttributes * NvCtrlInitXvAttributes(NvCtrlAttributePrivateHandle *h) NvCtrlXvTextureAttributes *attrs; - attrs = (NvCtrlXvTextureAttributes *) - malloc(sizeof(NvCtrlXvTextureAttributes)); + attrs = malloc(sizeof(NvCtrlXvTextureAttributes)); if ( !attrs ) { error_str = "Out of memory."; goto fail; @@ -311,8 +308,7 @@ NvCtrlXvAttributes * NvCtrlInitXvAttributes(NvCtrlAttributePrivateHandle *h) NvCtrlXvBlitterAttributes *attrs; - attrs = (NvCtrlXvBlitterAttributes *) - malloc(sizeof(NvCtrlXvBlitterAttributes)); + attrs = malloc(sizeof(NvCtrlXvBlitterAttributes)); if ( !attrs ) { error_str = "Out of memory."; goto fail; @@ -516,7 +512,7 @@ static NvCtrlXvAttribute *getXvAttribute(NvCtrlAttributePrivateHandle *h, for (i = 0; i < n; i++) { if (strcmp(attributes[i].name, name) != 0) continue; - attr = (NvCtrlXvAttribute *) malloc(sizeof (NvCtrlXvAttribute)); + attr = malloc(sizeof(NvCtrlXvAttribute)); attr->range.type = ATTRIBUTE_TYPE_RANGE; attr->range.u.range.min = attributes[i].min_value; attr->range.u.range.max = attributes[i].max_value; @@ -264,3 +264,4 @@ static int get_terminal_width(void) return (ws.ws_col - 1); } } + @@ -34,6 +34,7 @@ void nv_info_msg(const char*, const char*, ...); void nv_msg(const char*, const char*, ...); void nv_msg_preserve_whitespace(const char*, const char*, ...); + /* * NV_VSNPRINTF(): macro that assigns buf using vsnprintf(). This is * correct for differing semantics of vsnprintf() in different diff --git a/src/nvidia-settings.c b/src/nvidia-settings.c index c35d7ab..b43f79f 100644 --- a/src/nvidia-settings.c +++ b/src/nvidia-settings.c @@ -143,7 +143,7 @@ int main(int argc, char **argv) /* pass control to the gui */ - ctk_main(p, &conf, h); + ctk_main(p, &conf, h, op->page); /* write the configuration file */ diff --git a/src/option-table.h b/src/option-table.h index c28f44c..3c21261 100644 --- a/src/option-table.h +++ b/src/option-table.h @@ -32,7 +32,9 @@ #define BIGTAB " " /* - * Options table; see nvgetopt.h for a description of the fields. + * Options table; see nvgetopt.h for a description of the fields, and + * gen-manpage-opts.c:print_option() for a description of special + * characters that are converted during manpage generation. */ static const NVGetoptOption __options[] = { @@ -150,6 +152,25 @@ static const NVGetoptOption __options[] = { "list the descriptions of all attributes. Specify 'list' to list the " "attribute names without a descriptions." }, + { "page", 'p', NVGETOPT_STRING_ARGUMENT, NULL, + "The ^PAGE> argument to the <'--page'> commandline option selects a " + "particular page in the nvidia-settings user interface to display " + "upon starting nvidia-settings. Valid values are the page names " + "in the tree view on the left side of the nvidia-settings user " + "interface; e.g.,\n" + "\n" + TAB "--page=\"X Screen 0\"\n" + "\n" + "Because some page names are not unique (e.g., a \"PowerMizer\" page is " + "present under each GPU), the page name can optionally be prepended " + "with the name of the parent X Screen or GPU page, followed by a comma. " + "E.g.,\n" + "\n" + TAB "--page=\"GPU 0 - (Quadro 6000), PowerMizer\"\n" + "\n" + "The first page with a name matching the ^PAGE> argument will be used. " + "By default, the \"X Server Information\" page is displayed." }, + { NULL, 0, 0, NULL, NULL}, }; diff --git a/src/parse.c b/src/parse.c index 10a120b..a8fc02e 100644 --- a/src/parse.c +++ b/src/parse.c @@ -65,6 +65,7 @@ static char *nv_strndup(char *s, int n); #define I NV_PARSER_TYPE_SDI #define W NV_PARSER_TYPE_VALUE_IS_SWITCH_DISPLAY #define M NV_PARSER_TYPE_SDI_CSC +#define T NV_PARSER_TYPE_HIJACK_DISPLAY_DEVICE AttributeTableEntry attributeTable[] = { @@ -128,6 +129,8 @@ AttributeTableEntry attributeTable[] = { { "OpenGLImageSettings", NV_CTRL_IMAGE_SETTINGS, 0, "The image quality setting for OpenGL clients. This setting only takes effect on OpenGL clients started after it is set." }, { "XineramaStereoFlipping", NV_CTRL_XINERAMA_STEREO, 0, "When 1, OpenGL will allow stereo flipping on multiple X screens configured with Xinerama. When 0, flipping is allowed only on one X screen at a time." }, { "ShowSLIHUD", NV_CTRL_SHOW_SLI_HUD, 0, "If this is enabled (1), the driver will draw information about the current SLI mode into a \"heads-up display\" inside OpenGL windows accelerated with SLI. This setting only takes effect on OpenGL clients started after it is set." }, + { "ShowSLIVisualIndicator", NV_CTRL_SHOW_SLI_VISUAL_INDICATOR, 0, "If this is enabled (1), the driver will draw information about the current SLI mode into a \"visual indicator\" inside OpenGL windows accelerated with SLI. This setting only takes effect on OpenGL clients started after it is set." }, + { "ShowMultiGpuVisualIndicator", NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR, 0, "If this is enabled (1), the driver will draw information about the current MultiGPU mode into a \"visual indicator\" inside OpenGL windows accelerated with SLI. This setting only takes effect on OpenGL clients started after it is set." }, { "FSAAAppEnhanced", NV_CTRL_FSAA_APPLICATION_ENHANCED, 0, "Controls how the FSAA attribute is applied when FSAAAppControlled is disabled. When FSAAAppEnhanced is disabled, OpenGL applications will be forced to use the FSAA mode specified by the FSAA attribute. When the FSAAAppEnhanced attribute is enabled, only those applications that have selected a multisample FBConfig will be made to use the FSAA mode specified." }, { "GammaCorrectedAALinesValue", NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE, 0, "Returns the gamma value used by OpenGL when gamma-corrected antialiased lines are enabled." }, { "StereoEyesExchange", NV_CTRL_STEREO_EYES_EXCHANGE, 0, "Swaps the left and right eyes of stereo images." }, @@ -276,8 +279,8 @@ AttributeTableEntry attributeTable[] = { { "BlueGamma", GAMMA_VALUE|BLUE_CHANNEL, C|G, "Controls the gamma of the color blue in the display." }, { "Dithering", NV_CTRL_DITHERING, 0, "Controls the dithering: auto (0), enabled (1), disabled (2)." }, { "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)." }, + { "DitheringMode", NV_CTRL_DITHERING_MODE, 0, "Controls the dithering mode when CurrentDithering=1; auto (0), temporally repeating dithering pattern (1), static dithering pattern (2), temporally stochastic dithering (3)." }, + { "CurrentDitheringMode", NV_CTRL_CURRENT_DITHERING_MODE, 0, "Returns the current dithering mode: none (0), temporally repeating dithering pattern (1), static dithering pattern (2), temporally stochastic dithering (3)." }, { "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." }, @@ -297,6 +300,7 @@ AttributeTableEntry attributeTable[] = { { "OverscanCompensation", NV_CTRL_OVERSCAN_COMPENSATION, 0, "Adjust the amount of overscan compensation scaling, in pixels, to apply to the specified display device." }, { "ColorSpace", NV_CTRL_COLOR_SPACE, 0, "Sets the color space of the signal sent to the display device." }, { "ColorRange", NV_CTRL_COLOR_RANGE, 0, "Sets the color range of the signal sent to the display device." }, + { "SynchronousPaletteUpdates", NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES, 0, "Controls whether colormap updates are synchronized with X rendering." }, /* TV */ { "TVOverScan", NV_CTRL_TV_OVERSCAN, 0, "Adjusts the amount of overscan on the specified display device." }, @@ -321,29 +325,29 @@ AttributeTableEntry attributeTable[] = { { "XVideoSyncToDisplay", NV_CTRL_XV_SYNC_TO_DISPLAY, D|Z, "Controls which display device is synced to by the texture and blitter adaptors when they are set to synchronize to the vertical blanking." }, /* 3D Vision Pro */ - {"3DVisionProResetTransceiverToFactorySettings", NV_CTRL_3D_VISION_PRO_RESET_TRANSCEIVER_TO_FACTORY_SETTINGS, N, "Resets the 3D Vision Pro transceiver to its factory settings."}, - {"3DVisionProTransceiverChannel", NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL, N, "Controls the channel that is currently used by the 3D Vision Pro transceiver."}, - {"3DVisionProTransceiverMode", NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE, N, "Controls the mode in which the 3D Vision Pro transceiver operates."}, - {"3DVisionProTransceiverChannelFrequency", NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_FREQUENCY, N, "Returns the frequency of the channel(in kHz) of the 3D Vision Pro transceiver."}, - {"3DVisionProTransceiverChannelQuality", NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY, N, "Returns the quality of the channel(in percentage) of the 3D Vision Pro transceiver."}, - {"3DVisionProTransceiverChannelCount", NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_COUNT, N, "Returns the number of channels on the 3D Vision Pro transceiver."}, - {"3DVisionProPairGlasses", NV_CTRL_3D_VISION_PRO_PAIR_GLASSES, N, "Puts the 3D Vision Pro transceiver into pairing mode to gather additional glasses."}, - {"3DVisionProUnpairGlasses", NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES, N, "Tells a specific pair of glasses to unpair."}, - {"3DVisionProDiscoverGlasses", NV_CTRL_3D_VISION_PRO_DISCOVER_GLASSES, N, "Tells the 3D Vision Pro transceiver about the glasses that have been paired using NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_BEACON."}, - {"3DVisionProIdentifyGlasses", NV_CTRL_3D_VISION_PRO_IDENTIFY_GLASSES, N, "Causes glasses LEDs to flash for a short period of time."}, - {"3DVisionProGlassesSyncCycle", NV_CTRL_3D_VISION_PRO_GLASSES_SYNC_CYCLE, N, "Controls the sync cycle duration(in milliseconds) of the glasses."}, - {"3DVisionProGlassesMissedSyncCycles", NV_CTRL_3D_VISION_PRO_GLASSES_MISSED_SYNC_CYCLES, N, "Returns the number of state sync cycles recently missed by the glasses."}, - {"3DVisionProGlassesBatteryLevel", NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL, N, "Returns the battery level(in percentage) of the glasses."}, - {"3DVisionProTransceiverHardwareRevision", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_HARDWARE_REVISION, S|N, "Returns the hardware revision of the 3D Vision Pro transceiver."}, - {"3DVisionProTransceiverFirmwareVersionA", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_A, S|N, "Returns the firmware version of chip A of the 3D Vision Pro transceiver."}, - {"3DVisionProTransceiverFirmwareDateA", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_A, S|N, "Returns the date of the firmware of chip A of the 3D Vision Pro transceiver."}, - {"3DVisionProTransceiverFirmwareVersionB", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_B, S|N, "Returns the firmware version of chip B of the 3D Vision Pro transceiver."}, - {"3DVisionProTransceiverFirmwareDateB", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_B, S|N, "Returns the date of the firmware of chip B of the 3D Vision Pro transceiver."}, - {"3DVisionProTransceiverAddress", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_ADDRESS, S|N, "Returns the RF address of the 3D Vision Pro transceiver."}, - {"3DVisionProGlassesFirmwareVersionA", NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_VERSION_A, S|N, "Returns the firmware version of chip A of the glasses."}, - {"3DVisionProGlassesFirmwareDateA", NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_DATE_A, S|N, "Returns the date of the firmware of chip A of the glasses."}, - {"3DVisionProGlassesAddress", NV_CTRL_STRING_3D_VISION_PRO_GLASSES_ADDRESS, S|N, "Returns the RF address of the glasses."}, - {"3DVisionProGlassesName", NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME, S|N, "Controls the name the glasses should use."}, + {"3DVisionProResetTransceiverToFactorySettings", NV_CTRL_3D_VISION_PRO_RESET_TRANSCEIVER_TO_FACTORY_SETTINGS, N, "Resets the 3D Vision Pro transceiver to its factory settings."}, + {"3DVisionProTransceiverChannel", NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL, N, "Controls the channel that is currently used by the 3D Vision Pro transceiver."}, + {"3DVisionProTransceiverMode", NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE, N, "Controls the mode in which the 3D Vision Pro transceiver operates."}, + {"3DVisionProTransceiverChannelFrequency", NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_FREQUENCY, N|T, "Returns the frequency of the channel(in kHz) of the 3D Vision Pro transceiver."}, + {"3DVisionProTransceiverChannelQuality", NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY, N|T, "Returns the quality of the channel(in percentage) of the 3D Vision Pro transceiver."}, + {"3DVisionProTransceiverChannelCount", NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_COUNT, N, "Returns the number of channels on the 3D Vision Pro transceiver."}, + {"3DVisionProPairGlasses", NV_CTRL_3D_VISION_PRO_PAIR_GLASSES, N, "Puts the 3D Vision Pro transceiver into pairing mode to gather additional glasses."}, + {"3DVisionProUnpairGlasses", NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES, N, "Tells a specific pair of glasses to unpair."}, + {"3DVisionProDiscoverGlasses", NV_CTRL_3D_VISION_PRO_DISCOVER_GLASSES, N, "Tells the 3D Vision Pro transceiver about the glasses that have been paired using NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_BEACON."}, + {"3DVisionProIdentifyGlasses", NV_CTRL_3D_VISION_PRO_IDENTIFY_GLASSES, N, "Causes glasses LEDs to flash for a short period of time."}, + {"3DVisionProGlassesSyncCycle", NV_CTRL_3D_VISION_PRO_GLASSES_SYNC_CYCLE, N|T, "Controls the sync cycle duration(in milliseconds) of the glasses."}, + {"3DVisionProGlassesMissedSyncCycles", NV_CTRL_3D_VISION_PRO_GLASSES_MISSED_SYNC_CYCLES, N|T, "Returns the number of state sync cycles recently missed by the glasses."}, + {"3DVisionProGlassesBatteryLevel", NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL, N|T, "Returns the battery level(in percentage) of the glasses."}, + {"3DVisionProTransceiverHardwareRevision", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_HARDWARE_REVISION, S|N, "Returns the hardware revision of the 3D Vision Pro transceiver."}, + {"3DVisionProTransceiverFirmwareVersionA", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_A, S|N, "Returns the firmware version of chip A of the 3D Vision Pro transceiver."}, + {"3DVisionProTransceiverFirmwareDateA", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_A, S|N, "Returns the date of the firmware of chip A of the 3D Vision Pro transceiver."}, + {"3DVisionProTransceiverFirmwareVersionB", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_B, S|N, "Returns the firmware version of chip B of the 3D Vision Pro transceiver."}, + {"3DVisionProTransceiverFirmwareDateB", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_B, S|N, "Returns the date of the firmware of chip B of the 3D Vision Pro transceiver."}, + {"3DVisionProTransceiverAddress", NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_ADDRESS, S|N, "Returns the RF address of the 3D Vision Pro transceiver."}, + {"3DVisionProGlassesFirmwareVersionA", NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_VERSION_A, S|N|T, "Returns the firmware version of chip A of the glasses."}, + {"3DVisionProGlassesFirmwareDateA", NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_DATE_A, S|N|T, "Returns the date of the firmware of chip A of the glasses."}, + {"3DVisionProGlassesAddress", NV_CTRL_STRING_3D_VISION_PRO_GLASSES_ADDRESS, S|N|T, "Returns the RF address of the glasses."}, + {"3DVisionProGlassesName", NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME, S|N|T, "Controls the name the glasses should use."}, { NULL, 0, 0, NULL } }; @@ -579,8 +583,16 @@ int nv_parse_attribute_string(const char *str, int query, ParsedAttribute *a) display_device_name = nv_strndup(start, s - start); a->display_device_mask = display_device_name_to_display_device_mask(display_device_name); - if (a->display_device_mask == INVALID_DISPLAY_DEVICE_MASK) + /* + * stop parsing if the display device mask is invalid (and the + * display device mask is not hijacked for something other than + * display) + */ + + if ((a->display_device_mask == INVALID_DISPLAY_DEVICE_MASK) && + !(a->flags & NV_PARSER_TYPE_HIJACK_DISPLAY_DEVICE)) stop(NV_PARSER_STATUS_BAD_DISPLAY_DEVICE); + a->flags |= NV_PARSER_HAS_DISPLAY_DEVICE; if (*s == ']') s++; } @@ -932,8 +944,9 @@ int nv_strcasecmp(const char *a, const char *b) uint32 display_device_name_to_display_device_mask(const char *str) { uint32 mask = 0; - char *s, **toks; + char *s, **toks, *endptr; int i, n; + unsigned long int num; /* sanity check */ @@ -944,6 +957,17 @@ uint32 display_device_name_to_display_device_mask(const char *str) s = remove_spaces(str); if (!s || !*s) return INVALID_DISPLAY_DEVICE_MASK; + /* + * can the string be interpreted as a number? if so, use the number + * as the mask + */ + + num = strtoul(s, &endptr, 0); + if (*endptr == '\0') { + free(s); + return (uint32) num; + } + /* break up the string by commas */ toks = nv_strtok(s, ',', &n); @@ -1373,7 +1397,7 @@ char *remove_spaces(const char *o) len = strlen (o); - no_spaces = (char *) malloc (len+1); + no_spaces = malloc(len + 1); m = no_spaces; while (*o) { @@ -1383,8 +1407,8 @@ char *remove_spaces(const char *o) *m = '\0'; len = m - no_spaces + 1; - no_spaces = (char *) (realloc (no_spaces, len)); - + no_spaces = realloc (no_spaces, len); + return (no_spaces); } /* remove_spaces() */ @@ -1450,7 +1474,7 @@ static char **nv_strtok(char *s, char c, int *n) * dividing character, and the terminating NULL of the string) */ - delims = (char **) malloc((count+1) * sizeof(char *)); + delims = malloc((count + 1) * sizeof(char *)); m = s; for (i = 0; i < count; i++) { while (*m != c) m++; @@ -1464,7 +1488,7 @@ static char **nv_strtok(char *s, char c, int *n) * the divisions (the tokens) into the dynamic array of strings */ - tokens = (char **) malloc((count+1) * sizeof(char *)); + tokens = malloc((count + 1) * sizeof(char *)); len = delims[0] - s; tokens[0] = nv_strndup(s, len); @@ -1556,7 +1580,7 @@ int count_number_of_bits(unsigned int mask) static char *nv_strndup(char *s, int n) { - char *m = (char *) malloc(n+1); + char *m = malloc(n + 1); strncpy (m, s, n); m[n] = '\0'; return (m); @@ -1690,7 +1714,7 @@ const char *parse_read_name(const char *str, char **name, char term) while (*str && !name_terminated(*str, term)) str++; - *name = (char *)calloc(1, str -tmp +1); + *name = calloc(1, str - tmp + 1); if (!(*name)) { return NULL; } diff --git a/src/parse.h b/src/parse.h index 47d8506..9ba725e 100644 --- a/src/parse.h +++ b/src/parse.h @@ -43,6 +43,7 @@ * Flag values used in the flags field of the AttributeTableEntry struct. */ +#define NV_PARSER_TYPE_HIJACK_DISPLAY_DEVICE (1<<15) #define NV_PARSER_TYPE_FRAMELOCK (1<<16) #define NV_PARSER_TYPE_COLOR_ATTRIBUTE (1<<17) #define NV_PARSER_TYPE_NO_CONFIG_WRITE (1<<18) diff --git a/src/query-assign.c b/src/query-assign.c index 5a606df..0d3e11b 100644 --- a/src/query-assign.c +++ b/src/query-assign.c @@ -1780,7 +1780,10 @@ int nv_process_parsed_attribute(ParsedAttribute *a, CtrlHandles *h, if (!t->h) continue; /* no handle on this target; silently skip */ - if (a->flags & NV_PARSER_HAS_DISPLAY_DEVICE) { + /* validate any specified display device mask */ + + if ((a->flags & NV_PARSER_HAS_DISPLAY_DEVICE) && + !(a->flags & NV_PARSER_TYPE_HIJACK_DISPLAY_DEVICE)) { /* Expand any wildcards in the display device mask */ @@ -2121,6 +2124,17 @@ int nv_process_parsed_attribute(ParsedAttribute *a, CtrlHandles *h, continue; } + /* + * special case the display device mask in the case that it + * was "hijacked" for something other than a display device: + * assign mask here so that it will be passed through to + * process_parsed_attribute_internal() unfiltered + */ + + if (a->flags & NV_PARSER_TYPE_HIJACK_DISPLAY_DEVICE) { + mask = a->display_device_mask; + } + if (a->flags & NV_PARSER_TYPE_STRING_ATTRIBUTE) { status = NvCtrlGetValidStringDisplayAttributeValues(t->h, mask, a->attr, &valid); } else { @@ -97,6 +97,12 @@ ifndef TARGET_ARCH TARGET_ARCH := $(subst i686,x86,$(TARGET_ARCH)) endif +ifeq ($(TARGET_OS),Linux) + LIBDL_LDFLAGS = -ldl +else + LIBDL_LDFLAGS = +endif + OUTPUTDIR ?= _out/$(TARGET_OS)_$(TARGET_ARCH) NV_QUIET_COMMAND_REMOVED_TARGET_PREFIX ?= @@ -1 +1 @@ -NVIDIA_VERSION = 260.19.36 +NVIDIA_VERSION = 270.18 |