diff -Nru nvidia-settings-470.57.01/debian/changelog nvidia-settings-510.47.03/debian/changelog --- nvidia-settings-470.57.01/debian/changelog 2022-02-03 15:28:33.000000000 +0000 +++ nvidia-settings-510.47.03/debian/changelog 2022-02-14 15:51:41.000000000 +0000 @@ -1,3 +1,17 @@ +nvidia-settings (510.47.03-0ubuntu1) jammy; urgency=medium + + * New upstream release (LP: #1960766). + * debian/rules.defs: + - Remove final / from the URL + * debian/patches/series: + - Drop 07_remove_features_for_legacy.patch. + * debian/patches/08_add_prime_support.patch: + - Rebase on 510 + * debian/patches/17_do_not_read_config_on_power_saving_mode.patch: + - Refresh patch. + + -- Alberto Milone Mon, 14 Feb 2022 16:51:41 +0100 + nvidia-settings (470.57.01-0ubuntu4) jammy; urgency=medium [ Jeremy Szu ] diff -Nru nvidia-settings-470.57.01/debian/patches/08_add_prime_support.patch nvidia-settings-510.47.03/debian/patches/08_add_prime_support.patch --- nvidia-settings-470.57.01/debian/patches/08_add_prime_support.patch 2021-05-05 13:48:18.000000000 +0000 +++ nvidia-settings-510.47.03/debian/patches/08_add_prime_support.patch 2022-02-14 15:48:01.000000000 +0000 @@ -755,62 +755,220 @@ #include "ctkopengl.h" #include "ctkglx.h" #include "ctkmultisample.h" -@@ -704,7 +705,8 @@ GtkWidget *ctk_window_new(ParsedAttribut - driver_major = driver_minor = 0; +@@ -165,7 +166,7 @@ GType ctk_window_get_type(void) + } - /* X Server info & configuration */ -- -+ /* Skip if nvidia is not loaded */ -+ if (system) { - if (system->targets[X_SCREEN_TARGET]) { + return ctk_window_type; +- ++ + } /* ctk_window_get_type() */ - GtkWidget *child; -@@ -1011,13 +1013,6 @@ GtkWidget *ctk_window_new(ParsedAttribut - ctk_3d_vision_pro_select, ctk_3d_vision_pro_unselect); - } -- -- /* We show this section in two cases: -- * 1) when the driver is not in use (hybrid graphics) -- * 2) when the driver release >= 319 -- */ -- if (driver_major == 0 || driver_major >= 319) { -- - /* app profile configuration */ - widget = ctk_app_profile_new(server_target, ctk_config); - if (widget) { -@@ -1039,8 +1034,6 @@ GtkWidget *ctk_window_new(ParsedAttribut - } - } +@@ -429,12 +430,12 @@ static void tree_selection_changed(GtkTr + + ctk_window->iter = iter; + ctk_window->widget = widget; +- ++ + } /* tree_selection_changed() */ + + + +-/* ++/* + * row_activated_event() - callback for row-activated event + * - handles key presses automatically + * - allows the mouse to collapse/expand the menu even when the +@@ -447,7 +448,7 @@ static void row_activated_event(GtkTreeV + gpointer user_data) + { + CtkWindow *ctk_window = CTK_WINDOW(user_data); +- ++ + if (gtk_tree_view_row_expanded(ctk_window->treeview, path)) { + gtk_tree_view_collapse_row(ctk_window->treeview, path); + } else { +@@ -517,12 +518,12 @@ GtkWidget *ctk_window_new(ParsedAttribut + gtk_container_set_border_width(GTK_CONTAINER(ctk_window), CTK_WINDOW_PAD); + + ctk_window->attribute_list = p; +- ++ + /* create the config object */ + + ctk_window->ctk_config = CTK_CONFIG(ctk_config_new(conf, system)); + ctk_config = ctk_window->ctk_config; +- ++ + /* create the quit dialog */ -- } -- - /* nvidia-settings configuration */ + ctk_window->quit_dialog = create_quit_dialog(ctk_window); +@@ -534,21 +535,21 @@ GtkWidget *ctk_window_new(ParsedAttribut + vbox = gtk_vbox_new(FALSE, 5); + gtk_container_add(GTK_CONTAINER(ctk_window), vbox); + gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); +- ++ + /* place the status bar */ +- ++ + statusbar = ctk_config_get_statusbar(ctk_config); + eventbox = gtk_event_box_new(); + gtk_container_add(GTK_CONTAINER(eventbox), statusbar); +- ++ + gtk_box_pack_start(GTK_BOX(hbox), eventbox, TRUE, TRUE, 0); +- ++ + ctk_config_set_tooltip(ctk_config, eventbox, "The status bar displays " + "the most recent change that has been sent to the " + "X server."); +- ++ + /* create and place the help toggle button */ +- ++ + toggle_button = gtk_toggle_button_new(); - add_page(GTK_WIDGET(ctk_window->ctk_config), -@@ -1048,6 +1041,22 @@ GtkWidget *ctk_window_new(ParsedAttribut + g_object_set(G_OBJECT(toggle_button), +@@ -566,7 +567,7 @@ GtkWidget *ctk_window_new(ParsedAttribut + ctk_window->ctk_help = NULL; + tag_table = ctk_help_create_tag_table(); + ctk_window->help_tag_table = tag_table; +- ++ + ctk_config_set_tooltip(ctk_config, toggle_button, "The Help button " + "toggles the display of a help window which " + "provides a detailed explanation of the available " +@@ -580,14 +581,14 @@ GtkWidget *ctk_window_new(ParsedAttribut + g_signal_connect(G_OBJECT(button), "clicked", + G_CALLBACK(close_button_clicked), + (gpointer) ctk_window); +- ++ + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); +- ++ + ctk_config_set_tooltip(ctk_config, button, "The Quit button causes the " + "current settings to be saved to the configuration " + "file (~/.nvidia-settings-rc), and nvidia-settings " + "to exit."); +- ++ + /* create the horizontal pane */ + + hpane = gtk_hpaned_new(); +@@ -598,11 +599,11 @@ GtkWidget *ctk_window_new(ParsedAttribut + gtk_paned_pack1(GTK_PANED(hpane), frame, FALSE, FALSE); + + /* scrollable window */ +- ++ + sw = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); +- ++ + gtk_container_add(GTK_CONTAINER(frame), sw); + + /* create the tree model */ +@@ -857,7 +858,7 @@ GtkWidget *ctk_window_new(ParsedAttribut + gtk_tree_store_set(ctk_window->tree_store, &iter, + CTK_WINDOW_WIDGET_COLUMN, child, -1); + gtk_tree_store_set(ctk_window->tree_store, &iter, +- CTK_WINDOW_HELP_COLUMN, ++ CTK_WINDOW_HELP_COLUMN, + ctk_gpu_create_help(tag_table, CTK_GPU(child)), -1); + gtk_tree_store_set(ctk_window->tree_store, &iter, + CTK_WINDOW_CONFIG_FILE_ATTRIBUTES_FUNC_COLUMN, +@@ -883,7 +884,7 @@ GtkWidget *ctk_window_new(ParsedAttribut + if (child) { + help = ctk_powermizer_create_help(tag_table, CTK_POWERMIZER(child)); + add_page(child, help, ctk_window, &iter, NULL, "PowerMizer", +- NULL, ctk_powermizer_start_timer, ++ NULL, ctk_powermizer_start_timer, + ctk_powermizer_stop_timer); + } + +@@ -995,6 +996,14 @@ GtkWidget *ctk_window_new(ParsedAttribut ctk_window, NULL, NULL, "nvidia-settings Configuration", NULL, NULL, NULL); -+ }/* End skipping when nvidia is not loaded */ -+ -+ /* We show this section in two cases: -+ * 1) when the driver is not in use (hybrid graphics) -+ * 2) when the driver release >= 319 -+ */ -+ if (driver_major == 0 || driver_major >= 319) { -+ /* PRIME settings */ -+ widget = ctk_prime_new(ctk_config); -+ if (widget) { -+ help = ctk_prime_create_help(tag_table, CTK_PRIME(widget)); -+ add_page(widget, help, ctk_window, NULL, NULL, "PRIME Profiles", -+ NULL, NULL, NULL); -+ } -+ } ++ /* PRIME settings */ ++ widget = ctk_prime_new(ctk_config); ++ if (widget) { ++ help = ctk_prime_create_help(tag_table, CTK_PRIME(widget)); ++ add_page(widget, help, ctk_window, NULL, NULL, "PRIME Profiles", ++ NULL, NULL, NULL); ++ } + /* * we're done with the current data in the parsed attribute list, * so clean it out +@@ -1022,9 +1031,9 @@ GtkWidget *ctk_window_new(ParsedAttribut + + + /* set the window title */ +- ++ + gtk_window_set_title(GTK_WINDOW(object), "NVIDIA Settings"); +- ++ + gtk_widget_show_all(GTK_WIDGET(object)); + + +@@ -1057,7 +1066,7 @@ GtkWidget *ctk_window_new(ParsedAttribut + + g_signal_connect(G_OBJECT(ctk_window), "delete-event", + G_CALLBACK(ctk_window_delete_event), (gpointer) ctk_window); +- ++ + return GTK_WIDGET(object); + + } /* ctk_window_new() */ +@@ -1154,7 +1163,7 @@ static void add_page(GtkWidget *widget, + GtkTreeIter *child_iter, + const gchar *label, config_file_attributes_func_t func, + select_widget_func_t select_func, +- unselect_widget_func_t unselect_func) ++ unselect_widget_func_t unselect_func) + { + GtkTreeIter tmp_child_iter; + +@@ -1226,20 +1235,20 @@ static GtkWidget *create_quit_dialog(Ctk + + gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); + gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); +- ++ + hbox = gtk_hbox_new(FALSE, 5); + gtk_container_set_border_width(GTK_CONTAINER(hbox), 6); + gtk_container_add(GTK_CONTAINER(ctk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox); +- ++ + pixbuf = ctk_widget_render_icon(dialog, CTK_STOCK_DIALOG_QUESTION, + GTK_ICON_SIZE_DIALOG, NULL); + image = gtk_image_new_from_pixbuf(pixbuf); + g_object_unref(pixbuf); +- ++ + alignment = gtk_alignment_new(0.0, 0.0, 0, 0); + gtk_container_add(GTK_CONTAINER(alignment), image); + gtk_box_pack_start(GTK_BOX(hbox), alignment, FALSE, FALSE, 2); +- ++ + label = gtk_label_new("Do you really want to quit?"); + ctk_window->quit_dialog_pending_label = label; + alignment = gtk_alignment_new(0.0, 0.0, 0, 0); +@@ -1540,7 +1549,7 @@ static void update_display_devices(GtkWi + parent_path = + gtk_tree_model_get_path(GTK_TREE_MODEL(ctk_window->tree_store), + &parent_iter); +- parent_expanded = ++ parent_expanded = + gtk_tree_view_row_expanded(ctk_window->treeview, parent_path); + + --- a/src/src.mk +++ b/src/src.mk @@ -173,6 +173,7 @@ GTK_SRC += gtk+-2.x/ctkapcrulemodel.c @@ -842,39 +1000,35 @@ if (!filename) { nv_error_msg("Unable to open configuration file for writing."); return NV_FALSE; ---- a/src/gtk+-2.x/ctkui.c -+++ b/src/gtk+-2.x/ctkui.c -@@ -49,6 +49,8 @@ void ctk_main(ParsedAttribute *p, - gtk_window_set_default_icon_list(list); - window = ctk_window_new(p, conf, system); +--- a/src/nvidia-settings.c ++++ b/src/nvidia-settings.c +@@ -306,7 +306,7 @@ int main(int argc, char **argv) + NvCtrlFreeAllSystems(&systems); + return ret ? 0 : 1; + } +- ++ + /* initialize the parsed attribute list */ -+ /* Skip if nvidia is not loaded */ -+ if (system) { - if (!system->has_nv_control) { - GtkWidget *dlg; - dlg = gtk_message_dialog_new (NULL, -@@ -62,7 +64,7 @@ void ctk_main(ParsedAttribute *p, - gtk_dialog_run(GTK_DIALOG(dlg)); - gtk_widget_destroy (dlg); + p = nv_parsed_attribute_init(); +@@ -335,7 +335,7 @@ int main(int argc, char **argv) } -- -+ } - ctk_window_set_active_page(CTK_WINDOW(window), page); - gtk_main(); ---- a/src/nvidia-settings.c -+++ b/src/nvidia-settings.c -@@ -366,11 +366,11 @@ int main(int argc, char **argv) - /* Get the CtrlSystem for this X screen */ + /* upload the data from the config file */ +- ++ + if (!op->no_load) { + ret = nv_read_config_file(op, op->config, op->ctrl_display, + p, &conf, &systems); +@@ -367,9 +367,11 @@ int main(int argc, char **argv) system = NvCtrlGetSystem(op->ctrl_display, &systems); -- + +#if 0 - if (!system || !system->dpy) { + if (!system) { return 1; } -- +#endif + /* pass control to the gui */ - libdata.fn_ctk_main(p, &conf, system, op->page); diff -Nru nvidia-settings-470.57.01/debian/patches/17_do_not_read_config_on_power_saving_mode.patch nvidia-settings-510.47.03/debian/patches/17_do_not_read_config_on_power_saving_mode.patch --- nvidia-settings-470.57.01/debian/patches/17_do_not_read_config_on_power_saving_mode.patch 2021-09-17 09:29:27.000000000 +0000 +++ nvidia-settings-510.47.03/debian/patches/17_do_not_read_config_on_power_saving_mode.patch 2022-02-14 15:48:01.000000000 +0000 @@ -1,11 +1,9 @@ -Index: nvidia-settings-470.57.01/src/nvidia-settings.c -=================================================================== ---- nvidia-settings-470.57.01.orig/src/nvidia-settings.c 2021-09-10 00:40:09.000000000 +0800 -+++ nvidia-settings-470.57.01/src/nvidia-settings.c 2021-09-10 00:42:27.903240138 +0800 -@@ -336,7 +336,7 @@ +--- a/src/nvidia-settings.c ++++ b/src/nvidia-settings.c +@@ -336,7 +336,7 @@ int main(int argc, char **argv) /* upload the data from the config file */ - + - if (!op->no_load) { + if (!op->no_load && systems.n != 0) { ret = nv_read_config_file(op, op->config, op->ctrl_display, diff -Nru nvidia-settings-470.57.01/debian/patches/series nvidia-settings-510.47.03/debian/patches/series --- nvidia-settings-470.57.01/debian/patches/series 2022-02-03 15:28:23.000000000 +0000 +++ nvidia-settings-510.47.03/debian/patches/series 2022-02-14 15:48:01.000000000 +0000 @@ -1,7 +1,6 @@ link-order.diff 05_add_polkit_support.patch 06_remove_local_prefix.patch -07_remove_features_for_legacy.patch 08_add_prime_support.patch 10_legacy_vdpau.patch 11_link_as-needed.patch diff -Nru nvidia-settings-470.57.01/debian/rules.defs nvidia-settings-510.47.03/debian/rules.defs --- nvidia-settings-470.57.01/debian/rules.defs 2021-08-17 12:50:46.000000000 +0000 +++ nvidia-settings-510.47.03/debian/rules.defs 2022-02-14 15:48:01.000000000 +0000 @@ -1,3 +1,3 @@ NVIDIA_FILENAME = nvidia-settings-${NVIDIA_RELEASE}.tar.bz2 NVIDIA_TARBALL = nvidia-settings_${NVIDIA_RELEASE}.orig.tar.bz2 -HTTPURL_PREFIX = https://download.nvidia.com/XFree86/nvidia-settings/ +HTTPURL_PREFIX = https://download.nvidia.com/XFree86/nvidia-settings diff -Nru nvidia-settings-470.57.01/doc/version.mk nvidia-settings-510.47.03/doc/version.mk --- nvidia-settings-470.57.01/doc/version.mk 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/doc/version.mk 2022-01-24 23:51:09.000000000 +0000 @@ -1,4 +1,4 @@ -NVIDIA_VERSION = 470.57.01 +NVIDIA_VERSION = 510.47.03 # This file. VERSION_MK_FILE := $(lastword $(MAKEFILE_LIST)) diff -Nru nvidia-settings-470.57.01/samples/nv-control-events.c nvidia-settings-510.47.03/samples/nv-control-events.c --- nvidia-settings-470.57.01/samples/nv-control-events.c 2021-07-07 22:48:21.000000000 +0000 +++ nvidia-settings-510.47.03/samples/nv-control-events.c 2022-01-24 23:51:09.000000000 +0000 @@ -623,7 +623,6 @@ 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_GPU_CURRENT_PROCESSOR_CLOCK_FREQS), 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), @@ -654,8 +653,6 @@ MAKE_ENTRY(NV_CTRL_FRAMELOCK_DISPLAY_CONFIG), MAKE_ENTRY(NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY), MAKE_ENTRY(NV_CTRL_USED_DEDICATED_GPU_MEMORY), - MAKE_ENTRY(NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE), - MAKE_ENTRY(NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT), MAKE_ENTRY(NV_CTRL_DPY_HDMI_3D), MAKE_ENTRY(NV_CTRL_BASE_MOSAIC), MAKE_ENTRY(NV_CTRL_MULTIGPU_PRIMARY_POSSIBLE), diff -Nru nvidia-settings-470.57.01/samples/nv-control-info.c nvidia-settings-510.47.03/samples/nv-control-info.c --- nvidia-settings-470.57.01/samples/nv-control-info.c 2021-07-07 22:48:21.000000000 +0000 +++ nvidia-settings-510.47.03/samples/nv-control-info.c 2022-01-24 23:51:09.000000000 +0000 @@ -161,7 +161,6 @@ 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_GPU_CURRENT_PROCESSOR_CLOCK_FREQS), 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), @@ -191,8 +190,6 @@ MAKE_ENTRY(NV_CTRL_FRAMELOCK_DISPLAY_CONFIG), MAKE_ENTRY(NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY), MAKE_ENTRY(NV_CTRL_USED_DEDICATED_GPU_MEMORY), - MAKE_ENTRY(NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE), - MAKE_ENTRY(NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT), MAKE_ENTRY(NV_CTRL_DPY_HDMI_3D), MAKE_ENTRY(NV_CTRL_BASE_MOSAIC), MAKE_ENTRY(NV_CTRL_MULTIGPU_PRIMARY_POSSIBLE), diff -Nru nvidia-settings-470.57.01/samples/nv-control-warpblend.c nvidia-settings-510.47.03/samples/nv-control-warpblend.c --- nvidia-settings-470.57.01/samples/nv-control-warpblend.c 2021-07-07 22:48:21.000000000 +0000 +++ nvidia-settings-510.47.03/samples/nv-control-warpblend.c 2022-01-24 23:51:09.000000000 +0000 @@ -23,11 +23,11 @@ #include "nv-control-warpblend.h" -typedef struct __attribute__((packed)) { +typedef struct { float x, y; } vertex2f; -typedef struct __attribute__((packed)) { +typedef struct { vertex2f pos; vertex2f tex; vertex2f tex2; diff -Nru nvidia-settings-470.57.01/samples/version.mk nvidia-settings-510.47.03/samples/version.mk --- nvidia-settings-470.57.01/samples/version.mk 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/samples/version.mk 2022-01-24 23:51:09.000000000 +0000 @@ -1,4 +1,4 @@ -NVIDIA_VERSION = 470.57.01 +NVIDIA_VERSION = 510.47.03 # This file. VERSION_MK_FILE := $(lastword $(MAKEFILE_LIST)) diff -Nru nvidia-settings-470.57.01/src/command-line.c nvidia-settings-510.47.03/src/command-line.c --- nvidia-settings-470.57.01/src/command-line.c 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/command-line.c 2022-01-24 23:51:09.000000000 +0000 @@ -49,7 +49,7 @@ { nv_msg(NULL, ""); nv_msg(NULL, NV_ID_STRING); - nv_msg(TAB, "The NVIDIA X Server Settings tool."); + nv_msg(TAB, "The NVIDIA Settings tool."); nv_msg(NULL, ""); nv_msg(TAB, "This program is used to configure the " "NVIDIA Linux graphics driver."); diff -Nru nvidia-settings-470.57.01/src/common-utils/msg.c nvidia-settings-510.47.03/src/common-utils/msg.c --- nvidia-settings-470.57.01/src/common-utils/msg.c 2021-07-07 22:48:22.000000000 +0000 +++ nvidia-settings-510.47.03/src/common-utils/msg.c 2022-01-24 23:51:09.000000000 +0000 @@ -113,7 +113,7 @@ NV_VSNPRINTF(buf, fmt); \ format(stream, prefix, buf, whitespace); \ free (buf); \ -} while(0) +} while (0) /* diff -Nru nvidia-settings-470.57.01/src/common-utils/nvgetopt.c nvidia-settings-510.47.03/src/common-utils/nvgetopt.c --- nvidia-settings-470.57.01/src/common-utils/nvgetopt.c 2021-07-07 22:48:22.000000000 +0000 +++ nvidia-settings-510.47.03/src/common-utils/nvgetopt.c 2022-01-24 23:51:09.000000000 +0000 @@ -189,7 +189,7 @@ if (a[0] == '-') a++; if (a[0] == '+') a++; - while(a[0]) { a[0] = a[1]; a++; } + while (a[0]) { a[0] = a[1]; a++; } /* * decrement argv_index so that we process this diff -Nru nvidia-settings-470.57.01/src/common-utils/nvpci-utils.c nvidia-settings-510.47.03/src/common-utils/nvpci-utils.c --- nvidia-settings-470.57.01/src/common-utils/nvpci-utils.c 1970-01-01 00:00:00.000000000 +0000 +++ nvidia-settings-510.47.03/src/common-utils/nvpci-utils.c 2022-01-24 23:51:09.000000000 +0000 @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2021 NVIDIA Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "nvpci-utils.h" + +/* + * libpciaccess stores the device class in bits 16-23, subclass in 8-15, and + * interface in bits 0-7 of dev->device_class. We care only about the class + * and subclass. + */ +const uint32_t PCI_CLASS_DISPLAY_VGA = 0x30000; +const uint32_t PCI_CLASS_SUBCLASS_MASK = 0xffff00; + +/* + * nvpci_find_gpu_by_vendor() - use libpciaccess to find all VGA and 3D PCI + * devices matching the passed-in vendor_id (which may be set to PCI_MATCH_ANY). + * The caller is responsible for calling pci_system_init() before using this + * function, and pci_system_cleanup() when libpciaccess is no longer needed. + */ +struct pci_device_iterator *nvpci_find_gpu_by_vendor(uint32_t vendor_id) +{ + const struct pci_id_match match = { + .vendor_id = vendor_id, + .device_id = PCI_MATCH_ANY, + .subvendor_id = PCI_MATCH_ANY, + .subdevice_id = PCI_MATCH_ANY, + .device_class = PCI_CLASS_DISPLAY_VGA, + /* + * Ignore bit 1 of the subclass, to allow both 0x30000 (VGA controller) + * and 0x30200 (3D controller). + */ + .device_class_mask = PCI_CLASS_SUBCLASS_MASK & ~0x200, + }; + + return pci_id_match_iterator_create(&match); +} + +/* + * nvpci_dev_is_vga() - test whether the passed-in struct pci_device* has the + * VGA device class 0x0300 (and not 3D class 0x0302). + */ +int nvpci_dev_is_vga(struct pci_device *dev) +{ + return (dev->device_class & PCI_CLASS_SUBCLASS_MASK) == + PCI_CLASS_DISPLAY_VGA; +} diff -Nru nvidia-settings-470.57.01/src/common-utils/nvpci-utils.h nvidia-settings-510.47.03/src/common-utils/nvpci-utils.h --- nvidia-settings-470.57.01/src/common-utils/nvpci-utils.h 1970-01-01 00:00:00.000000000 +0000 +++ nvidia-settings-510.47.03/src/common-utils/nvpci-utils.h 2022-01-24 23:51:09.000000000 +0000 @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2021 NVIDIA Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef __NVPCI_UTILS_H__ +#define __NVPCI_UTILS_H__ + +#include + +#define NV_PCI_VENDOR_ID 0x10de + +struct pci_device_iterator *nvpci_find_gpu_by_vendor(uint32_t vendor_id); +int nvpci_dev_is_vga(struct pci_device *dev); + +#endif /* __NVPCI_UTILS_H__ */ diff -Nru nvidia-settings-470.57.01/src/common-utils/src.mk nvidia-settings-510.47.03/src/common-utils/src.mk --- nvidia-settings-470.57.01/src/common-utils/src.mk 2021-07-07 22:48:22.000000000 +0000 +++ nvidia-settings-510.47.03/src/common-utils/src.mk 2022-01-24 23:51:09.000000000 +0000 @@ -1,5 +1,8 @@ # makefile fragment included by nvidia-xconfig, nvidia-settings, and nvidia-installer +# the including makefile should set this if the relevant program uses pciaccess +COMMON_UTILS_PCIACCESS ?= + COMMON_UTILS_SRC += nvgetopt.c COMMON_UTILS_SRC += common-utils.c COMMON_UTILS_SRC += msg.c @@ -9,6 +12,16 @@ COMMON_UTILS_EXTRA_DIST += msg.h COMMON_UTILS_EXTRA_DIST += src.mk +# only build nvpci-utils.c for programs that actually use libpciaccess, to +# prevent other programs from needing to set the right CFLAGS/LDFLAGS for code +# they won't use. Otherwise, just package it in the source tarball. +ifneq ($(COMMON_UTILS_PCIACCESS),) + COMMON_UTILS_SRC += nvpci-utils.c +else + COMMON_UTILS_EXTRA_DIST += nvpci-utils.c +endif +COMMON_UTILS_EXTRA_DIST += nvpci-utils.h + # gen-manpage-opts-helper.c is listed in EXTRA_DIST, rather than SRC, # because it is not compiled into the utilities themselves, but used # when building the utility's gen-manpage-opts diff -Nru nvidia-settings-470.57.01/src/config-file.c nvidia-settings-510.47.03/src/config-file.c --- nvidia-settings-470.57.01/src/config-file.c 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/config-file.c 2022-01-24 23:51:09.000000000 +0000 @@ -19,7 +19,7 @@ /* * config-file.c - this source file contains functions for processing - * the NVIDIA X Server control panel configuration file. + * the NVIDIA Settings control panel configuration file. * * The configuration file is simply a newline-separated list of * attribute strings, where the syntax of an attribute string is @@ -260,7 +260,7 @@ fprintf(stream, "# %s\n", filename); fprintf(stream, "#\n"); fprintf(stream, "# Configuration file for nvidia-settings - the NVIDIA " - "X Server Settings utility\n"); + "Settings utility\n"); /* NOTE: ctime(3) generates a new line */ diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctk3dvisionpro.c nvidia-settings-510.47.03/src/gtk+-2.x/ctk3dvisionpro.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctk3dvisionpro.c 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctk3dvisionpro.c 2022-01-24 23:51:09.000000000 +0000 @@ -187,7 +187,8 @@ static void ctk_3d_vision_pro_class_init(Ctk3DVisionProClass - *ctk_3d_vision_pro_class) + *ctk_3d_vision_pro_class, + gpointer class_data) { GObjectClass *gobject_class = (GObjectClass *)ctk_3d_vision_pro_class; gobject_class->finalize = ctk_3d_vision_pro_finalize; @@ -325,8 +326,11 @@ const gchar *str = gtk_entry_get_text(GTK_ENTRY(widget)); // Store new glasses name in dialog box - dlg->glasses_new_name = realloc(dlg->glasses_new_name, strlen(str) + 1); - strncpy(dlg->glasses_new_name, str, strlen(str) + 1); + char *new_name = strdup(str); + if (new_name != NULL) { + free(dlg->glasses_new_name); + dlg->glasses_new_name = new_name; + } return str; } @@ -1320,7 +1324,7 @@ 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)); + sizeof(HTU(0)->glasses_info[dlg->glasses_selected_index]->name) - 1); 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); diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkapcprofilemodel.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkapcprofilemodel.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkapcprofilemodel.c 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkapcprofilemodel.c 2022-01-24 23:51:09.000000000 +0000 @@ -29,9 +29,9 @@ static GObjectClass *parent_class = NULL; // Forward declarations -static void apc_profile_model_init(CtkApcProfileModel *prof_model); +static void apc_profile_model_init(CtkApcProfileModel *prof_model, gpointer); static void apc_profile_model_finalize(GObject *object); -static void apc_profile_model_tree_model_init(GtkTreeModelIface *iface); +static void apc_profile_model_tree_model_init(GtkTreeModelIface *iface, gpointer); static GtkTreeModelFlags apc_profile_model_get_flags(GtkTreeModel *tree_model); static gint apc_profile_model_get_n_columns(GtkTreeModel *tree_model); static GType apc_profile_model_get_column_type(GtkTreeModel *tree_model, gint index); @@ -54,7 +54,7 @@ static gboolean apc_profile_model_iter_parent(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child); -static void apc_profile_model_class_init(CtkApcProfileModelClass *klass); +static void apc_profile_model_class_init(CtkApcProfileModelClass *klass, gpointer); static void apc_profile_model_get_value(GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, @@ -62,7 +62,7 @@ static void -apc_profile_model_tree_sortable_init(GtkTreeSortableIface *iface); +apc_profile_model_tree_sortable_init(GtkTreeSortableIface *iface, gpointer); static gboolean apc_profile_model_get_sort_column_id(GtkTreeSortable *sortable, gint *sort_column_id, @@ -122,7 +122,7 @@ return apc_profile_model_type; } -static void apc_profile_model_class_init(CtkApcProfileModelClass *klass) +static void apc_profile_model_class_init(CtkApcProfileModelClass *klass, gpointer class_data) { GObjectClass *object_class; @@ -182,7 +182,7 @@ return result; } -static void apc_profile_model_init(CtkApcProfileModel *prof_model) +static void apc_profile_model_init(CtkApcProfileModel *prof_model, gpointer g_class) { prof_model->stamp = g_random_int(); // random int to catch iterator type mismatches prof_model->config = NULL; @@ -222,7 +222,8 @@ } static void -apc_profile_model_tree_model_init(GtkTreeModelIface *iface) +apc_profile_model_tree_model_init(GtkTreeModelIface *iface, + gpointer iface_data) { iface->get_flags = apc_profile_model_get_flags; iface->get_n_columns = apc_profile_model_get_n_columns; @@ -239,7 +240,8 @@ } static void -apc_profile_model_tree_sortable_init(GtkTreeSortableIface *iface) +apc_profile_model_tree_sortable_init(GtkTreeSortableIface *iface, + gpointer iface_data) { iface->get_sort_column_id = apc_profile_model_get_sort_column_id; iface->set_sort_column_id = apc_profile_model_set_sort_column_id; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkapcrulemodel.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkapcrulemodel.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkapcrulemodel.c 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkapcrulemodel.c 2022-01-24 23:51:09.000000000 +0000 @@ -28,12 +28,12 @@ // Forward declarations GType ctk_apc_rule_model_get_type(void); -static void apc_rule_model_class_init(CtkApcRuleModelClass *klass); -static void apc_rule_model_init(CtkApcRuleModel *rule_model); +static void apc_rule_model_class_init(CtkApcRuleModelClass *klass, gpointer); +static void apc_rule_model_init(CtkApcRuleModel *rule_model, gpointer); static void apc_rule_model_finalize(GObject *object); -static void apc_rule_model_tree_model_init(GtkTreeModelIface *iface); -static void apc_rule_model_drag_source_init(GtkTreeDragSourceIface *iface); -static void apc_rule_model_drag_dest_init(GtkTreeDragDestIface *iface); +static void apc_rule_model_tree_model_init(GtkTreeModelIface *iface, gpointer); +static void apc_rule_model_drag_source_init(GtkTreeDragSourceIface *iface, gpointer); +static void apc_rule_model_drag_dest_init(GtkTreeDragDestIface *iface, gpointer); static GtkTreeModelFlags apc_rule_model_get_flags(GtkTreeModel *tree_model); static gint apc_rule_model_get_n_columns(GtkTreeModel *tree_model); static GType apc_rule_model_get_column_type(GtkTreeModel *tree_model, gint index); @@ -132,7 +132,8 @@ return apc_rule_model_type; } -static void apc_rule_model_class_init(CtkApcRuleModelClass *klass) +static void apc_rule_model_class_init(CtkApcRuleModelClass *klass, + gpointer class_data) { GObjectClass *object_class; @@ -142,7 +143,7 @@ object_class->finalize = apc_rule_model_finalize; } -static void apc_rule_model_init(CtkApcRuleModel *rule_model) +static void apc_rule_model_init(CtkApcRuleModel *rule_model, gpointer g_class) { rule_model->stamp = g_random_int(); // random int to catch iterator type mismatches rule_model->config = NULL; @@ -156,7 +157,8 @@ parent_class->finalize(object); } -static void apc_rule_model_tree_model_init(GtkTreeModelIface *iface) +static void apc_rule_model_tree_model_init(GtkTreeModelIface *iface, + gpointer iface_data) { iface->get_flags = apc_rule_model_get_flags; iface->get_n_columns = apc_rule_model_get_n_columns; @@ -172,14 +174,16 @@ iface->iter_parent = apc_rule_model_iter_parent; } -static void apc_rule_model_drag_source_init(GtkTreeDragSourceIface *iface) +static void apc_rule_model_drag_source_init(GtkTreeDragSourceIface *iface, + gpointer iface_data) { iface->row_draggable = apc_rule_model_row_draggable; iface->drag_data_get = apc_rule_model_drag_data_get; iface->drag_data_delete = apc_rule_model_drag_data_delete; } -static void apc_rule_model_drag_dest_init(GtkTreeDragDestIface *iface) +static void apc_rule_model_drag_dest_init(GtkTreeDragDestIface *iface, + gpointer iface_data) { iface->drag_data_received = apc_rule_model_drag_data_received; iface->row_drop_possible = apc_rule_model_row_drop_possible; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkappprofile.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkappprofile.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkappprofile.c 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkappprofile.c 2022-01-24 23:51:09.000000000 +0000 @@ -42,6 +42,10 @@ #define STATUSBAR_UPDATE_WARNING "This will take effect after changes are saved." +#define SHARPEN_ENABLE_DEFAULT FALSE +#define SHARPEN_VALUE_DEFAULT 50 +#define SHARPEN_FILM_GRAIN_DEFAULT 17 + enum { RULE_FEATURE_PROCNAME, RULE_FEATURE_DSO, @@ -138,7 +142,7 @@ /* * Function prototypes */ -static void app_profile_class_init(CtkAppProfileClass *ctk_object_class); +static void app_profile_class_init(CtkAppProfileClass *ctk_object_class, gpointer); static void app_profile_finalize(GObject *object); static void edit_rule_dialog_destroy(EditRuleDialog *dialog); static void edit_profile_dialog_destroy(EditProfileDialog *dialog); @@ -232,7 +236,8 @@ } /* ctk_app_profile_get_type() */ -static void app_profile_class_init(CtkAppProfileClass *ctk_object_class) +static void app_profile_class_init(CtkAppProfileClass *ctk_object_class, + gpointer class_data) { GObjectClass *gobject_class = G_OBJECT_CLASS(ctk_object_class); gobject_class->finalize = app_profile_finalize; @@ -361,8 +366,13 @@ for (i = 0; i < json_array_size(key_docs); i++) { json_t *json_key_object = json_array_get(key_docs, i); json_t *json_name = json_object_get(json_key_object, "key"); + const gchar *key_name = json_string_value(json_name); + // The GLSharpen* variables have custom UI, so don't add them to the dropdown + if (!strncmp(key_name, "GLSharpen", 9)) { + continue; + } ctk_drop_down_menu_append_item(menu, - json_string_value(json_name), + key_name, i); } @@ -1381,6 +1391,18 @@ return FALSE; } +static void sharpen_enable_checkbox_toggled(GtkWidget *widget, + gpointer user_data) +{ + EditProfileDialog *dialog = (EditProfileDialog *)user_data; + gboolean sharpen_enable; + + sharpen_enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + + ctk_widget_set_visible(dialog->sharpen_value_box, sharpen_enable); + ctk_widget_set_visible(dialog->sharpen_film_grain_box, sharpen_enable); +} + static const char __rule_pattern_help[] = "In this section, you write the pattern that will be used to determine whether " "the settings in this rule will apply to a given application."; @@ -2347,12 +2369,47 @@ return FALSE; } +static void edit_profile_dialog_update_sharpen_settings(EditProfileDialog *dialog) +{ + json_t *sharpen_enable_setting, *sharpen_value_setting, *sharpen_film_setting; + gboolean sharpen_enable; + int sharpen_value, sharpen_film; + + sharpen_enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->sharpen_enable_check_button)); + + if (!sharpen_enable) { + return; + } + + sharpen_enable_setting = json_object(); + json_object_set_new(sharpen_enable_setting, "key", json_string("GLSharpenEnable")); + json_object_set_new(sharpen_enable_setting, "value", json_boolean(sharpen_enable)); + + json_array_append(dialog->settings, sharpen_enable_setting); + + sharpen_value_setting = json_object(); + json_object_set_new(sharpen_value_setting, "key", json_string("GLSharpenValue")); + sharpen_value = gtk_adjustment_get_value(GTK_ADJUSTMENT(dialog->sharpen_value_adjustment)); + json_object_set_new(sharpen_value_setting, "value", json_integer(sharpen_value)); + + json_array_append(dialog->settings, sharpen_value_setting); + + sharpen_film_setting = json_object(); + json_object_set_new(sharpen_film_setting, "key", json_string("GLSharpenIgnoreFilmGrain")); + sharpen_film = gtk_adjustment_get_value(GTK_ADJUSTMENT(dialog->sharpen_film_grain_adjustment)); + json_object_set_new(sharpen_film_setting, "value", json_integer(sharpen_film)); + + json_array_append(dialog->settings, sharpen_film_setting); +} + static void edit_profile_dialog_update_settings(EditProfileDialog *dialog) { json_array_clear(dialog->settings); gtk_tree_model_foreach(GTK_TREE_MODEL(dialog->settings_store), append_setting, (gpointer)dialog->settings); + + edit_profile_dialog_update_sharpen_settings(dialog); } static gboolean widget_get_visible(GtkWidget *widget) @@ -2973,6 +3030,11 @@ GtkWidget *tree_view; GtkWidget *scroll_win; GtkWidget *button; + GtkWidget *sharpen_enable_checkbox; + GtkWidget *sharpen_value_slider; + GtkWidget *sharpen_film_slider; + GtkAdjustment *sharpen_value_adjustment; + GtkAdjustment *sharpen_film_adjustment; GList *toolbar_widget_items; ToolbarItemTemplate *edit_profile_settings_toolbar_items, *edit_profile_dialog_toolbar_items; @@ -2980,7 +3042,6 @@ TreeViewColumnTemplate *settings_tree_view_columns; size_t num_settings_tree_view_columns; - dialog = malloc(sizeof(EditProfileDialog)); if (!dialog) { return NULL; @@ -3098,6 +3159,56 @@ gtk_container_add(GTK_CONTAINER(scroll_win), tree_view); gtk_box_pack_start(GTK_BOX(main_vbox), scroll_win, TRUE, TRUE, 0); + hbox = gtk_hbox_new(FALSE, 5); + + label = gtk_label_new("Enable Sharpening"); + dialog->sharpen_enable_check_button = sharpen_enable_checkbox + = gtk_check_button_new(); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sharpen_enable_checkbox), + SHARPEN_ENABLE_DEFAULT); + + g_signal_connect(G_OBJECT(sharpen_enable_checkbox), "toggled", + G_CALLBACK(sharpen_enable_checkbox_toggled), + (gpointer)dialog); + + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), sharpen_enable_checkbox, TRUE, TRUE, 0); + + gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 0); + + dialog->sharpen_value_box = hbox = gtk_hbox_new(FALSE, 5); + label = gtk_label_new("Sharpening Amount"); + dialog->sharpen_value_adjustment = sharpen_value_adjustment + = GTK_ADJUSTMENT(gtk_adjustment_new(SHARPEN_VALUE_DEFAULT, 0, 100, 1, 1, 0.0)); + + dialog->sharpen_value_slider = sharpen_value_slider = + gtk_hscale_new(GTK_ADJUSTMENT(sharpen_value_adjustment)); + gtk_scale_set_draw_value(GTK_SCALE(sharpen_value_slider), TRUE); + gtk_scale_set_value_pos(GTK_SCALE(sharpen_value_slider), GTK_POS_TOP); + gtk_scale_set_digits(GTK_SCALE(sharpen_value_slider), 0); + + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), sharpen_value_slider, TRUE, TRUE, 0); + + gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 0); + + dialog->sharpen_film_grain_box = hbox = gtk_hbox_new(FALSE, 5); + label = gtk_label_new("Film Grain Reduction"); + dialog->sharpen_film_grain_adjustment = sharpen_film_adjustment = + GTK_ADJUSTMENT(gtk_adjustment_new(SHARPEN_FILM_GRAIN_DEFAULT, 0, 100, 1, 1, 0.0)); + + dialog->sharpen_film_grain_slider = sharpen_film_slider = + gtk_hscale_new(GTK_ADJUSTMENT(sharpen_film_adjustment)); + gtk_scale_set_draw_value(GTK_SCALE(sharpen_film_slider), TRUE); + gtk_scale_set_value_pos(GTK_SCALE(sharpen_film_slider), GTK_POS_TOP); + gtk_scale_set_digits(GTK_SCALE(sharpen_film_slider), 0); + + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), sharpen_film_slider, TRUE, TRUE, 0); + + gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 0); + dialog->setting_update_canceled = FALSE; ctk_statusbar_init(&dialog->error_statusbar); @@ -3399,6 +3510,50 @@ return FALSE; } +static gboolean check_sharpening_setting(EditProfileDialog *dialog, + GtkTreeModel *model, + GtkTreeIter *iter) +{ + json_t *setting; + json_t *value; + const char *key; + + gtk_tree_model_get(model, iter, SETTING_LIST_STORE_COL_SETTING, &setting, -1); + if (setting && setting->refcount == 0) { + return FALSE; + } + + key = json_string_value(json_object_get(setting, "key")); + value = json_object_get(setting, "value"); + + if (!strcmp(key, "GLSharpenEnable")) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->sharpen_enable_check_button), + json_is_true(value)); + return TRUE; + } else if (!strcmp(key, "GLSharpenValue") && json_is_integer(value)) { + gtk_adjustment_set_value(GTK_ADJUSTMENT(dialog->sharpen_value_adjustment), json_integer_value(value)); + return TRUE; + } else if (!strcmp(key, "GLSharpenIgnoreFilmGrain") && json_is_integer(value)) { + gtk_adjustment_set_value(GTK_ADJUSTMENT(dialog->sharpen_film_grain_adjustment), json_integer_value(value)); + return TRUE; + } + + return FALSE; +} + +static void edit_profile_dialog_load_sharpening_settings(EditProfileDialog *dialog) { + gint i, row_count; + GtkTreeModel *model = GTK_TREE_MODEL(dialog->settings_store); + GtkTreeIter iter; + row_count = gtk_tree_model_iter_n_children(model, NULL); + for (i = row_count - 1; i >= 0; i--) { + gtk_tree_model_iter_nth_child(model, &iter, NULL, i); + if (check_sharpening_setting(dialog, model, &iter)) { + gtk_list_store_remove(GTK_LIST_STORE(dialog->settings_store), &iter); + } + } +} + static void edit_profile_dialog_load_values(EditProfileDialog *dialog) { // window title @@ -3435,6 +3590,7 @@ load_settings_from_profile(CTK_APP_PROFILE(dialog->parent), dialog->settings_store, dialog->name->str); + edit_profile_dialog_load_sharpening_settings(dialog); } else { gtk_list_store_clear(dialog->settings_store); } @@ -3444,6 +3600,7 @@ { edit_profile_dialog_load_values(dialog); gtk_widget_show_all(dialog->top_window); + sharpen_enable_checkbox_toggled(dialog->sharpen_enable_check_button, dialog); // disable focusing to calling window until this window closed gtk_window_set_transient_for(GTK_WINDOW(dialog->top_window), diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkappprofile.h nvidia-settings-510.47.03/src/gtk+-2.x/ctkappprofile.h --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkappprofile.h 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkappprofile.h 2022-01-24 23:51:09.000000000 +0000 @@ -104,6 +104,14 @@ GtkWidget *source_file_combo; + GtkWidget *sharpen_enable_check_button; + GtkWidget *sharpen_value_box; + GtkAdjustment *sharpen_value_adjustment; + GtkWidget *sharpen_value_slider; + GtkWidget *sharpen_film_grain_box; + GtkAdjustment *sharpen_film_grain_adjustment; + GtkWidget *sharpen_film_grain_slider; + GtkWidget *add_edit_profile_button; GtkWidget *registry_key_combo; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkbanner.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkbanner.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkbanner.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkbanner.c 2022-01-24 23:51:09.000000000 +0000 @@ -59,7 +59,7 @@ static void -ctk_banner_class_init (CtkBannerClass *); +ctk_banner_class_init (CtkBannerClass *, gpointer); static void ctk_banner_finalize (GObject *); @@ -122,7 +122,8 @@ } static void ctk_banner_class_init( - CtkBannerClass *ctk_banner_class + CtkBannerClass *ctk_banner_class, + gpointer class_data ) { GObjectClass *gobject_class; @@ -311,7 +312,8 @@ needed_w = ctk_banner->artwork.w + ctk_banner->artwork_pad_x; needed_h = ctk_banner->artwork.h; - if ((ctk_banner->back.w >= needed_w) && + if (ctk_banner->artwork.pixbuf && + (ctk_banner->back.w >= needed_w) && (ctk_banner->back.h >= needed_h)) { w = ctk_banner->artwork.w; @@ -429,13 +431,13 @@ { BANNER_ARTWORK_X, FALSE, 16, PNG(x) }, { BANNER_ARTWORK_XVIDEO, FALSE, 16, PNG(xvideo) }, { BANNER_ARTWORK_SVP, FALSE, 16, PNG(svp_3dvp) }, - { BANNER_ARTWORK_INVALID, FALSE, 16, NULL, NULL }, + { BANNER_ARTWORK_BLANK, FALSE, 16, NULL, NULL }, #undef PNG }; int i; - for (i = 0; ArtworkTable[i].artwork != BANNER_ARTWORK_INVALID; i++) { + for (i = 0; ArtworkTable[i].artwork <= BANNER_ARTWORK_BLANK; i++) { if (ArtworkTable[i].artwork == artwork) { *tall = ArtworkTable[i].tall; *pad_x = ArtworkTable[i].pad_x; @@ -459,13 +461,10 @@ { GObject *object; CtkBanner *ctk_banner; - int tall, pad_x; + + int tall = 0, pad_x = 0; GdkPixbuf *pixbuf = select_artwork(artwork, &tall, &pad_x); - if (!pixbuf) { - return NULL; - } - object = g_object_new(CTK_TYPE_BANNER, NULL); ctk_banner = CTK_BANNER(object); @@ -524,10 +523,11 @@ /* load the artwork pixbuf */ - - ctk_banner->artwork.pixbuf = pixbuf; - ctk_banner->artwork.w = gdk_pixbuf_get_width(pixbuf); - ctk_banner->artwork.h = gdk_pixbuf_get_height(pixbuf); + if (pixbuf) { + ctk_banner->artwork.pixbuf = pixbuf; + ctk_banner->artwork.w = gdk_pixbuf_get_width(pixbuf); + ctk_banner->artwork.h = gdk_pixbuf_get_height(pixbuf); + } return GTK_WIDGET(object); } diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkbanner.h nvidia-settings-510.47.03/src/gtk+-2.x/ctkbanner.h --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkbanner.h 2021-07-07 22:48:19.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkbanner.h 2022-01-24 23:51:09.000000000 +0000 @@ -66,7 +66,7 @@ BANNER_ARTWORK_X, BANNER_ARTWORK_XVIDEO, BANNER_ARTWORK_SVP, - BANNER_ARTWORK_INVALID + BANNER_ARTWORK_BLANK } BannerArtworkType; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkcolorcontrols.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkcolorcontrols.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkcolorcontrols.c 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkcolorcontrols.c 2022-01-24 23:51:09.000000000 +0000 @@ -37,7 +37,7 @@ /* function prototypes */ static void -ctk_color_controls_class_init(CtkColorControlsClass *ctk_object_class); +ctk_color_controls_class_init(CtkColorControlsClass *ctk_object_class, gpointer); static void ctk_color_controls_finalize(GObject *object); @@ -122,7 +122,8 @@ static void -ctk_color_controls_class_init(CtkColorControlsClass *ctk_object_class) +ctk_color_controls_class_init(CtkColorControlsClass *ctk_object_class, + gpointer class_data) { GObjectClass *gobject_class = (GObjectClass *)ctk_object_class; gobject_class->finalize = ctk_color_controls_finalize; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkcolorcorrection.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkcolorcorrection.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkcolorcorrection.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkcolorcorrection.c 2022-01-24 23:51:09.000000000 +0000 @@ -82,7 +82,7 @@ flush_attribute_channel_values (CtkColorCorrection *, gint, gint); static void -ctk_color_correction_class_init(CtkColorCorrectionClass *); +ctk_color_correction_class_init(CtkColorCorrectionClass *, gpointer); static void ctk_color_correction_finalize(GObject *); @@ -163,7 +163,8 @@ static void ctk_color_correction_class_init(CtkColorCorrectionClass - *ctk_color_correction_class) + *ctk_color_correction_class, + gpointer class_data) { GObjectClass *gobject_class = (GObjectClass *)ctk_color_correction_class; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkconfig.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkconfig.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkconfig.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkconfig.c 2022-01-24 23:51:09.000000000 +0000 @@ -74,7 +74,7 @@ "that refer to that profile to also be updated to refer to the new " "profile name."; -static void ctk_config_class_init(CtkConfigClass *ctk_config_class); +static void ctk_config_class_init(CtkConfigClass *ctk_config_class, gpointer); static void display_status_bar_toggled(GtkWidget *, gpointer); static void slider_text_entries_toggled(GtkWidget *, gpointer); @@ -122,7 +122,8 @@ ctk_help_data_list_free_full(ctk_config->help_data); } -static void ctk_config_class_init(CtkConfigClass *ctk_config_class) +static void ctk_config_class_init(CtkConfigClass *ctk_config_class, + gpointer class_data) { GObjectClass *gobject_class = G_OBJECT_CLASS(ctk_config_class); gobject_class->finalize = config_finalize; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkcurve.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkcurve.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkcurve.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkcurve.c 2022-01-24 23:51:09.000000000 +0000 @@ -28,7 +28,7 @@ #define REQUESTED_HEIGHT 94 static void -ctk_curve_class_init (CtkCurveClass *); +ctk_curve_class_init (CtkCurveClass *, gpointer); static void ctk_curve_finalize (GObject *); @@ -95,7 +95,8 @@ } static void ctk_curve_class_init( - CtkCurveClass *ctk_curve_class + CtkCurveClass *ctk_curve_class, + gpointer class_data ) { GObjectClass *gobject_class; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkdisplayconfig.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkdisplayconfig.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkdisplayconfig.c 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkdisplayconfig.c 2022-01-24 23:51:09.000000000 +0000 @@ -499,6 +499,13 @@ CTK_EVENT_NAME(NV_CTRL_STRING_DELETE_METAMODE), G_CALLBACK(display_config_attribute_changed), (gpointer) ctk_object); + + if (screen->num_prime_displays > 0) { + g_signal_connect(G_OBJECT(screen->ctk_event), + CTK_EVENT_NAME(NV_CTRL_STRING_PRIME_OUTPUTS_DATA), + G_CALLBACK(display_config_attribute_changed), + (gpointer) ctk_object); + } } } /* register_layout_events() */ diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkdisplaydevice.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkdisplaydevice.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkdisplaydevice.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkdisplaydevice.c 2022-01-24 23:51:09.000000000 +0000 @@ -36,7 +36,7 @@ #include "ctkhelp.h" #include "ctkutils.h" -static void ctk_display_device_class_init(CtkDisplayDeviceClass *); +static void ctk_display_device_class_init(CtkDisplayDeviceClass *, gpointer); static void ctk_display_device_finalize(GObject *); static void reset_button_clicked(GtkButton *button, gpointer user_data); @@ -244,7 +244,8 @@ } static void ctk_display_device_class_init( - CtkDisplayDeviceClass *ctk_object_class + CtkDisplayDeviceClass *ctk_object_class, + gpointer class_data ) { GObjectClass *gobject_class = (GObjectClass *)ctk_object_class; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkditheringcontrols.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkditheringcontrols.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkditheringcontrols.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkditheringcontrols.c 2022-01-24 23:51:09.000000000 +0000 @@ -37,7 +37,7 @@ /* function prototypes */ static void -ctk_dither_controls_class_init(CtkDitheringControlsClass *ctk_object_class); +ctk_dither_controls_class_init(CtkDitheringControlsClass *ctk_object_class, gpointer); static void ctk_dither_controls_finalize(GObject *object); @@ -132,7 +132,8 @@ } /* ctk_dithering_controls_get_type() */ static void -ctk_dither_controls_class_init(CtkDitheringControlsClass *ctk_object_class) +ctk_dither_controls_class_init(CtkDitheringControlsClass *ctk_object_class, + gpointer class_data) { GObjectClass *gobject_class = (GObjectClass *)ctk_object_class; gobject_class->finalize = ctk_dither_controls_finalize; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkdropdownmenu.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkdropdownmenu.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkdropdownmenu.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkdropdownmenu.c 2022-01-24 23:51:09.000000000 +0000 @@ -33,7 +33,7 @@ static void -ctk_drop_down_menu_class_init(CtkDropDownMenuClass *ctk_drop_down_menu_class); +ctk_drop_down_menu_class_init(CtkDropDownMenuClass *ctk_drop_down_menu_class, gpointer class_data); static void ctk_drop_down_menu_free(GObject *object); @@ -69,7 +69,8 @@ static void -ctk_drop_down_menu_class_init(CtkDropDownMenuClass *ctk_drop_down_menu_class) +ctk_drop_down_menu_class_init(CtkDropDownMenuClass *ctk_drop_down_menu_class, + gpointer class_data) { GObjectClass *gobject_class; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkecc.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkecc.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkecc.c 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkecc.c 2022-01-24 23:51:09.000000000 +0000 @@ -58,6 +58,22 @@ "Returns the number of double-bit ECC errors detected by the " "targeted GPU since the last counter reset."; +static const char *__detailed_sbit_error_help = +"Returns the number of single-bit ECC errors detected for the specified " +"memory location by the targeted GPU since the last system reboot."; + +static const char *__detailed_dbit_error_help = +"Returns the number of double-bit ECC errors detected for the specified " +"memory location by the targeted GPU since the last system reboot."; + +static const char *__detailed_aggregate_sbit_error_help = +"Returns the number of single-bit ECC errors detected for the specified " +"memory location by the targeted GPU since the last counter reset."; + +static const char *__detailed_aggregate_dbit_error_help = +"Returns the number of double-bit ECC errors detected for the specified " +"memory location by the targeted GPU since the last counter reset."; + static const char *__configuration_status_help = "Returns the current ECC configuration setting or specifies new " "settings. Changes to these settings do not take effect until the next " @@ -157,6 +173,135 @@ /* + * memory_location_label() - returns the proper name of the memory location + * specified. + */ +static const char *memory_location_label(const int index, int sram_value) +{ + if (index < 0 || index >= NVML_MEMORY_LOCATION_COUNT) { + return "Unknown"; + } + + /* + * NVML_MEMORY_LOCATION_DRAM and MNML_MEMORY_LOCATION_DEVICE_MEMORY share + * the same index value. _DRAM is only for Turing+ while _DEVICE_MEMORY is + * used preTuring. Since NVML_MEMORY_LOCATION_SRAM is also only used for + * Turing+, if that value is valid then this is Turing+ and we want the DRAM + * label. + */ + + if (index == NVML_MEMORY_LOCATION_DRAM && sram_value >= 0) { + return "DRAM"; + } + + switch (index) { + case NVML_MEMORY_LOCATION_L1_CACHE: + return "L1 Cache"; + case NVML_MEMORY_LOCATION_L2_CACHE: + return "L2 Cache"; + case NVML_MEMORY_LOCATION_DEVICE_MEMORY: + // See above for duplicate value NVML_MEMORY_LOCATION_DRAM + return "Device Memory"; + case NVML_MEMORY_LOCATION_REGISTER_FILE: + return "Register File"; + case NVML_MEMORY_LOCATION_TEXTURE_MEMORY: + return "Texture Memory"; + case NVML_MEMORY_LOCATION_TEXTURE_SHM: + return "Texture Shared"; + case NVML_MEMORY_LOCATION_CBU: + return "CBU"; + case NVML_MEMORY_LOCATION_SRAM: + return "SRAM"; + } + + return "Unknown"; +} + + + +/* + * update_detailed_widgets() - fills in or clears out the values for the + * detailed ECC information. + */ +static void update_detailed_widgets(CtkEccDetailedTableRow errors[], + gboolean vol, int *counts) +{ + int loc; + int value; + char s[32]; + GtkLabel *label; + for (loc = NVML_MEMORY_LOCATION_L1_CACHE; + loc < NVML_MEMORY_LOCATION_COUNT; + loc++) { + + if (!counts) { + value = -1; + } else { + value = counts[loc]; + } + + if (vol) { + errors[loc].vol_count_value = value; + label = GTK_LABEL(errors[loc].vol_count); + } else { + errors[loc].agg_count_value = value; + label = GTK_LABEL(errors[loc].agg_count); + } + + if (value < 0) { + gtk_label_set_text(label, "N/A"); + } else { + sprintf(s, "%d", value); + gtk_label_set_text(label, s); + } + } +} + + + +/* + * hide_unavailable_rows() - Hide a row in the table for a memory location if + * both the volatile and aggregate values are less than 0, i.e. not supported. + */ + +static void hide_unavailable_rows(CtkEcc *ctk_ecc) +{ + int loc; + gboolean show_row; + gboolean any_detailed_info = FALSE; + + for (loc = NVML_MEMORY_LOCATION_L1_CACHE; + loc < NVML_MEMORY_LOCATION_COUNT; + loc++) { + + show_row = (ctk_ecc->single_errors[loc].vol_count_value >= 0 || + ctk_ecc->single_errors[loc].agg_count_value >= 0); + ctk_widget_set_visible(ctk_ecc->single_errors[loc].err_type, show_row); + ctk_widget_set_visible(ctk_ecc->single_errors[loc].mem_type, show_row); + ctk_widget_set_visible(ctk_ecc->single_errors[loc].vol_count, + show_row); + ctk_widget_set_visible(ctk_ecc->single_errors[loc].agg_count, + show_row); + any_detailed_info |= show_row; + + show_row = (ctk_ecc->double_errors[loc].vol_count_value >= 0 || + ctk_ecc->double_errors[loc].agg_count_value >= 0); + ctk_widget_set_visible(ctk_ecc->double_errors[loc].err_type, show_row); + ctk_widget_set_visible(ctk_ecc->double_errors[loc].mem_type, show_row); + ctk_widget_set_visible(ctk_ecc->double_errors[loc].vol_count, + show_row); + ctk_widget_set_visible(ctk_ecc->double_errors[loc].agg_count, + show_row); + any_detailed_info |= show_row; + } + + ctk_widget_set_visible(ctk_ecc->detailed_table, any_detailed_info); + ctk_widget_set_visible(ctk_ecc->summary_table, !any_detailed_info); +} + + + +/* * update_ecc_info() - update ECC status and configuration */ @@ -167,6 +312,8 @@ int64_t val; gboolean status; ReturnStatus ret; + unsigned char *cdata; + int *counts, len; if (!ctk_ecc->ecc_config_supported && !ctk_ecc->ecc_enabled ) { @@ -201,7 +348,18 @@ /* Query ECC Errors */ - if (ctk_ecc->sbit_error) { + /* Detailed Single Bit Volatile */ + counts = NULL; + cdata = NULL; + ret = NvCtrlGetBinaryAttribute(ctrl_target, 0, + NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_SINGLE_BIT, + &cdata, &len); + if (ret == NvCtrlSuccess) { + counts = (int *)cdata; + } + update_detailed_widgets(ctk_ecc->single_errors, 1, counts); + + if (!counts && ctk_ecc->sbit_error) { ret = NvCtrlGetAttribute64(ctrl_target, NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS, &val); @@ -210,8 +368,21 @@ } set_label_value(ctk_ecc->sbit_error, val); } + nvfree(cdata); + + /* Detailed Double Bit Volatile */ + counts = NULL; + cdata = NULL; + ret = NvCtrlGetBinaryAttribute(ctrl_target, 0, + NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_DOUBLE_BIT, + &cdata, &len); + if (ret == NvCtrlSuccess) { + counts = (int *)cdata; + } + + update_detailed_widgets(ctk_ecc->double_errors, 1, counts); - if (ctk_ecc->dbit_error) { + if (!counts && ctk_ecc->dbit_error) { ret = NvCtrlGetAttribute64(ctrl_target, NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS, &val); @@ -220,8 +391,21 @@ } set_label_value(ctk_ecc->dbit_error, val); } + nvfree(cdata); - if (ctk_ecc->aggregate_sbit_error) { + /* Detailed Single Bit Aggregate */ + counts = NULL; + cdata = NULL; + ret = NvCtrlGetBinaryAttribute(ctrl_target, 0, + NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_SINGLE_BIT_AGGREGATE, + &cdata, &len); + if (ret == NvCtrlSuccess) { + counts = (int *)cdata; + } + + update_detailed_widgets(ctk_ecc->single_errors, 0, counts); + + if (!counts && ctk_ecc->aggregate_sbit_error) { ret = NvCtrlGetAttribute64(ctrl_target, NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS, &val); @@ -230,8 +414,21 @@ } set_label_value(ctk_ecc->aggregate_sbit_error, val); } + nvfree(cdata); - if (ctk_ecc->aggregate_dbit_error) { + /* Detailed Double Bit Aggregate */ + counts = NULL; + cdata = NULL; + ret = NvCtrlGetBinaryAttribute(ctrl_target, 0, + NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_DOUBLE_BIT_AGGREGATE, + &cdata, &len); + if (ret == NvCtrlSuccess) { + counts = (int *)cdata; + } + + update_detailed_widgets(ctk_ecc->double_errors, 0, counts); + + if (!counts && ctk_ecc->aggregate_dbit_error) { ret = NvCtrlGetAttribute64(ctrl_target, NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS, &val); @@ -240,6 +437,9 @@ } set_label_value(ctk_ecc->aggregate_dbit_error, val); } + nvfree(cdata); + + hide_unavailable_rows(ctk_ecc); return TRUE; } /* update_ecc_info() */ @@ -480,6 +680,99 @@ +/* + * pack_detailed_widgets() - helper function to create a row for detailed ECC + * data. + */ + +static void pack_detailed_widgets(CtkEcc *ctk_ecc, gboolean single, + int row, int loc) +{ + CtkConfig *ctk_config = ctk_ecc->ctk_config; + GtkWidget *widget_err = NULL; + GtkWidget *widget_mem = NULL; + int xpad = 12, ypad = 2; + + widget_mem = GTK_WIDGET(gtk_label_new(memory_location_label(loc, 0))); + if (single) { + widget_err = GTK_WIDGET(gtk_label_new("Single Bit")); + ctk_ecc->single_errors[loc].err_type = widget_err; + ctk_ecc->single_errors[loc].mem_type = widget_mem; + } else { + widget_err = GTK_WIDGET(gtk_label_new("Double Bit")); + ctk_ecc->double_errors[loc].err_type = widget_err; + ctk_ecc->double_errors[loc].mem_type = widget_mem; + } + + ctk_widget_set_halign_left(widget_err); + ctk_widget_set_halign_left(widget_mem); + + gtk_table_attach(GTK_TABLE(ctk_ecc->detailed_table), widget_err, 0, 1, + row, row + 1, GTK_FILL, GTK_FILL, xpad, ypad); + + gtk_table_attach(GTK_TABLE(ctk_ecc->detailed_table), widget_mem, 1, 2, + row, row + 1, GTK_FILL, GTK_FILL, xpad, ypad); + + if (single) { + ctk_config_set_tooltip(ctk_config, + ctk_ecc->single_errors[loc].vol_count, + __detailed_sbit_error_help); + ctk_config_set_tooltip(ctk_config, + ctk_ecc->single_errors[loc].agg_count, + __detailed_aggregate_sbit_error_help); + gtk_table_attach(GTK_TABLE(ctk_ecc->detailed_table), + ctk_ecc->single_errors[loc].vol_count, + 2, 3, row, row + 1, GTK_SHRINK, GTK_SHRINK, + xpad, ypad); + gtk_table_attach(GTK_TABLE(ctk_ecc->detailed_table), + ctk_ecc->single_errors[loc].agg_count, + 3, 4, row, row + 1, GTK_SHRINK, GTK_SHRINK, + xpad, ypad); + } else { + ctk_config_set_tooltip(ctk_config, + ctk_ecc->double_errors[loc].vol_count, + __detailed_dbit_error_help); + ctk_config_set_tooltip(ctk_config, + ctk_ecc->double_errors[loc].agg_count, + __detailed_aggregate_dbit_error_help); + gtk_table_attach(GTK_TABLE(ctk_ecc->detailed_table), + ctk_ecc->double_errors[loc].vol_count, + 2, 3, row, row + 1, GTK_SHRINK, GTK_SHRINK, + xpad, ypad); + gtk_table_attach(GTK_TABLE(ctk_ecc->detailed_table), + ctk_ecc->double_errors[loc].agg_count, + 3, 4, row, row + 1, GTK_SHRINK, GTK_SHRINK, + xpad, ypad); + } +} + + + +/* + * update_detailed_label_for_values() - Sets the label names for the + * detailed memory location labels. This need to be run after the first + * query for values so that it can propery set the labels for the + * memory locations available. + */ +static void update_detailed_label_for_values(CtkEcc *ctk_ecc) +{ + const char *loc_str; + + loc_str = memory_location_label(NVML_MEMORY_LOCATION_DRAM, + ctk_ecc->single_errors[NVML_MEMORY_LOCATION_SRAM].vol_count_value); + gtk_label_set_text( + GTK_LABEL(ctk_ecc->single_errors[NVML_MEMORY_LOCATION_DRAM].mem_type), + loc_str); + + loc_str = memory_location_label(NVML_MEMORY_LOCATION_DRAM, + ctk_ecc->double_errors[NVML_MEMORY_LOCATION_SRAM].vol_count_value); + gtk_label_set_text( + GTK_LABEL(ctk_ecc->double_errors[NVML_MEMORY_LOCATION_DRAM].mem_type), + loc_str); +} + + + GtkWidget* ctk_ecc_new(CtrlTarget *ctrl_target, CtkConfig *ctk_config, CtkEvent *ctk_event) @@ -502,6 +795,8 @@ ReturnStatus ret; gchar *ecc_enabled_string; gchar *str = NULL; + int loc; + gint xpad = 12, ypad = 2; /* make sure we have a handle */ @@ -635,34 +930,41 @@ hseparator = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); - table = gtk_table_new(1, 2, FALSE); - gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), 3); - gtk_table_set_col_spacings(GTK_TABLE(table), 15); - gtk_container_set_border_width(GTK_CONTAINER(table), 5); - /* ECC Status */ hbox2 = gtk_hbox_new(FALSE, 0); - gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, row, row+1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 5); label = gtk_label_new("ECC:"); gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 5); eventbox = gtk_event_box_new(); - gtk_table_attach(GTK_TABLE(table), eventbox, 1, 2, row, row+1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + gtk_box_pack_start(GTK_BOX(hbox2), eventbox, FALSE, FALSE, 5); label = gtk_label_new(ecc_enabled_string); gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); gtk_container_add(GTK_CONTAINER(eventbox), label); ctk_config_set_tooltip(ctk_config, eventbox, __ecc_status_help); ctk_ecc->status = label; - - row += 3; - + + /* Add ECC Errors */ + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new("ECC Errors"); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + + hseparator = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); + + row = 0; + table = gtk_table_new(1, 2, FALSE); + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), 3); + gtk_table_set_col_spacings(GTK_TABLE(table), 15); + gtk_container_set_border_width(GTK_CONTAINER(table), 5); + if (sbit_error_available && dbit_error_available) { ctk_ecc->sbit_error = @@ -690,7 +992,79 @@ "Aggregate Double-bit ECC Errors:", aggregate_dbit_error, row, ecc_enabled); } - + + ctk_ecc->summary_table = table; + + /* + * Create the structures needed for the Detailed ECC information table. + */ + + /* Initialize the widgets for the Detailed ECC counts */ + for (loc = NVML_MEMORY_LOCATION_L1_CACHE; + loc < NVML_MEMORY_LOCATION_COUNT; + loc++) { + ctk_ecc->single_errors[loc].vol_count = + GTK_WIDGET(gtk_label_new("N/A")); + ctk_ecc->single_errors[loc].agg_count = + GTK_WIDGET(gtk_label_new("N/A")); + ctk_ecc->double_errors[loc].vol_count = + GTK_WIDGET(gtk_label_new("N/A")); + ctk_ecc->double_errors[loc].agg_count = + GTK_WIDGET(gtk_label_new("N/A")); + } + + /* Create the detailed ECC table. Headers, labels, and pack the widgets */ + ctk_ecc->detailed_table = gtk_table_new(5, 4, FALSE); + + /* Header row */ + row = 0; + gtk_table_attach(GTK_TABLE(ctk_ecc->detailed_table), + GTK_WIDGET(gtk_label_new("Error Type")), + 0, 1, row, row + 1, GTK_FILL, GTK_FILL, xpad, ypad); + gtk_table_attach(GTK_TABLE(ctk_ecc->detailed_table), + GTK_WIDGET(gtk_label_new("Memory Type")), + 1, 2, row, row + 1, GTK_FILL, GTK_FILL, xpad, ypad); + gtk_table_attach(GTK_TABLE(ctk_ecc->detailed_table), + GTK_WIDGET(gtk_label_new("Volatile")), + 2, 3, row, row + 1, GTK_SHRINK, GTK_SHRINK, xpad, ypad); + gtk_table_attach(GTK_TABLE(ctk_ecc->detailed_table), + GTK_WIDGET(gtk_label_new("Aggregate")), + 3, 4, row, row + 1, GTK_SHRINK, GTK_SHRINK, xpad, ypad); + + /* Start of the data rows, add the single bit error rows first */ + + row = 1; + + /* Single Bit */; + pack_detailed_widgets(ctk_ecc, TRUE, row++, + NVML_MEMORY_LOCATION_DEVICE_MEMORY); + for (loc = NVML_MEMORY_LOCATION_L1_CACHE; + loc < NVML_MEMORY_LOCATION_COUNT; + loc++, row++) { + if (loc == NVML_MEMORY_LOCATION_DEVICE_MEMORY) { + continue; + } + pack_detailed_widgets(ctk_ecc, TRUE, row, loc); + } + + /* Double Bit */ + pack_detailed_widgets(ctk_ecc, FALSE, row++, + NVML_MEMORY_LOCATION_DEVICE_MEMORY); + for (loc = NVML_MEMORY_LOCATION_L1_CACHE; + loc < NVML_MEMORY_LOCATION_COUNT; + loc++, row++) { + if (loc == NVML_MEMORY_LOCATION_DEVICE_MEMORY) { + continue; + } + pack_detailed_widgets(ctk_ecc, FALSE, row, loc); + } + + gtk_widget_set_sensitive(ctk_ecc->detailed_table, ecc_enabled); + + gtk_box_pack_start(GTK_BOX(vbox), ctk_ecc->detailed_table, + FALSE, FALSE, 0); + + /* ECC configuration settings */ hbox = gtk_hbox_new(FALSE, 0); @@ -783,6 +1157,7 @@ gtk_widget_show_all(GTK_WIDGET(ctk_ecc)); update_ecc_info(ctk_ecc); + update_detailed_label_for_values(ctk_ecc); return GTK_WIDGET(ctk_ecc); } diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkecc.h nvidia-settings-510.47.03/src/gtk+-2.x/ctkecc.h --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkecc.h 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkecc.h 2022-01-24 23:51:09.000000000 +0000 @@ -22,6 +22,7 @@ #include "ctkevent.h" #include "ctkconfig.h" +#include "nvml.h" G_BEGIN_DECLS @@ -46,6 +47,16 @@ typedef struct _CtkEcc CtkEcc; typedef struct _CtkEccClass CtkEccClass; +typedef struct _CtkEccDetailedTableRow +{ + GtkWidget *err_type; + GtkWidget *mem_type; + GtkWidget *vol_count; + GtkWidget *agg_count; + int vol_count_value; + int agg_count_value; +} CtkEccDetailedTableRow; + struct _CtkEcc { GtkVBox parent; @@ -62,6 +73,7 @@ GtkWidget* clear_aggregate_button; GtkWidget* reset_default_config_button; GtkWidget* configuration_status; + GtkWidget* summary_table; gboolean ecc_enabled; gboolean ecc_configured; @@ -73,6 +85,9 @@ gboolean ecc_config_supported; gboolean ecc_default_status; + GtkWidget* detailed_table; + CtkEccDetailedTableRow single_errors[NVML_MEMORY_LOCATION_COUNT]; + CtkEccDetailedTableRow double_errors[NVML_MEMORY_LOCATION_COUNT]; }; struct _CtkEccClass diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkedid.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkedid.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkedid.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkedid.c 2022-01-24 23:51:09.000000000 +0000 @@ -178,7 +178,7 @@ if (!filename) { goto done; } - strncpy(filename, ctk_edid->filename, len); + memcpy(filename, ctk_edid->filename, len + 1); /* * It is possible that filename is entered without any extension, diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkevent.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkevent.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkevent.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkevent.c 2022-01-24 23:51:09.000000000 +0000 @@ -39,7 +39,7 @@ #include "NVCtrlLib.h" #include "msg.h" -static void ctk_event_class_init(CtkEventClass *ctk_event_class); +static void ctk_event_class_init(CtkEventClass *ctk_event_class, gpointer); static gboolean ctk_event_prepare(GSource *, gint *); static gboolean ctk_event_check(GSource *); @@ -101,7 +101,8 @@ } /* ctk_event_get_type() */ -static void ctk_event_class_init(CtkEventClass *ctk_event_class) +static void ctk_event_class_init(CtkEventClass *ctk_event_class, + gpointer class_data) { gint i; @@ -242,7 +243,6 @@ 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_GPU_CURRENT_PROCESSOR_CLOCK_FREQS); 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); @@ -262,8 +262,6 @@ MAKE_SIGNAL(NV_CTRL_FRAMELOCK_DISPLAY_CONFIG); MAKE_SIGNAL(NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY); MAKE_SIGNAL(NV_CTRL_USED_DEDICATED_GPU_MEMORY); - MAKE_SIGNAL(NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE); - MAKE_SIGNAL(NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT); MAKE_SIGNAL(NV_CTRL_DPY_HDMI_3D); MAKE_SIGNAL(NV_CTRL_BASE_MOSAIC); MAKE_SIGNAL(NV_CTRL_MULTIGPU_PRIMARY_POSSIBLE); @@ -296,6 +294,7 @@ MAKE_SIGNAL(NV_CTRL_DISPLAY_VRR_MIN_REFRESH_RATE); MAKE_SIGNAL(NV_CTRL_DISPLAY_VRR_ENABLED); MAKE_SIGNAL(NV_CTRL_PLATFORM_POWER_MODE); + MAKE_SIGNAL(NV_CTRL_MUX_AUTO_SWITCH); #undef MAKE_SIGNAL /* @@ -305,7 +304,7 @@ * knows about. */ -#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_PLATFORM_CURRENT_POWER_MODE +#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_DYNAMIC_BOOST_SUPPORT #warning "There are attributes that do not emit signals!" #endif @@ -350,9 +349,10 @@ MAKE_STRING_SIGNAL(NV_CTRL_STRING_GPU_UTILIZATION); MAKE_STRING_SIGNAL(NV_CTRL_STRING_MULTIGPU_MODE); MAKE_STRING_SIGNAL(NV_CTRL_STRING_PRIME_OUTPUTS_DATA); + MAKE_STRING_SIGNAL(NV_CTRL_STRING_MUX_STATE); #undef MAKE_STRING_SIGNAL -#if NV_CTRL_STRING_LAST_ATTRIBUTE != NV_CTRL_STRING_DISPLAY_NAME_CONNECTOR +#if NV_CTRL_STRING_LAST_ATTRIBUTE != NV_CTRL_STRING_MUX_STATE #warning "There are attributes that do not emit signals!" #endif @@ -385,7 +385,8 @@ MAKE_BINARY_SIGNAL(NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU); #undef MAKE_BINARY_SIGNAL -#if NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE != NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU +#if NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE != \ + NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_DOUBLE_BIT_AGGREGATE #warning "There are attributes that do not emit signals!" #endif diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkframelock.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkframelock.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkframelock.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkframelock.c 2022-01-24 23:51:09.000000000 +0000 @@ -4618,7 +4618,8 @@ * */ static void ctk_framelock_class_init( - CtkFramelockClass *ctk_framelock_class + CtkFramelockClass *ctk_framelock_class, + gpointer class_data ) { parent_class = g_type_class_peek_parent(ctk_framelock_class); diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkgauge.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkgauge.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkgauge.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkgauge.c 2022-01-24 23:51:09.000000000 +0000 @@ -27,7 +27,7 @@ #define REQUESTED_HEIGHT 86 static void -ctk_gauge_class_init (CtkGaugeClass *); +ctk_gauge_class_init (CtkGaugeClass *, gpointer); static void ctk_gauge_finalize (GObject *); @@ -95,7 +95,8 @@ } static void ctk_gauge_class_init( - CtkGaugeClass *ctk_gauge_class + CtkGaugeClass *ctk_gauge_class, + gpointer class_data ) { GObjectClass *gobject_class; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkglwidget.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkglwidget.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkglwidget.c 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkglwidget.c 2022-01-24 23:51:09.000000000 +0000 @@ -202,7 +202,8 @@ assert(!"unimplemented"); } -static void ctk_glwidget_class_init(CtkGLWidgetClass *klass) +static void ctk_glwidget_class_init(CtkGLWidgetClass *klass, + gpointer class_data) { GtkWidgetClass *widget_class; GObjectClass *gobject_class = G_OBJECT_CLASS(klass); diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkglx.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkglx.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkglx.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkglx.c 2022-01-24 23:51:09.000000000 +0000 @@ -1257,7 +1257,7 @@ ctk_help_title(b, &i, "Graphics Information Help"); ctk_help_para(b, &i, - "This page in the NVIDIA X Server Control Panel describes " + "This page in the NVIDIA Settings Control Panel describes " "information about graphics libraries available on this X " "screen." ); diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkgpu.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkgpu.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkgpu.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkgpu.c 2022-01-24 23:51:09.000000000 +0000 @@ -96,7 +96,7 @@ gchar *bus_type_str, *bus_rate, *pcie_gen; bus_type = 0xffffffff; - bus_type_str = "Unknown"; + bus_type_str = NULL; ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_BUS_TYPE, &bus_type); if (ret == NvCtrlSuccess) { if (bus_type == NV_CTRL_BUS_TYPE_AGP) @@ -107,6 +107,8 @@ bus_type_str = "PCI Express"; else if (bus_type == NV_CTRL_BUS_TYPE_INTEGRATED) bus_type_str = "Integrated"; + else + bus_type_str = "Unknown"; } /* NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH */ @@ -228,8 +230,8 @@ ReturnStatus ret; gchar *screens; - gchar *displays; - gchar *tmp_str; + gchar *displays = NULL; + gchar *tmp_str = NULL; gchar *gpu_cores; gchar *memory_interface; gchar *bus = NULL; @@ -245,6 +247,7 @@ int total_rows = 21; int gpu_memory; utilizationEntry entry; + gboolean resizable_bar; /* @@ -325,6 +328,14 @@ gpu_cores = g_strdup_printf("%d", tmp); } + /* NV_CTRL_RESIZABLE_BAR */ + ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_RESIZABLE_BAR, &tmp); + if (ret != NvCtrlSuccess) { + resizable_bar = FALSE; + } else { + resizable_bar = tmp; + } + /* NV_CTRL_GPU_MEMORY_BUS_WIDTH */ ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_MEMORY_BUS_WIDTH, &tmp); @@ -426,6 +437,7 @@ ctk_gpu->gpu_cores = (gpu_cores != NULL) ? 1 : 0; ctk_gpu->gpu_uuid = (gpu_uuid != NULL) ? 1 : 0; ctk_gpu->memory_interface = (memory_interface != NULL) ? 1 : 0; + ctk_gpu->resizable_bar = resizable_bar; ctk_gpu->ctk_config = ctk_config; ctk_gpu->ctk_event = ctk_event; ctk_gpu->pcie_gen_queriable = FALSE; @@ -498,9 +510,11 @@ 0, 0.5, "VBIOS Version:", 0, 0.5, vbios_version); } - add_table_row(table, row++, - 0, 0.5, "Total Memory:", - 0, 0.5, video_ram); + if (video_ram) { + add_table_row(table, row++, + 0, 0.5, "Total Memory:", + 0, 0.5, video_ram); + } add_table_row(table, row++, 0, 0.5, "Total Dedicated Memory:", 0, 0.5, gpu_memory_text); @@ -508,6 +522,12 @@ add_table_row(table, row++, 0, 0.5, "Used Dedicated Memory:", 0, 0.5, NULL); + if (ctk_gpu->resizable_bar) { + gtk_table_resize(GTK_TABLE(table), ++total_rows, 2); + add_table_row(table, row++, + 0, 0.5, "Resizable BAR:", + 0, 0.5, "Yes"); + } if ( ctk_gpu->memory_interface ) { gtk_table_resize(GTK_TABLE(table), ++total_rows, 2); add_table_row(table, row++, @@ -532,9 +552,11 @@ /* spacing */ row += 3; - add_table_row(table, row++, - 0, 0.5, "Bus Type:", - 0, 0.5, bus); + if (bus) { + add_table_row(table, row++, + 0, 0.5, "Bus Type:", + 0, 0.5, bus); + } if ( pci_bus_id ) { add_table_row(table, row++, 0, 0.5, "Bus ID:", @@ -564,13 +586,17 @@ add_table_row(table, row++, 0, 0.5, "Maximum PCIe Link Width:", 0, 0.5, link_width_str); - add_table_row(table, row++, - 0, 0.5, "Maximum PCIe Link Speed:", - 0, 0.5, link_speed_str); - ctk_gpu->pcie_utilization_label = + if (link_speed_str) { add_table_row(table, row++, - 0, 0.5, "PCIe Bandwidth Utilization:", - 0, 0.5, NULL); + 0, 0.5, "Maximum PCIe Link Speed:", + 0, 0.5, link_speed_str); + } + if (entry.pcie_specified) { + ctk_gpu->pcie_utilization_label = + add_table_row(table, row++, + 0, 0.5, "PCIe Bandwidth Utilization:", + 0, 0.5, NULL); + } g_free(link_speed_str); g_free(link_width_str); @@ -579,19 +605,22 @@ } update_gpu_usage(ctk_gpu); - /* spacing */ - row += 3; - add_table_row(table, row++, - 0, 0, "X Screens:", - 0, 0, screens); - /* spacing */ - displays = make_display_device_list(ctrl_target); - row += 3; - ctk_gpu->displays = - add_table_row(table, row, - 0, 0, "Display Devices:", - 0, 0, displays); + if (ctrl_target->system->has_nv_control) { + /* spacing */ + row += 3; + add_table_row(table, row++, + 0, 0, "X Screens:", + 0, 0, screens); + /* spacing */ + displays = make_display_device_list(ctrl_target); + + row += 3; + ctk_gpu->displays = + add_table_row(table, row, + 0, 0, "Display Devices:", + 0, 0, displays); + } free(product_name); free(vbios_version); @@ -641,7 +670,7 @@ ctk_help_title(b, &i, "Graphics Card Information Help"); ctk_help_para(b, &i, "This page in the NVIDIA " - "X Server Control Panel describes basic " + "Settings Control Panel describes basic " "information about the Graphics Processing Unit " "(GPU)."); @@ -680,6 +709,12 @@ ctk_help_para(b, &i, "This is the amount of dedicated memory used " "by your GPU."); + if (ctk_gpu->resizable_bar) { + ctk_help_heading(b, &i, "Resizable BAR"); + ctk_help_para(b, &i, "This indicates whether Resizable BAR may be " + "available on supported systems."); + } + if (ctk_gpu->memory_interface) { ctk_help_heading(b, &i, "Memory Interface"); ctk_help_para(b, &i, "This is the bus bandwidth of the GPU's " diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkgpu.h nvidia-settings-510.47.03/src/gtk+-2.x/ctkgpu.h --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkgpu.h 2021-07-07 22:48:19.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkgpu.h 2022-01-24 23:51:09.000000000 +0000 @@ -67,6 +67,7 @@ gint gpu_cores; gint gpu_uuid; gint memory_interface; + gboolean resizable_bar; gboolean pcie_gen_queriable; }; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkgridlicense.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkgridlicense.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkgridlicense.c 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkgridlicense.c 2022-01-24 23:51:09.000000000 +0000 @@ -2,7 +2,7 @@ * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix * and Linux systems. * - * Copyright (C) 2020 NVIDIA Corporation. + * Copyright (C) 2021 NVIDIA Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -49,10 +49,12 @@ static const char * __manage_grid_licenses_help = "Use the Manage License page to obtain licenses " -"for NVIDIA vGPU or NVIDIA RTX Virtual Workstation on supported Tesla products."; +"for NVIDIA vGPU or NVIDIA RTX Virtual Workstation on supported Tesla products. " +"The current license status is displayed on the page. If licensed, the license expiry information in GMT time zone is shown."; static const char * __manage_grid_licenses_vcompute_help = "Use the Manage License page to obtain licenses " -"for NVIDIA vGPU or NVIDIA RTX Virtual Workstation or NVIDIA Virtual Compute Server on supported Tesla products."; +"for NVIDIA vGPU or NVIDIA RTX Virtual Workstation or NVIDIA Virtual Compute Server on supported Tesla products. " +"The current license status is displayed on the page. If licensed, the license expiry information in GMT time zone is shown."; static const char * __grid_virtual_workstation_help = "Select this option to enable NVIDIA RTX Virtual Workstation license."; static const char * __grid_virtual_compute_help = @@ -84,7 +86,7 @@ "Clicking the Cancel button sets the text in all textboxes from the gridd.conf file. " "Any changes you have done will be lost."; -typedef struct +typedef struct { void *dbusHandle; typeof(dbus_bus_get) *getDbus; @@ -116,7 +118,7 @@ static void apply_clicked(GtkWidget *widget, gpointer user_data); static void cancel_clicked(GtkWidget *widget, gpointer user_data); static void ctk_manage_grid_license_finalize(GObject *object); -static void ctk_manage_grid_license_class_init(CtkManageGridLicenseClass *); +static void ctk_manage_grid_license_class_init(CtkManageGridLicenseClass *, gpointer); static void dbusClose(DbusData *dbusData); static gboolean checkConfigfile(gboolean *writable); static gboolean disallow_whitespace(GtkWidget *widget, GdkEvent *event, gpointer user_data); @@ -127,7 +129,7 @@ static void get_licensable_feature_information(gpointer user_data); static gboolean is_feature_supported(gpointer user_data, int featureType); static gboolean is_restart_required(gpointer user_data); -static gboolean queryEnabledFeatureCode = TRUE; +static gboolean bQueryGridLicenseInfo = TRUE; int64_t enabledFeatureCode = NV_GRID_LICENSE_FEATURE_TYPE_VAPP; GType ctk_manage_grid_license_get_type(void) @@ -419,8 +421,7 @@ itemIsPresent); } - /* Append any items not updated in the above loop. */ - + /* Append any items not updated in the above loop. */ for (i = 0; i < ARRAY_LEN(configParamsList); i++) { if (itemIsPresent[i]) { @@ -630,7 +631,8 @@ } -static void ctk_manage_grid_license_class_init(CtkManageGridLicenseClass *ctk_object_class) +static void ctk_manage_grid_license_class_init(CtkManageGridLicenseClass *ctk_object_class, + gpointer class_data) { GObjectClass *gobject_class = (GObjectClass *)ctk_object_class; gobject_class->finalize = ctk_manage_grid_license_finalize; @@ -786,8 +788,8 @@ gboolean ret = TRUE; char licenseStatusMsgTmp[GRID_MESSAGE_MAX_BUFFER_SIZE] = {0}; - int licenseState = NV_GRID_UNLICENSED; - int griddFeatureType = ctk_manage_grid_license->feature_type; + int licenseState = NV_GRID_UNLICENSED; + int griddFeatureType = ctk_manage_grid_license->feature_type; /* Send license state and feature type request */ if ((!(send_message_to_gridd(ctk_manage_grid_license, LICENSE_STATE_REQUEST, @@ -835,7 +837,7 @@ ctk_manage_grid_license->gridd_feature_type = griddFeatureType; if (licenseState == NV_GRID_UNLICENSED) { - queryEnabledFeatureCode = TRUE; + bQueryGridLicenseInfo = TRUE; switch (ctk_manage_grid_license->feature_type) { case NV_GRID_LICENSE_FEATURE_TYPE_VAPP: ctk_manage_grid_license->licenseStatus = NV_GRID_UNLICENSED_VAPP; @@ -893,9 +895,14 @@ default: break; } - if (queryEnabledFeatureCode == TRUE) { + + if (ctk_manage_grid_license->prevLicenseState == NV_GRID_LICENSE_RENEWING && licenseState == NV_GRID_LICENSED) { + bQueryGridLicenseInfo = TRUE; + } + + if (bQueryGridLicenseInfo == TRUE) { get_licensable_feature_information(ctk_manage_grid_license); - queryEnabledFeatureCode = FALSE; + bQueryGridLicenseInfo = FALSE; } } else if (licenseState == NV_GRID_LICENSE_REQUESTING) { @@ -961,7 +968,8 @@ snprintf(licenseStatusMsgTmp, sizeof(licenseStatusMsgTmp), "Your system is currently configured for %s.", NVIDIA_VIRTUAL_APPLICATIONS); break; case NV_GRID_LICENSE_STATUS_ACQUIRED: - snprintf(licenseStatusMsgTmp, sizeof(licenseStatusMsgTmp), "Your system is licensed for %s.", ctk_manage_grid_license->productName); + snprintf(licenseStatusMsgTmp, sizeof(licenseStatusMsgTmp), "Your system is licensed for %s, expiring at %s.", + ctk_manage_grid_license->productName, ctk_manage_grid_license->licenseExpiry); break; case NV_GRID_LICENSE_STATUS_REQUESTING: snprintf(licenseStatusMsgTmp, sizeof(licenseStatusMsgTmp), "Acquiring license for %s.", ctk_manage_grid_license->productName); @@ -1010,6 +1018,8 @@ gtk_label_set_text(GTK_LABEL(ctk_manage_grid_license->label_license_state), licenseStatusMsgTmp); + ctk_manage_grid_license->prevLicenseState = licenseState; + return ret; } @@ -1142,12 +1152,19 @@ { if (gridLicensableFeatures->gridLicensableFeatures[i].featureEnabled != 0) { enabledFeatureCode = gridLicensableFeatures->gridLicensableFeatures[i].featureCode; - // Save product name of enabled feature strncpy(ctk_manage_grid_license->productName, - gridLicensableFeatures->gridLicensableFeatures[i].productName, - sizeof(ctk_manage_grid_license->productName) - 1); + gridLicensableFeatures->gridLicensableFeatures[i].productName, + sizeof(ctk_manage_grid_license->productName) - 1); ctk_manage_grid_license->productName[sizeof(ctk_manage_grid_license->productName) - 1] = '\0'; + //Save the license expiry information + snprintf(ctk_manage_grid_license->licenseExpiry, sizeof(ctk_manage_grid_license->licenseExpiry), "%d-%d-%d %d:%d:%d GMT", + gridLicensableFeatures->gridLicensableFeatures[i].licenseExpiry.year, + gridLicensableFeatures->gridLicensableFeatures[i].licenseExpiry.month, + gridLicensableFeatures->gridLicensableFeatures[i].licenseExpiry.day, + gridLicensableFeatures->gridLicensableFeatures[i].licenseExpiry.hour, + gridLicensableFeatures->gridLicensableFeatures[i].licenseExpiry.min, + gridLicensableFeatures->gridLicensableFeatures[i].licenseExpiry.sec); } else if (gridLicensableFeatures->gridLicensableFeatures[i].featureEnabled == 0) { if ((ctk_manage_grid_license->feature_type == gridLicensableFeatures->gridLicensableFeatures[i].featureCode) && @@ -1606,12 +1623,10 @@ (strcmp(griddConfig->str[NV_GRIDD_ENABLE_UI], "TRUE") != 0)) { return NULL; } - /* create the CtkManageGridLicense object */ - object = g_object_new(CTK_TYPE_MANAGE_GRID_LICENSE, NULL); - + ctk_manage_grid_license = CTK_MANAGE_GRID_LICENSE(object); ctk_manage_grid_license->ctk_config = ctk_config; ctk_manage_grid_license->license_edition_state = mode; @@ -1621,7 +1636,6 @@ ctk_manage_grid_license->licenseStatus = NV_GRID_UNLICENSED_VGPU; /* set container properties for the CtkManageGridLicense widget */ - gtk_box_set_spacing(GTK_BOX(ctk_manage_grid_license), 5); // Set feature type based on user configured parameter or virtualization mode @@ -1633,7 +1647,6 @@ get_licensable_feature_information(ctk_manage_grid_license); /* banner */ - banner = ctk_banner_image_new(BANNER_ARTWORK_SERVER_LICENSING); gtk_box_pack_start(GTK_BOX(object), banner, FALSE, FALSE, 0); @@ -1756,7 +1769,6 @@ /* Primary License Server Address */ - label = gtk_label_new("Primary Server:"); ctk_manage_grid_license->txt_server_address = gtk_entry_new(); hbox = gtk_hbox_new(FALSE, 0); @@ -1993,6 +2005,12 @@ ctk_config_start_timer(ctk_manage_grid_license->ctk_config, (GSourceFunc) update_manage_grid_license_state_info, (gpointer) ctk_manage_grid_license); + + /* Query licensable feature info if switched to 'Manage License' page + from any other page to update license expiry information */ + if (ctk_manage_grid_license->licenseStatus == NV_GRID_LICENSE_STATUS_ACQUIRED) { + get_licensable_feature_information(ctk_manage_grid_license); + } } void ctk_manage_grid_license_stop_timer(GtkWidget *widget) diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkgridlicense.h nvidia-settings-510.47.03/src/gtk+-2.x/ctkgridlicense.h --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkgridlicense.h 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkgridlicense.h 2022-01-24 23:51:09.000000000 +0000 @@ -2,7 +2,7 @@ * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix * and Linux systems. * - * Copyright (C) 2020 NVIDIA Corporation. + * Copyright (C) 2021 NVIDIA Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -43,42 +43,42 @@ #define GRID_MESSAGE_MAX_BUFFER_SIZE 512 #define NVIDIA_VIRTUAL_APPLICATIONS "NVIDIA Virtual Applications" -typedef struct _CtkManageGridLicense CtkManageGridLicense; -typedef struct _CtkManageGridLicenseClass CtkManageGridLicenseClass; - -typedef struct _DbusData DbusData; +typedef struct _CtkManageGridLicense CtkManageGridLicense; +typedef struct _CtkManageGridLicenseClass CtkManageGridLicenseClass; +typedef struct _DbusData DbusData; struct _CtkManageGridLicense { - GtkVBox parent; + GtkVBox parent; - CtkConfig *ctk_config; + CtkConfig *ctk_config; - GtkWidget* txt_secondary_server_port; - GtkWidget* txt_secondary_server_address; - GtkWidget* txt_server_port; - GtkWidget* txt_server_address; - GtkWidget* label_license_state; - GtkWidget* btn_apply; - GtkWidget* radio_btn_vapp; - GtkWidget* radio_btn_vws; - GtkWidget* radio_btn_vcompute; - GtkWidget* btn_cancel; - GtkWidget* box_server_info; - - DbusData *dbusData; - CtrlTarget *target; - - gint license_edition_state; - gint feature_type; // Feature type from UI/vGPU license config file. - int gridd_feature_type; // Feature type fetched from nvidia-gridd. - char productName[GRID_LICENSE_INFO_MAX_LENGTH]; // vGPU product name fetched from nvml corresponding to the licensed/applied feature - char productNamevWS[GRID_LICENSE_INFO_MAX_LENGTH]; // vGPU product name fetched from nvml corresponding to the feature type '2' - char productNamevCompute[GRID_LICENSE_INFO_MAX_LENGTH]; // vGPU product name fetched from nvml corresponding to the feature type '4' - - int licenseStatus; // Current license status to be displayed on UI - gboolean isvComputeSupported; // Check if 'NVIDIA Virtual Compute Server' feature is supported - gboolean isvWSSupported; // Check if 'NVIDIA RTX Virtual Workstation' feature is supported + GtkWidget* txt_secondary_server_port; + GtkWidget* txt_secondary_server_address; + GtkWidget* txt_server_port; + GtkWidget* txt_server_address; + GtkWidget* label_license_state; + GtkWidget* btn_apply; + GtkWidget* radio_btn_vapp; + GtkWidget* radio_btn_vws; + GtkWidget* radio_btn_vcompute; + GtkWidget* btn_cancel; + GtkWidget* box_server_info; + + DbusData *dbusData; + CtrlTarget *target; + + gint license_edition_state; + gint feature_type; // Feature type from UI/vGPU license config file + int gridd_feature_type; // Feature type fetched from nvidia-gridd + char productName[GRID_LICENSE_INFO_MAX_LENGTH]; // vGPU product name fetched from nvml corresponding to the licensed/applied feature + char productNamevWS[GRID_LICENSE_INFO_MAX_LENGTH]; // vGPU product name fetched from nvml corresponding to the feature type '2' + char productNamevCompute[GRID_LICENSE_INFO_MAX_LENGTH]; // vGPU product name fetched from nvml corresponding to the feature type '4' + int licenseStatus; // Current license status to be displayed on UI + int prevLicenseState; // The previous license state + gboolean isvComputeSupported; // Check if 'NVIDIA Virtual Compute Server' feature is supported + gboolean isvWSSupported; // Check if 'NVIDIA RTX Virtual Workstation' feature is supported + char licenseExpiry[GRID_LICENSE_INFO_MAX_LENGTH]; // License expiry timestamp }; /* diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkhelp.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkhelp.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkhelp.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkhelp.c 2022-01-24 23:51:09.000000000 +0000 @@ -82,7 +82,7 @@ ctk_help->toggle_button = toggle_button; gtk_window_set_title(GTK_WINDOW(ctk_help), - "NVIDIA X Server Settings Help"); + "NVIDIA Settings Help"); gtk_window_set_default_size(GTK_WINDOW(ctk_help), -1, 400); @@ -203,7 +203,7 @@ gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0); gtk_text_buffer_insert_with_tags_by_name - (buffer, &iter, "\nNVIDIA X Server Settings Help", -1, + (buffer, &iter, "\nNVIDIA Settings Help", -1, CTK_HELP_TITLE_TAG, NULL); gtk_text_buffer_insert(buffer, &iter, "\n\nThere is no help available " diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkimagesliders.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkimagesliders.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkimagesliders.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkimagesliders.c 2022-01-24 23:51:09.000000000 +0000 @@ -37,7 +37,7 @@ "alters the level of Image Sharpening for this display device."; -static void ctk_image_sliders_class_init(CtkImageSliders *ctk_object_class); +static void ctk_image_sliders_class_init(CtkImageSliders *ctk_object_class, gpointer); static void ctk_image_sliders_finalize(GObject *object); static GtkWidget * add_scale(CtkConfig *ctk_config, @@ -85,7 +85,8 @@ } static void ctk_image_sliders_class_init( - CtkImageSliders *ctk_object_class + CtkImageSliders *ctk_object_class, + gpointer class_data ) { GObjectClass *gobject_class = (GObjectClass *)ctk_object_class; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkopengl.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkopengl.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkopengl.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkopengl.c 2022-01-24 23:51:09.000000000 +0000 @@ -114,7 +114,7 @@ static gint map_nvctrl_value_to_table(CtkOpenGL *ctk_opengl, gint val); static void -ctk_opengl_new_class_init(CtkOpenGLClass *ctk_object_class); +ctk_opengl_new_class_init(CtkOpenGLClass *ctk_object_class, gpointer); static void ctk_opengl_new_finalize(GObject *object); @@ -230,8 +230,9 @@ } - static void -ctk_opengl_new_class_init(CtkOpenGLClass *ctk_object_class) +static void +ctk_opengl_new_class_init(CtkOpenGLClass *ctk_object_class, + gpointer class_data) { GObjectClass *gobject_class = (GObjectClass *)ctk_object_class; gobject_class->finalize = ctk_opengl_new_finalize; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkpowermizer.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkpowermizer.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkpowermizer.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkpowermizer.c 2022-01-24 23:51:09.000000000 +0000 @@ -44,12 +44,6 @@ static void update_powermizer_menu_event(GObject *object, gpointer arg1, gpointer user_data); -static void dp_config_button_toggled(GtkWidget *, gpointer); -static void dp_set_config_status(CtkPowermizer *); -static void dp_update_config_status(CtkPowermizer *, gboolean); -static void dp_configuration_update_received(GObject *, CtrlEvent *, gpointer); -static void post_dp_configuration_update(CtkPowermizer *); -static void show_dp_toggle_warning_dlg(CtkPowermizer *ctk_powermizer); static void post_set_attribute_offset_value(CtkPowermizer *ctk_powermizer, gint attribute, gint val); @@ -87,13 +81,10 @@ static const char *__memory_transfer_rate_freq_help = "This indicates the current Memory transfer rate."; -static const char *__processor_clock_freq_help = -"This indicates the current Processor Clock frequency."; - static const char *__performance_levels_table_help = "This indicates the Performance Levels available for the GPU. Each " "performance level is indicated by a Performance Level number, along with " -"the Graphics, Memory and Processor clocks for that level. The currently active " +"the Graphics and Memory clocks for that level. The currently active " "performance level is shown in regular text. All other performance " "levels are shown in gray. Note that multiple performance levels may share " "the same range of available clocks."; @@ -134,13 +125,6 @@ "'Prefer Consistent Performance' hints to the driver to lock to GPU base clocks, " "when possible. "; -static const char *__dp_configuration_button_help = -"CUDA - Double Precision lets you enable " -"increased double-precision calculations in CUDA applications. Available on " -"GPUs with the capability for increased double-precision performance." -" NOTE: Selecting a GPU reduces performance for non-CUDA applications, " -"including games. To increase game performance, disable this checkbox."; - GType ctk_powermizer_get_type(void) { static GType ctk_powermizer_type = 0; @@ -175,8 +159,6 @@ gboolean perf_level_specified; gint nvclock; gboolean nvclock_specified; - gint processorclock; - gboolean processorclock_specified; gint nvclockmin; gboolean nvclockmin_specified; gint nvclockmax; @@ -189,11 +171,6 @@ gint memtransferratemax; gint memtransferrateeditable; gboolean memtransferratemax_specified; - gint processorclockmin; - gboolean processorclockmin_specified; - gint processorclockmax; - gint processorclockeditable; - gboolean processorclockmax_specified; } perfModeEntry, * perfModeEntryPtr; @@ -226,17 +203,6 @@ pEntry->memtransferratemax_specified = TRUE; } else if (!strcasecmp("memtransferrateeditable", token)) { pEntry->memtransferrateeditable = atoi(value); - } else if (!strcasecmp("processorclock", token)) { - pEntry->processorclock = atoi(value); - pEntry->processorclock_specified = TRUE; - } else if (!strcasecmp("processorclockmin", token)) { - pEntry->processorclockmin = atoi(value); - pEntry->processorclockmax_specified = TRUE; - } else if (!strcasecmp("processorclockmax", token)) { - pEntry->processorclockmax = atoi(value); - pEntry->processorclockmax_specified = TRUE; - } else if (!strcasecmp("processorclockeditable", token)) { - pEntry->nvclockeditable = atoi(value); } } @@ -672,9 +638,7 @@ if (!ctk_powermizer->hasDecoupledClock && ((pEntry[index].nvclockmax != pEntry[index].nvclockmin) || (pEntry[index].memtransferratemax != - pEntry[index].memtransferratemin) || - (pEntry[index].processorclockmax != - pEntry[index].processorclockmin))) { + pEntry[index].memtransferratemin))) { ctk_powermizer->hasDecoupledClock = TRUE; } /* Set hasEditablePerfLevel flag to decide editable performance @@ -780,27 +744,6 @@ col_idx += 4; } - if (ctk_powermizer->processor_clock) { - /* Processor clock */ - label = gtk_label_new("Processor Clock"); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_table_attach(GTK_TABLE(table), label, col_idx+1, col_idx+3, 0, 1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - label = gtk_label_new("Min"); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_table_attach(GTK_TABLE(table), label, col_idx+1, col_idx+2, 1, 2, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - label = gtk_label_new("Max"); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_table_attach(GTK_TABLE(table), label, col_idx+2, col_idx+3, 1, 2, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - - /* Vertical separator */ - vsep = gtk_vseparator_new(); - gtk_table_attach(GTK_TABLE(table), vsep, col_idx+3, col_idx+4, - 0, row_idx, - GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0); - } } else { table = gtk_table_new(1, 4, FALSE); @@ -834,13 +777,6 @@ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); col_idx++; } - - if (ctk_powermizer->processor_clock) { - label = gtk_label_new("Processor Clock"); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_table_attach(GTK_TABLE(table), label, col_idx+1, col_idx+2, 0, 1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - } } /* Parse the perf levels and populate the table */ @@ -905,22 +841,6 @@ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); col_idx +=4; } - if (ctk_powermizer->processor_clock) { - g_snprintf(tmp_str, 24, "%d MHz", pEntry[i].processorclockmin); - label = gtk_label_new(tmp_str); - gtk_widget_set_sensitive(label, active); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_table_attach(GTK_TABLE(table), label, col_idx+1, col_idx+2, - row_idx, row_idx+1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - g_snprintf(tmp_str, 24, "%d MHz", pEntry[i].processorclockmax); - label = gtk_label_new(tmp_str); - gtk_widget_set_sensitive(label, active); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_table_attach(GTK_TABLE(table), label, col_idx+2, col_idx+3, - row_idx, row_idx+1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - } row_idx++; } else if ((pEntry[i].perf_level_specified) && (pEntry[i].nvclock_specified)) { @@ -964,15 +884,6 @@ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); col_idx++; } - if (ctk_powermizer->processor_clock) { - g_snprintf(tmp_str, 24, "%d MHz", pEntry[i].processorclock); - label = gtk_label_new(tmp_str); - gtk_widget_set_sensitive(label, active); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_table_attach(GTK_TABLE(table), label, col_idx, col_idx+1, - row_idx, row_idx+1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - } row_idx++; } else { nv_warning_msg("Incomplete Perf Mode (perf=%d, nvclock=%d," @@ -1050,12 +961,6 @@ gtk_label_set_text(GTK_LABEL(ctk_powermizer->memory_transfer_rate), s); g_free(s); } - - if (ctk_powermizer->processor_clock && pEntry.processorclock_specified) { - s = g_strdup_printf("%d Mhz", pEntry.processorclock); - gtk_label_set_text(GTK_LABEL(ctk_powermizer->processor_clock), s); - g_free(s); - } } free(clock_string); @@ -1077,13 +982,15 @@ g_free(s); } - if (ctk_powermizer->pcie_gen_queriable) { + if (ctk_powermizer->link_width) { /* NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH */ s = get_pcie_link_width_string(ctrl_target, NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH); gtk_label_set_text(GTK_LABEL(ctk_powermizer->link_width), s); g_free(s); + } + if (ctk_powermizer->link_speed) { /* NV_CTRL_GPU_PCIE_MAX_LINK_SPEED */ s = get_pcie_link_speed_string(ctrl_target, NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED); @@ -1190,21 +1097,19 @@ GtkWidget *hbox, *hbox2, *vbox, *vbox2, *hsep, *table; GtkWidget *banner, *label; CtkDropDownMenu *menu; - ReturnStatus ret, ret1; - gint attribute; + ReturnStatus ret; gint nvclock_attribute = 0, mem_transfer_rate_attribute = 0; gint val; gint row = 0; gchar *s = NULL; gint tmp; - gboolean processor_clock_available = FALSE; gboolean power_source_available = FALSE; gboolean perf_level_available = FALSE; gboolean gpu_clock_available = FALSE; gboolean mem_transfer_rate_available = FALSE; gboolean adaptive_clock_state_available = FALSE; - gboolean cuda_dp_ui = FALSE; - gboolean pcie_gen_queriable = FALSE; + gboolean pcie_link_width_available = FALSE; + gboolean pcie_link_speed_available = FALSE; CtrlAttributeValidValues valid_modes; char *clock_string = NULL; perfModeEntry pEntry; @@ -1256,23 +1161,27 @@ if (pEntry.memtransferrate_specified) { mem_transfer_rate_available = TRUE; } - if (pEntry.processorclock_specified) { - processor_clock_available = TRUE; - } } free(clock_string); /* NV_CTRL_GPU_PCIE_GENERATION */ - ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_PCIE_GENERATION, &tmp); + ret = NvCtrlGetAttribute(ctrl_target, + NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH, + &tmp); + if (ret == NvCtrlSuccess) { + pcie_link_width_available = TRUE; + } + + ret = NvCtrlGetAttribute(ctrl_target, + NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED, + &tmp); if (ret == NvCtrlSuccess) { - pcie_gen_queriable = TRUE; + pcie_link_speed_available = TRUE; } /* return early if query to attributes fail */ - if (!power_source_available && !perf_level_available && - !adaptive_clock_state_available && !gpu_clock_available && - !processor_clock_available && !pcie_gen_queriable) { + if (!perf_level_available && !gpu_clock_available) { return NULL; } /* create the CtkPowermizer object */ @@ -1282,7 +1191,6 @@ ctk_powermizer = CTK_POWERMIZER(object); ctk_powermizer->ctrl_target = ctrl_target; ctk_powermizer->ctk_config = ctk_config; - ctk_powermizer->pcie_gen_queriable = pcie_gen_queriable; ctk_powermizer->hasDecoupledClock = FALSE; ctk_powermizer->hasEditablePerfLevel = FALSE; ctk_powermizer->editable_performance_levels_unified = FALSE; @@ -1399,24 +1307,6 @@ } else { ctk_powermizer->memory_transfer_rate = NULL; } - /* Processor clock */ - if (processor_clock_available) { - /* spacing */ - row += 3; - ctk_powermizer->processor_clock = - add_table_row_with_help_text(table, ctk_config, - __processor_clock_freq_help, - row++, //row - 0, // column - 0.0f, - 0.5, - "Processor Clock:", - 0.0, - 0.5, - NULL); - } else { - ctk_powermizer->processor_clock = NULL; - } /* Power Source */ if (power_source_available) { /* spacing */ @@ -1435,10 +1325,13 @@ } else { ctk_powermizer->power_source = NULL; } - /* Current PCIe Link Width */ - if (ctk_powermizer->pcie_gen_queriable) { + /* PCIe Gen Info block */ + if (pcie_link_width_available || pcie_link_speed_available) { /* spacing */ row += 3; + } + /* Current PCIe Link Width */ + if (pcie_link_width_available) { ctk_powermizer->link_width = add_table_row_with_help_text(table, ctk_config, __current_pcie_link_width_help, @@ -1451,7 +1344,11 @@ 0.5, NULL); - /* Current PCIe Link Speed */ + } else { + ctk_powermizer->link_width = NULL; + } + /* Current PCIe Link Speed */ + if (pcie_link_speed_available) { ctk_powermizer->link_speed = add_table_row_with_help_text(table, ctk_config, __current_pcie_link_speed_help, @@ -1464,7 +1361,6 @@ 0.5, NULL); } else { - ctk_powermizer->link_width = NULL; ctk_powermizer->link_speed = NULL; } @@ -1622,109 +1518,6 @@ update_powermizer_menu_info(ctk_powermizer); } - /* - * check if CUDA - Double Precision Boost support available. - */ - - ret = NvCtrlGetAttribute(ctrl_target, - NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE, - &val); - if (ret == NvCtrlSuccess) { - attribute = NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE; - cuda_dp_ui = TRUE; - } else { - ret1 = NvCtrlGetAttribute(ctrl_target, - NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT, - &val); - if (ret1 == NvCtrlSuccess) { - attribute = NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT; - cuda_dp_ui = TRUE; - } - } - - if (cuda_dp_ui) { - ctk_powermizer->attribute = attribute; - ctk_powermizer->dp_toggle_warning_dlg_shown = FALSE; - - /* Query CUDA - Double Precision Boost Status */ - - dp_update_config_status(ctk_powermizer, val); - - /* CUDA - Double Precision Boost configuration settings */ - - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("CUDA"); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - hsep = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(hbox), hsep, TRUE, TRUE, 5); - - hbox2 = gtk_hbox_new(FALSE, 0); - ctk_powermizer->configuration_button = - gtk_check_button_new_with_label("CUDA - Double precision"); - gtk_box_pack_start(GTK_BOX(hbox2), - ctk_powermizer->configuration_button, - FALSE, FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(hbox2), 0); - gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON(ctk_powermizer->configuration_button), - ctk_powermizer->dp_enabled); - - /* Packing */ - - table = gtk_table_new(1, 1, FALSE); - gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), 3); - gtk_table_set_col_spacings(GTK_TABLE(table), 15); - gtk_container_set_border_width(GTK_CONTAINER(table), 5); - - gtk_table_attach(GTK_TABLE(table), hbox2, 0, 1, 0, 1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - - if (attribute == NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT) { - GtkWidget *separator; - - gtk_table_resize(GTK_TABLE(table), 1, 3); - /* V-bar */ - hbox2 = gtk_hbox_new(FALSE, 0); - separator = gtk_vseparator_new(); - gtk_box_pack_start(GTK_BOX(hbox2), separator, FALSE, FALSE, 0); - gtk_table_attach(GTK_TABLE(table), hbox2, 1, 2, 0, 1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - - ctk_powermizer->status = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(ctk_powermizer->status), 0.0f, 0.5f); - hbox2 = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox2), - ctk_powermizer->status, FALSE, FALSE, 0); - - gtk_table_attach(GTK_TABLE(table), hbox2, 2, 3, 0, 1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - } - - ctk_config_set_tooltip(ctk_config, ctk_powermizer->configuration_button, - __dp_configuration_button_help); - g_signal_connect(G_OBJECT(ctk_powermizer->configuration_button), - "clicked", - G_CALLBACK(dp_config_button_toggled), - (gpointer) ctk_powermizer); - if (attribute == NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE) { - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE), - G_CALLBACK(dp_configuration_update_received), - (gpointer) ctk_powermizer); - } else if (attribute == NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT) { - g_signal_connect(G_OBJECT(ctk_event), - CTK_EVENT_NAME(NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT), - G_CALLBACK(dp_configuration_update_received), - (gpointer) ctk_powermizer); - } - } else { - ctk_powermizer->configuration_button = NULL; - } - /* Updating the powermizer page */ update_powermizer_info(ctk_powermizer); @@ -1891,170 +1684,6 @@ -static void show_dp_toggle_warning_dlg(CtkPowermizer *ctk_powermizer) -{ - GtkWidget *dlg, *parent; - - /* return early if message dialog already shown */ - if (ctk_powermizer->dp_toggle_warning_dlg_shown) { - return; - } - ctk_powermizer->dp_toggle_warning_dlg_shown = TRUE; - parent = ctk_get_parent_window(GTK_WIDGET(ctk_powermizer)); - - dlg = gtk_message_dialog_new (GTK_WINDOW(parent), - GTK_DIALOG_MODAL, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "Changes to the CUDA - Double precision " - "setting " - "require a system reboot before " - "taking effect."); - gtk_dialog_run(GTK_DIALOG(dlg)); - gtk_widget_destroy (dlg); - -} /* show_dp_toggle_warning_dlg() */ - - - -/* - * post_dp_configuration_update() - this function updates status bar string. - */ - -static void post_dp_configuration_update(CtkPowermizer *ctk_powermizer) -{ - gboolean enabled = ctk_powermizer->dp_enabled; - - const char *conf_string = enabled ? "enabled" : "disabled"; - char message[128]; - - if (ctk_powermizer->attribute == NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT) { - snprintf(message, sizeof(message), "CUDA - Double precision will " - "be %s after reboot.", - conf_string); - } else { - snprintf(message, sizeof(message), "CUDA - Double precision %s.", - conf_string); - } - - ctk_config_statusbar_message(ctk_powermizer->ctk_config, "%s", message); -} /* post_dp_configuration_update() */ - - - -/* - * dp_set_config_status() - set CUDA - Double Precision Boost configuration - * button status. - */ - -static void dp_set_config_status(CtkPowermizer *ctk_powermizer) -{ - GtkWidget *configuration_button = ctk_powermizer->configuration_button; - - g_signal_handlers_block_by_func(G_OBJECT(configuration_button), - G_CALLBACK(dp_config_button_toggled), - (gpointer) ctk_powermizer); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(configuration_button), - ctk_powermizer->dp_enabled); - - g_signal_handlers_unblock_by_func(G_OBJECT(configuration_button), - G_CALLBACK(dp_config_button_toggled), - (gpointer) ctk_powermizer); -} /* dp_set_config_status() */ - - - -/* - * dp_update_config_status - get current CUDA - Double Precision Boost status. - */ - -static void dp_update_config_status(CtkPowermizer *ctk_powermizer, gboolean val) -{ - if ((ctk_powermizer->attribute == - NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE && - val == NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE_DISABLED) || - (ctk_powermizer->attribute == - NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT && - val == NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT_DISABLED)) { - ctk_powermizer->dp_enabled = FALSE; - } else { - ctk_powermizer->dp_enabled = TRUE; - } -} /* dp_update_config_status() */ - - - -/* - * dp_configuration_update_received() - this function is called when the - * NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE attribute is changed by another - * NV-CONTROL client. - */ - -static void dp_configuration_update_received(GObject *object, - CtrlEvent *event, - gpointer user_data) -{ - CtkPowermizer *ctk_powermizer = CTK_POWERMIZER(user_data); - - if (event->type != CTRL_EVENT_TYPE_INTEGER_ATTRIBUTE) { - return; - } - - ctk_powermizer->dp_enabled = event->int_attr.value; - - /* set CUDA - Double Precision Boost configuration buttion status */ - dp_set_config_status(ctk_powermizer); - - /* Update status bar message */ - post_dp_configuration_update(ctk_powermizer); -} /* dp_configuration_update_received() */ - - -/* - * dp_config_button_toggled() - callback function for - * enable CUDA - Double Precision Boost checkbox. - */ - -static void dp_config_button_toggled(GtkWidget *widget, - gpointer user_data) -{ - gboolean enabled; - CtkPowermizer *ctk_powermizer = CTK_POWERMIZER(user_data); - CtrlTarget *ctrl_target = ctk_powermizer->ctrl_target; - ReturnStatus ret; - - enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); - - /* show popup dialog when user first time click DP config */ - if (ctk_powermizer->attribute == NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT) { - show_dp_toggle_warning_dlg(ctk_powermizer); - } - - /* set the newly specified CUDA - Double Precision Boost value */ - ret = NvCtrlSetAttribute(ctrl_target, - ctk_powermizer->attribute, - enabled); - if (ret != NvCtrlSuccess) { - ctk_config_statusbar_message(ctk_powermizer->ctk_config, - "Failed to set " - "CUDA - Double precision " - "configuration!"); - return; - } - - ctk_powermizer->dp_enabled = enabled; - dp_set_config_status(ctk_powermizer); - if (ctk_powermizer->status) { - gtk_label_set_text(GTK_LABEL(ctk_powermizer->status), - "pending reboot"); - } - - /* Update status bar message */ - post_dp_configuration_update(ctk_powermizer); -} /* dp_config_button_toggled() */ - - - GtkTextBuffer *ctk_powermizer_create_help(GtkTextTagTable *table, CtkPowermizer *ctk_powermizer) { @@ -2077,11 +1706,7 @@ if (ctk_powermizer->gpu_clock) { ctk_help_heading(b, &i, "Clock Frequencies"); - if (ctk_powermizer->memory_transfer_rate && - ctk_powermizer->processor_clock) { - s = "This indicates the GPU's current Graphics Clock, " - "Memory transfer rate and Processor Clock frequencies."; - } else if (ctk_powermizer->memory_transfer_rate) { + if (ctk_powermizer->memory_transfer_rate) { s = "This indicates the GPU's current Graphics Clock and " "Memory transfer rate."; } else { @@ -2095,9 +1720,11 @@ ctk_help_para(b, &i, "%s", __power_source_help); } - if (ctk_powermizer->pcie_gen_queriable) { + if (ctk_powermizer->link_width) { ctk_help_heading(b, &i, "Current PCIe link width"); ctk_help_para(b, &i, "%s", __current_pcie_link_width_help); + } + if (ctk_powermizer->link_speed) { ctk_help_heading(b, &i, "Current PCIe link speed"); ctk_help_para(b, &i, "%s", __current_pcie_link_speed_help); } @@ -2123,11 +1750,6 @@ ctk_help_para(b, &i, "%s", ctk_powermizer->powermizer_menu_help); } - if (ctk_powermizer->configuration_button) { - ctk_help_heading(b, &i, "CUDA - Double precision"); - ctk_help_para(b, &i, "%s", __dp_configuration_button_help); - } - ctk_help_finish(b); return b; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkpowermizer.h nvidia-settings-510.47.03/src/gtk+-2.x/ctkpowermizer.h --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkpowermizer.h 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkpowermizer.h 2022-01-24 23:51:09.000000000 +0000 @@ -55,7 +55,6 @@ GtkWidget *adaptive_clock_status; GtkWidget *gpu_clock; GtkWidget *memory_transfer_rate; - GtkWidget *processor_clock; GtkWidget *power_source; GtkWidget *performance_level; GtkWidget *performance_table_hbox; @@ -66,24 +65,18 @@ gchar *powermizer_menu_help; - GtkWidget *configuration_button; - gboolean dp_enabled; - gboolean dp_toggle_warning_dlg_shown; gboolean hasDecoupledClock; gboolean hasEditablePerfLevel; gboolean editable_performance_levels_unified; gint nvclock_attribute; gint mem_transfer_rate_attribute; - gint attribute; gint powermizer_default_mode; - GtkWidget *status; GtkWidget *editable_perf_level_table; gint num_perf_levels; GtkWidget *link_width; GtkWidget *link_speed; - gboolean pcie_gen_queriable; }; struct _CtkPowermizerClass diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkscale.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkscale.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkscale.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkscale.c 2022-01-24 23:51:09.000000000 +0000 @@ -29,7 +29,7 @@ #endif static void ctk_scale_finalize(GObject *object); -static void ctk_scale_init(CtkScaleClass *ctk_object_class); +static void ctk_scale_init(CtkScaleClass *ctk_object_class, gpointer); enum { PROP_0, @@ -65,7 +65,8 @@ } -static void ctk_scale_init(CtkScaleClass *ctk_object_class) +static void ctk_scale_init(CtkScaleClass *ctk_object_class, + gpointer class_data) { GObjectClass *gobject_class = (GObjectClass *)ctk_object_class; gobject_class->finalize = ctk_scale_finalize; diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkscreen.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkscreen.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkscreen.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkscreen.c 2022-01-24 23:51:09.000000000 +0000 @@ -367,7 +367,7 @@ ctk_help_title(b, &i, "X Screen Information Help"); ctk_help_para(b, &i, "This page in the NVIDIA " - "X Server Control Panel describes basic " + "Settings Control Panel describes basic " "information about the X Screen '%s'.", screen_name); diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkserver.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkserver.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkserver.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkserver.c 2022-01-24 23:51:09.000000000 +0000 @@ -247,21 +247,27 @@ GtkWidget *hseparator; GtkWidget *table; - gchar *os; - gchar *arch; - gchar *driver_version; + CtrlTarget *gpu_target = NULL; + + gchar *os = NULL; + gchar *arch = NULL; + gchar *driver_version = NULL; + gchar *nvml_version = NULL; gchar *dname = NvCtrlGetDisplayName(ctrl_target); - gchar *display_name; - gchar *server_version; - gchar *vendor_str; - gchar *vendor_ver; - gchar *nv_control_server_version; - gchar *num_screens; + gchar *display_name = NULL; + gchar *server_version = NULL; + gchar *vendor_str = NULL; + gchar *vendor_ver = NULL; + gchar *nv_control_server_version = NULL; + gchar *num_screens = NULL; ReturnStatus ret; int tmp, os_val; int xinerama_enabled; + int row; + + gpu_target = NvCtrlGetDefaultTargetByType(ctrl_target->system, GPU_TARGET); /* * get the data that we will display below @@ -276,72 +282,85 @@ xinerama_enabled = FALSE; } - /* NV_CTRL_OPERATING_SYSTEM */ + if (ctrl_target->system->has_nv_control) { - os_val = NV_CTRL_OPERATING_SYSTEM_LINUX; - ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_OPERATING_SYSTEM, &os_val); - os = NULL; - if (ret == NvCtrlSuccess) { - if (os_val == NV_CTRL_OPERATING_SYSTEM_LINUX) os = "Linux"; - else if (os_val == NV_CTRL_OPERATING_SYSTEM_FREEBSD) os = "FreeBSD"; - else if (os_val == NV_CTRL_OPERATING_SYSTEM_SUNOS) os = "SunOS"; - } - if (!os) os = "Unknown"; + /* NV_CTRL_OPERATING_SYSTEM */ + + os_val = NV_CTRL_OPERATING_SYSTEM_LINUX; + ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_OPERATING_SYSTEM, &os_val); + os = NULL; + if (ret == NvCtrlSuccess) { + if (os_val == NV_CTRL_OPERATING_SYSTEM_LINUX) os = "Linux"; + else if (os_val == NV_CTRL_OPERATING_SYSTEM_FREEBSD) os = "FreeBSD"; + else if (os_val == NV_CTRL_OPERATING_SYSTEM_SUNOS) os = "SunOS"; + } + if (!os) os = "Unknown"; - /* NV_CTRL_ARCHITECTURE */ + /* NV_CTRL_ARCHITECTURE */ - ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_ARCHITECTURE, &tmp); - arch = NULL; - if (ret == NvCtrlSuccess) { - switch (tmp) { - case NV_CTRL_ARCHITECTURE_X86: arch = "x86"; break; - case NV_CTRL_ARCHITECTURE_X86_64: arch = "x86_64"; break; - case NV_CTRL_ARCHITECTURE_IA64: arch = "ia64"; break; - case NV_CTRL_ARCHITECTURE_ARM: arch = "ARM"; break; - case NV_CTRL_ARCHITECTURE_AARCH64: arch = "AArch64"; break; - case NV_CTRL_ARCHITECTURE_PPC64LE: arch = "ppc64le"; break; + ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_ARCHITECTURE, &tmp); + arch = NULL; + if (ret == NvCtrlSuccess) { + switch (tmp) { + case NV_CTRL_ARCHITECTURE_X86: arch = "x86"; break; + case NV_CTRL_ARCHITECTURE_X86_64: arch = "x86_64"; break; + case NV_CTRL_ARCHITECTURE_IA64: arch = "ia64"; break; + case NV_CTRL_ARCHITECTURE_ARM: arch = "ARM"; break; + case NV_CTRL_ARCHITECTURE_AARCH64: arch = "AArch64"; break; + case NV_CTRL_ARCHITECTURE_PPC64LE: arch = "ppc64le"; break; + } } + if (!arch) arch = "Unknown"; + os = g_strdup_printf("%s-%s", os, arch); } - if (!arch) arch = "Unknown"; - os = g_strdup_printf("%s-%s", os, arch); /* NV_CTRL_STRING_NVIDIA_DRIVER_VERSION */ driver_version = get_nvidia_driver_version(ctrl_target); - /* Display Name */ + /* NV_CTRL_STRING_NVML_VERSION */ - display_name = nv_standardize_screen_name(dname, -2); + NvCtrlGetStringAttribute(gpu_target, + NV_CTRL_STRING_NVML_VERSION, + &nvml_version); - /* X Server Version */ + if (ctrl_target->system->has_nv_control) { - server_version = g_strdup_printf("%d.%d", - NvCtrlGetProtocolVersion(ctrl_target), - NvCtrlGetProtocolRevision(ctrl_target)); + /* Display Name */ - /* Server Vendor String */ + display_name = nv_standardize_screen_name(dname, -2); - vendor_str = g_strdup(NvCtrlGetServerVendor(ctrl_target)); + /* X Server Version */ - /* Server Vendor Version */ + server_version = g_strdup_printf("%d.%d", + NvCtrlGetProtocolVersion(ctrl_target), + NvCtrlGetProtocolRevision(ctrl_target)); - vendor_ver = get_server_vendor_version(ctrl_target); + /* Server Vendor String */ - /* NV_CTRL_STRING_NV_CONTROL_VERSION */ + vendor_str = g_strdup(NvCtrlGetServerVendor(ctrl_target)); - ret = NvCtrlGetStringAttribute(ctrl_target, - NV_CTRL_STRING_NV_CONTROL_VERSION, - &nv_control_server_version); - if (ret != NvCtrlSuccess) nv_control_server_version = NULL; + /* Server Vendor Version */ - /* # Logical X Screens */ + vendor_ver = get_server_vendor_version(ctrl_target); + + /* NV_CTRL_STRING_NV_CONTROL_VERSION */ + + ret = NvCtrlGetStringAttribute(ctrl_target, + NV_CTRL_STRING_NV_CONTROL_VERSION, + &nv_control_server_version); + if (ret != NvCtrlSuccess) nv_control_server_version = NULL; + + /* # Logical X Screens */ + + if (xinerama_enabled) { + num_screens = g_strdup_printf("%d (Xinerama)", + NvCtrlGetScreenCount(ctrl_target)); + } else { + num_screens = g_strdup_printf("%d", + NvCtrlGetScreenCount(ctrl_target)); + } - if (xinerama_enabled) { - num_screens = g_strdup_printf("%d (Xinerama)", - NvCtrlGetScreenCount(ctrl_target)); - } else { - num_screens = g_strdup_printf("%d", - NvCtrlGetScreenCount(ctrl_target)); } @@ -363,7 +382,7 @@ } else if (os_val == NV_CTRL_OPERATING_SYSTEM_SUNOS) { banner = ctk_banner_image_new(BANNER_ARTWORK_SOLARIS); } else { - banner = ctk_banner_image_new(BANNER_ARTWORK_PENGUIN); + banner = ctk_banner_image_new(BANNER_ARTWORK_BLANK); } gtk_box_pack_start(GTK_BOX(ctk_object), banner, FALSE, FALSE, 0); @@ -384,7 +403,7 @@ hseparator = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); - table = gtk_table_new(2, 2, FALSE); + table = gtk_table_new(3, 2, FALSE); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); gtk_table_set_row_spacings(GTK_TABLE(table), 3); @@ -392,47 +411,56 @@ gtk_container_set_border_width(GTK_CONTAINER(table), 5); - add_table_row(table, 0, - 0, 0.5, "Operating System:", 0, 0.5, os); - add_table_row(table, 1, + row = 0; + if (os) { + add_table_row(table, row++, + 0, 0.5, "Operating System:", 0, 0.5, os); + } + add_table_row(table, row++, 0, 0.5, "NVIDIA Driver Version:", 0, 0.5, driver_version); + if (nvml_version) { + add_table_row(table, row++, + 0, 0.5, "NVML Version:", 0, 0.5, nvml_version); + } /* * This displays basic X Server information, including * version number, vendor information and the number of * X Screens. */ + if (ctrl_target->system->has_nv_control) { - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("X Server Information"); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - hseparator = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); + label = gtk_label_new("X Server Information"); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - table = gtk_table_new(15, 2, FALSE); - gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), 3); - gtk_table_set_col_spacings(GTK_TABLE(table), 15); - gtk_container_set_border_width(GTK_CONTAINER(table), 5); + hseparator = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); - add_table_row(table, 0, - 0, 0.5, "Display Name:", 0, 0.5, display_name); - /* separator */ - add_table_row(table, 4, - 0, 0.5, "Server Version Number:", 0, 0.5, server_version); - add_table_row(table, 5, - 0, 0.5, "Server Vendor String:", 0, 0.5, vendor_str); - add_table_row(table, 6, - 0, 0.5, "Server Vendor Version:", 0, 0.5, vendor_ver); - /* separator */ - add_table_row(table, 10, - 0, 0, "NV-CONTROL Version:", 0, 0, nv_control_server_version); - /* separator */ - add_table_row(table, 14, - 0, 0, "Screens:", 0, 0, num_screens); + table = gtk_table_new(15, 2, FALSE); + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), 3); + gtk_table_set_col_spacings(GTK_TABLE(table), 15); + gtk_container_set_border_width(GTK_CONTAINER(table), 5); + + add_table_row(table, 0, + 0, 0.5, "Display Name:", 0, 0.5, display_name); + /* separator */ + add_table_row(table, 4, + 0, 0.5, "Server Version Number:", 0, 0.5, server_version); + add_table_row(table, 5, + 0, 0.5, "Server Vendor String:", 0, 0.5, vendor_str); + add_table_row(table, 6, + 0, 0.5, "Server Vendor Version:", 0, 0.5, vendor_ver); + /* separator */ + add_table_row(table, 10, + 0, 0, "NV-CONTROL Version:", 0, 0, nv_control_server_version); + /* separator */ + add_table_row(table, 14, + 0, 0, "Screens:", 0, 0, num_screens); + } /* print special trademark text for FreeBSD */ @@ -472,6 +500,7 @@ g_free(display_name); g_free(os); free(driver_version); + free(nvml_version); g_free(server_version); g_free(vendor_str); @@ -499,7 +528,7 @@ gtk_text_buffer_get_iter_at_offset(b, &i, 0); - ctk_help_title(b, &i, "X Server Information Help"); + ctk_help_title(b, &i, "System Information Help"); ctk_help_heading(b, &i, "Operating System"); ctk_help_para(b, &i, "This is the operating system on which the NVIDIA " diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkthermal.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkthermal.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkthermal.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkthermal.c 2022-01-24 23:51:09.000000000 +0000 @@ -101,9 +101,12 @@ static const char * __fan_rpm_help = "This shows the current GPU Fan Speed in rotations per minute (RPM)."; -static const char * __fan_speed_help = +static const char * __fan_current_speed_help = "This shows the current GPU Fan Speed level as a percentage."; +static const char * __fan_target_speed_help = +"This shows the target GPU Fan Speed level as a percentage."; + static const char * __fan_control_type_help = "Fan Type indicates if and how this fan may be controlled. Possible " "types are Variable, Toggle or Restricted. Variable fans can be " @@ -163,9 +166,12 @@ gchar *tmp_str; CtkThermal *ctk_thermal; GtkWidget *table, *label, *eventbox; - gint ret; + gint ret, ret2; gint row_idx; /* Where to insert into the cooler info table */ - + gboolean cooler_extra_info = FALSE; + int num_cols = 2; + int current_speed_attr; + ctk_thermal = CTK_THERMAL(user_data); /* Since table cell management in GTK lacks, just remove and rebuild @@ -178,7 +184,17 @@ /* Generate a new table */ - table = gtk_table_new(1, 5, FALSE); + ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[0].ctrl_target, + NV_CTRL_THERMAL_COOLER_CONTROL_TYPE, &cooler_type); + ret2 = NvCtrlGetAttribute(ctk_thermal->cooler_control[0].ctrl_target, + NV_CTRL_THERMAL_COOLER_TARGET, &cooler_target); + if (ret == NvCtrlSuccess && ret2 == NvCtrlSuccess) { + cooler_extra_info = TRUE; + ctk_thermal->thermal_cooler_extra_info_supported = cooler_extra_info; + num_cols = 5; + } + + table = gtk_table_new(1, num_cols, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 3); gtk_table_set_col_spacings(GTK_TABLE(table), 15); gtk_container_set_border_width(GTK_CONTAINER(table), 5); @@ -194,39 +210,51 @@ gtk_container_add(GTK_CONTAINER(eventbox), label); ctk_config_set_tooltip(ctk_thermal->ctk_config, eventbox, __fan_id_help); - label = gtk_label_new("Speed (RPM)"); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); eventbox = gtk_event_box_new(); + if (cooler_extra_info) { + current_speed_attr = NV_CTRL_THERMAL_COOLER_SPEED; + label = gtk_label_new("Speed (RPM)"); + ctk_config_set_tooltip(ctk_thermal->ctk_config, eventbox, + __fan_rpm_help); + } else { + current_speed_attr = NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL; + label = gtk_label_new("Current Speed (%)"); + ctk_config_set_tooltip(ctk_thermal->ctk_config, eventbox, + __fan_current_speed_help); + } + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); gtk_table_attach(GTK_TABLE(table), eventbox, 1, 2, 0, 1, GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); gtk_container_add(GTK_CONTAINER(eventbox), label); - ctk_config_set_tooltip(ctk_thermal->ctk_config, eventbox, __fan_rpm_help); - label = gtk_label_new("Speed (%)"); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - eventbox = gtk_event_box_new(); - gtk_table_attach(GTK_TABLE(table), eventbox, 2, 3, 0, 1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - gtk_container_add(GTK_CONTAINER(eventbox), label); - ctk_config_set_tooltip(ctk_thermal->ctk_config, eventbox, __fan_speed_help); + if (cooler_extra_info) { + label = gtk_label_new("Target Speed (%)"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + eventbox = gtk_event_box_new(); + gtk_table_attach(GTK_TABLE(table), eventbox, 2, 3, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + gtk_container_add(GTK_CONTAINER(eventbox), label); + ctk_config_set_tooltip(ctk_thermal->ctk_config, eventbox, + __fan_target_speed_help); - label = gtk_label_new("Control Type"); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - eventbox = gtk_event_box_new(); - gtk_table_attach(GTK_TABLE(table), eventbox, 3, 4, 0, 1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - gtk_container_add(GTK_CONTAINER(eventbox), label); - ctk_config_set_tooltip(ctk_thermal->ctk_config, eventbox, - __fan_control_type_help); + label = gtk_label_new("Control Type"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + eventbox = gtk_event_box_new(); + gtk_table_attach(GTK_TABLE(table), eventbox, 3, 4, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + gtk_container_add(GTK_CONTAINER(eventbox), label); + ctk_config_set_tooltip(ctk_thermal->ctk_config, eventbox, + __fan_control_type_help); - label = gtk_label_new("Cooling Target"); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - eventbox = gtk_event_box_new(); - gtk_table_attach(GTK_TABLE(table), eventbox, 4, 5, 0, 1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - gtk_container_add(GTK_CONTAINER(eventbox), label); - ctk_config_set_tooltip(ctk_thermal->ctk_config, eventbox, - __fan_cooling_target_help); + label = gtk_label_new("Cooling Target"); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + eventbox = gtk_event_box_new(); + gtk_table_attach(GTK_TABLE(table), eventbox, 4, 5, 0, 1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + gtk_container_add(GTK_CONTAINER(eventbox), label); + ctk_config_set_tooltip(ctk_thermal->ctk_config, eventbox, + __fan_cooling_target_help); + } /* Fill the cooler info */ for (i = 0; i < ctk_thermal->cooler_count; i++) { @@ -242,7 +270,7 @@ free(tmp_str); ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target, - NV_CTRL_THERMAL_COOLER_SPEED, + current_speed_attr, &speed); if (ret == NvCtrlSuccess) { tmp_str = g_strdup_printf("%d", speed); @@ -256,69 +284,79 @@ GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); free(tmp_str); - ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target, - NV_CTRL_THERMAL_COOLER_LEVEL, - &level); - if (ret != NvCtrlSuccess) { - /* cooler information no longer available */ - return FALSE; - } - tmp_str = g_strdup_printf("%d", level); - label = gtk_label_new(tmp_str); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_table_attach(GTK_TABLE(table), label, 2, 3, row_idx, row_idx+1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - free(tmp_str); + if (cooler_extra_info) { + ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target, + NV_CTRL_THERMAL_COOLER_LEVEL, + &level); + if (ret != NvCtrlSuccess) { + /* cooler information no longer available */ + return FALSE; + } + tmp_str = g_strdup_printf("%d", level); + label = gtk_label_new(tmp_str); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, row_idx, row_idx+1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + free(tmp_str); - ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target, - NV_CTRL_THERMAL_COOLER_CONTROL_TYPE, - &cooler_type); - if (ret != NvCtrlSuccess) { - /* cooler information no longer available */ - return FALSE; - } - if (cooler_type == NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_VARIABLE) { - tmp_str = g_strdup_printf("Variable"); - } else if (cooler_type == NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_TOGGLE) { - tmp_str = g_strdup_printf("Toggle"); - } else if (cooler_type == NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_NONE) { - tmp_str = g_strdup_printf("Restricted"); - } - label = gtk_label_new(tmp_str); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_table_attach(GTK_TABLE(table), label, 3, 4, row_idx, row_idx+1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - free(tmp_str); + ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target, + NV_CTRL_THERMAL_COOLER_CONTROL_TYPE, + &cooler_type); + if (ret != NvCtrlSuccess && ret != NvCtrlNotSupported) { + return FALSE; + } - ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target, - NV_CTRL_THERMAL_COOLER_TARGET, - &cooler_target); - if (ret != NvCtrlSuccess) { - /* cooler information no longer available */ - return FALSE; - } - switch(cooler_target) { - case NV_CTRL_THERMAL_COOLER_TARGET_GPU: - tmp_str = g_strdup_printf("GPU"); - break; - case NV_CTRL_THERMAL_COOLER_TARGET_MEMORY: - tmp_str = g_strdup_printf("Memory"); - break; - case NV_CTRL_THERMAL_COOLER_TARGET_POWER_SUPPLY: - tmp_str = g_strdup_printf("Power Supply"); - break; - case NV_CTRL_THERMAL_COOLER_TARGET_GPU_RELATED: - tmp_str = g_strdup_printf("GPU, Memory, and Power Supply"); - break; - default: - break; + if (ret == NvCtrlNotSupported) { + tmp_str = g_strdup_printf("Unknown"); + } else if (cooler_type == NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_VARIABLE) { + tmp_str = g_strdup_printf("Variable"); + } else if (cooler_type == NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_TOGGLE) { + tmp_str = g_strdup_printf("Toggle"); + } else if (cooler_type == NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_NONE) { + tmp_str = g_strdup_printf("Restricted"); + } + label = gtk_label_new(tmp_str); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 3, 4, row_idx, row_idx+1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + free(tmp_str); + + ret = NvCtrlGetAttribute(ctk_thermal->cooler_control[i].ctrl_target, + NV_CTRL_THERMAL_COOLER_TARGET, + &cooler_target); + if (ret != NvCtrlSuccess && ret != NvCtrlNotSupported) { + return FALSE; + } + + if (ret == NvCtrlNotSupported) { + tmp_str = g_strdup_printf("Unknown"); + } else { + + switch(cooler_target) { + case NV_CTRL_THERMAL_COOLER_TARGET_GPU: + tmp_str = g_strdup_printf("GPU"); + break; + case NV_CTRL_THERMAL_COOLER_TARGET_MEMORY: + tmp_str = g_strdup_printf("Memory"); + break; + case NV_CTRL_THERMAL_COOLER_TARGET_POWER_SUPPLY: + tmp_str = g_strdup_printf("Power Supply"); + break; + case NV_CTRL_THERMAL_COOLER_TARGET_GPU_RELATED: + tmp_str = g_strdup_printf("GPU, Memory, and Power Supply"); + break; + default: + break; + } + } + label = gtk_label_new(tmp_str); + gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); + gtk_table_attach(GTK_TABLE(table), label, 4, 5, row_idx, row_idx+1, + GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); + free(tmp_str); } - label = gtk_label_new(tmp_str); - gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f); - gtk_table_attach(GTK_TABLE(table), label, 4, 5, row_idx, row_idx+1, - GTK_FILL, GTK_FILL | GTK_EXPAND, 5, 0); - free(tmp_str); } + gtk_widget_show_all(table); /* X driver takes fraction of second to refresh newly set value */ @@ -1079,7 +1117,7 @@ CtrlTarget *sensor_target; CtrlAttributeValidValues cooler_range; CtrlAttributeValidValues sensor_range; - gint trigger, core, ambient; + gint slowdown, core, ambient; gint upper; gchar *s; gint i, j; @@ -1094,7 +1132,6 @@ Bool cooler_control_enabled; int cur_cooler_idx = 0; int cur_sensor_idx = 0; - int slowdown; Bool thermal_sensor_target_type_supported = FALSE; /* make sure we have a handle */ @@ -1127,21 +1164,21 @@ /* thermal information unavailable */ return NULL; } + } - ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_MAX_CORE_THRESHOLD, - &upper); - if (ret != NvCtrlSuccess) { - /* thermal information unavailable */ - return NULL; - } + ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_SLOWDOWN_THRESHOLD, + &slowdown); + if (ret != NvCtrlSuccess) { + slowdown = 0; + } - ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_CORE_THRESHOLD, - &trigger); - if (ret != NvCtrlSuccess) { - /* thermal information unavailable */ - return NULL; - } + ret = NvCtrlGetAttribute(ctrl_target, NV_CTRL_GPU_SHUTDOWN_THRESHOLD, + &upper); + if (ret != NvCtrlSuccess) { + upper = slowdown; } + + /* Query the list of sensors attached to this GPU */ ret = NvCtrlGetBinaryAttribute(ctrl_target, 0, @@ -1227,13 +1264,6 @@ hsep = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(hbox1), hsep, TRUE, TRUE, 0); - ret = NvCtrlGetAttribute(ctk_thermal->ctrl_target, - NV_CTRL_GPU_SLOWDOWN_THRESHOLD, - &slowdown); - if (ret != NvCtrlSuccess) { - slowdown = 0; - } - if (ctk_thermal->sensor_count > 0) { ctk_thermal->sensor_info = (SensorInfoPtr) nvalloc(ctk_thermal->sensor_count * sizeof(SensorInfoRec)); @@ -1294,34 +1324,37 @@ vbox1 = gtk_vbox_new(FALSE, 0); hbox1 = gtk_hbox_new(FALSE, 0); - frame = gtk_frame_new("Slowdown Threshold"); gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox1), vbox1, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox1), frame, FALSE, FALSE, 0); - hbox2 = gtk_hbox_new(FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(hbox2), FRAME_PADDING); - gtk_container_add(GTK_CONTAINER(frame), hbox2); + if (slowdown > 0) { + frame = gtk_frame_new("Slowdown Threshold"); + gtk_box_pack_start(GTK_BOX(vbox1), frame, FALSE, FALSE, 0); - label = gtk_label_new("Degrees: "); - gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); + hbox2 = gtk_hbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(hbox2), FRAME_PADDING); + gtk_container_add(GTK_CONTAINER(frame), hbox2); - eventbox = gtk_event_box_new(); - gtk_box_pack_start(GTK_BOX(hbox2), eventbox, FALSE, FALSE, 0); + label = gtk_label_new("Degrees: "); + gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); - entry = gtk_entry_new(); - gtk_entry_set_max_length(GTK_ENTRY(entry), 5); - gtk_container_add(GTK_CONTAINER(eventbox), entry); - gtk_widget_set_sensitive(entry, FALSE); - gtk_entry_set_width_chars(GTK_ENTRY(entry), 5); + eventbox = gtk_event_box_new(); + gtk_box_pack_start(GTK_BOX(hbox2), eventbox, FALSE, FALSE, 0); - s = g_strdup_printf(" %d ", trigger); - gtk_entry_set_text(GTK_ENTRY(entry), s); - g_free(s); - ctk_config_set_tooltip(ctk_config, eventbox, __core_threshold_help); + entry = gtk_entry_new(); + gtk_entry_set_max_length(GTK_ENTRY(entry), 5); + gtk_container_add(GTK_CONTAINER(eventbox), entry); + gtk_widget_set_sensitive(entry, FALSE); + gtk_entry_set_width_chars(GTK_ENTRY(entry), 5); - label = gtk_label_new(" C"); - gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); + s = g_strdup_printf(" %d ", slowdown); + gtk_entry_set_text(GTK_ENTRY(entry), s); + g_free(s); + ctk_config_set_tooltip(ctk_config, eventbox, __core_threshold_help); + + label = gtk_label_new(" C"); + gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); + } /* GPU Core Temperature */ @@ -1376,7 +1409,7 @@ } /* GPU Core Temperature Gauge */ - + ctk_thermal->core_gauge = pack_gauge(hbox1, 25, upper, ctk_config, __temp_level_help); } @@ -1679,26 +1712,32 @@ ctk_help_heading(b, &i, "ID"); ctk_help_para(b, &i, "%s", __fan_id_help); - ctk_help_heading(b, &i, "Speed (RPM)"); - ctk_help_para(b, &i,"%s", __fan_rpm_help); + if (ctk_thermal->thermal_cooler_extra_info_supported) { + ctk_help_heading(b, &i, "Speed (RPM)"); + ctk_help_para(b, &i,"%s", __fan_rpm_help); - ctk_help_heading(b, &i, "Speed (%%)"); - ctk_help_para(b, &i, "%s", __fan_speed_help); + ctk_help_heading(b, &i, "Target Speed (%%)"); + ctk_help_para(b, &i, "%s", __fan_target_speed_help); - ctk_help_heading(b, &i, "Type"); - ctk_help_para(b, &i, "%s", __fan_control_type_help); + ctk_help_heading(b, &i, "Type"); + ctk_help_para(b, &i, "%s", __fan_control_type_help); - ctk_help_heading(b, &i, "Cooling Target"); - ctk_help_para(b, &i, "%s", __fan_cooling_target_help); + ctk_help_heading(b, &i, "Cooling Target"); + ctk_help_para(b, &i, "%s", __fan_cooling_target_help); - ctk_help_heading(b, &i, "Enable GPU Fan Settings"); - ctk_help_para(b, &i, "%s", __enable_button_help); + } else { + ctk_help_heading(b, &i, "Current Speed (%%)"); + ctk_help_para(b, &i,"%s", __fan_current_speed_help); + } if ( ctk_thermal->show_fan_control_frame ) { ctk_help_heading(b, &i, "Enable GPU Fan Settings"); + ctk_help_para(b, &i, "%s", __enable_button_help); + + ctk_help_heading(b, &i, "Apply"); ctk_help_para(b, &i, "%s", __apply_button_help); - ctk_help_heading(b, &i, "Enable GPU Fan Settings"); + ctk_help_heading(b, &i, "Reset Hardware Defaults"); ctk_help_para(b, &i, "%s", __reset_button_help); } done: diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkthermal.h nvidia-settings-510.47.03/src/gtk+-2.x/ctkthermal.h --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkthermal.h 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkthermal.h 2022-01-24 23:51:09.000000000 +0000 @@ -104,6 +104,7 @@ int cooler_count; int sensor_count; gboolean thermal_sensor_target_type_supported; + gboolean thermal_cooler_extra_info_supported; }; struct _CtkThermalClass diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkui.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkui.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkui.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkui.c 2022-01-24 23:51:09.000000000 +0000 @@ -49,20 +49,6 @@ gtk_window_set_default_icon_list(list); window = ctk_window_new(p, conf, system); - if (!system->has_nv_control) { - GtkWidget *dlg; - dlg = gtk_message_dialog_new (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "You do not appear to be using the NVIDIA " - "X driver. Please edit your X configuration " - "file (just run `nvidia-xconfig` " - "as root), and restart the X server."); - gtk_dialog_run(GTK_DIALOG(dlg)); - gtk_widget_destroy (dlg); - } - ctk_window_set_active_page(CTK_WINDOW(window), page); gtk_main(); diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkutils.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkutils.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkutils.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkutils.c 2022-01-24 23:51:09.000000000 +0000 @@ -67,6 +67,20 @@ #endif } +void ctk_widget_set_visible(GtkWidget *w, gboolean visible) +{ +#ifdef CTK_GTK3 + /* GTK function added in 2.18 */ + gtk_widget_set_visible(w, visible); +#else + if (visible) { + gtk_widget_show(w); + } else { + gtk_widget_hide(w); + } +#endif +} + gboolean ctk_widget_is_drawable(GtkWidget *w) { #ifdef CTK_GTK3 @@ -323,6 +337,15 @@ #endif } +void ctk_widget_set_halign_left(GtkWidget *w) +{ +#ifdef CTK_GTK3 + gtk_widget_set_halign(w, GTK_ALIGN_START); +#else + g_object_set(w, "xalign", 0.0, NULL); +#endif +} + GtkWidget *ctk_file_chooser_dialog_new(const gchar *title, GtkWindow *parent, GtkFileChooserAction action) @@ -457,9 +480,7 @@ gchar *s = NULL; ret = NvCtrlGetAttribute(ctrl_target, attribute, &tmp); - if (ret != NvCtrlSuccess) { - s = g_strdup_printf("Unknown"); - } else { + if (ret == NvCtrlSuccess) { s = g_strdup_printf("%.1f GT/s", tmp/1000.0); } @@ -551,11 +572,11 @@ ret = NvCtrlGetBinaryAttribute(ctrl_target, 0, attr, (unsigned char **)(&pData), &len); - if (ret != NvCtrlSuccess) { - goto done; + if (ret == NvCtrlNotSupported) { + return NULL; } - for (i = 0; i < pData[0]; i++) { + for (i = 0; ret == NvCtrlSuccess && i < pData[0]; i++) { CtrlTarget *ctrl_other; int display_id = pData[i+1]; gchar *logName = NULL; @@ -601,8 +622,6 @@ } } - done: - if (!displays) { displays = g_strdup("None"); } @@ -772,6 +791,10 @@ GList *list; GList *node; + if (!container) { + return; + } + list = gtk_container_get_children(GTK_CONTAINER(container)); node = list; while (node) { diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkutils.h nvidia-settings-510.47.03/src/gtk+-2.x/ctkutils.h --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkutils.h 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkutils.h 2022-01-24 23:51:09.000000000 +0000 @@ -90,6 +90,7 @@ gboolean ctk_widget_is_sensitive(GtkWidget *w); gboolean ctk_widget_get_sensitive(GtkWidget *w); gboolean ctk_widget_get_visible(GtkWidget *w); +void ctk_widget_set_visible(GtkWidget *w, gboolean visible); gboolean ctk_widget_is_drawable(GtkWidget *w); GdkWindow *ctk_widget_get_window(GtkWidget *w); void ctk_widget_get_allocation(GtkWidget *w, GtkAllocation *a); @@ -110,6 +111,7 @@ GtkWidget *ctk_statusbar_get_message_area(GtkStatusbar *statusbar); void ctk_cell_renderer_set_alignment(GtkCellRenderer *widget, gfloat x, gfloat y); +void ctk_widget_set_halign_left(GtkWidget *w); GtkWidget *ctk_file_chooser_dialog_new(const gchar *title, GtkWindow *parent, GtkFileChooserAction action); diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkvdpau.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkvdpau.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkvdpau.c 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkvdpau.c 2022-01-24 23:51:09.000000000 +0000 @@ -229,6 +229,11 @@ {"VP9", VDP_DECODER_PROFILE_VP9_PROFILE_2, 0x100}, {"VP9", VDP_DECODER_PROFILE_VP9_PROFILE_3, 0x100}, #endif +#ifdef VDP_DECODER_PROFILE_AV1_MAIN + {"AV1", VDP_DECODER_PROFILE_AV1_MAIN, 0x200}, + {"AV1", VDP_DECODER_PROFILE_AV1_HIGH, 0x200}, + {"AV1", VDP_DECODER_PROFILE_AV1_PROFESSIONAL, 0x200}, +#endif }; const size_t decoder_list_count = sizeof(decoder_list)/sizeof(Desc); @@ -577,6 +582,11 @@ {"VP9 PROFILE 2", VDP_DECODER_PROFILE_VP9_PROFILE_2, 0}, {"VP9 PROFILE 3", VDP_DECODER_PROFILE_VP9_PROFILE_3, 0}, #endif +#ifdef VDP_DECODER_PROFILE_AV1_MAIN + {"AV1 MAIN", VDP_DECODER_PROFILE_AV1_MAIN, 0}, + {"AV1 HIGH", VDP_DECODER_PROFILE_AV1_HIGH, 0}, + {"AV1 PROFESSIONAL", VDP_DECODER_PROFILE_AV1_PROFESSIONAL, 0}, +#endif }; const size_t decoder_profile_count = sizeof(decoder_profiles)/sizeof(Desc); diff -Nru nvidia-settings-470.57.01/src/gtk+-2.x/ctkwindow.c nvidia-settings-510.47.03/src/gtk+-2.x/ctkwindow.c --- nvidia-settings-470.57.01/src/gtk+-2.x/ctkwindow.c 2021-07-07 22:48:14.000000000 +0000 +++ nvidia-settings-510.47.03/src/gtk+-2.x/ctkwindow.c 2022-01-24 23:51:09.000000000 +0000 @@ -103,7 +103,7 @@ typedef void (*select_widget_func_t)(GtkWidget *); typedef void (*unselect_widget_func_t)(GtkWidget *); -static void ctk_window_class_init(CtkWindowClass *); +static void ctk_window_class_init(CtkWindowClass *, gpointer); #ifdef CTK_GTK3 static void ctk_window_real_destroy(GtkWidget *); @@ -175,7 +175,8 @@ * class structure */ -static void ctk_window_class_init(CtkWindowClass *ctk_window_class) +static void ctk_window_class_init(CtkWindowClass *ctk_window_class, + gpointer class_data) { #ifdef CTK_GTK3 GtkWidgetClass *widget_class; @@ -499,8 +500,9 @@ GtkTextBuffer *help; CtrlTargetNode *node; - CtrlTarget *server_target = NULL; - CtrlTarget *ctrl_target = NULL; + CtrlTarget *default_x_target = NULL; + CtrlTarget *default_gpu_target = NULL; + CtrlTarget *ctrl_target; CtkEvent *ctk_event; CtkConfig *ctk_config; @@ -655,53 +657,56 @@ ctk_window->page_viewer = hbox; ctk_window->page = NULL; + /* + * Create generic and specific default system targets. X Screen target + * will only exist if the X Server is available. In that case, the generic + * default target will be the default gpu target instead. + */ + default_x_target = NvCtrlGetDefaultTargetByType(system, X_SCREEN_TARGET); + default_gpu_target = NvCtrlGetDefaultTargetByType(system, GPU_TARGET); - /* X Server info & configuration */ + ctrl_target = default_x_target; + if (!ctrl_target) { + ctrl_target = default_gpu_target; + } - if (system->targets[X_SCREEN_TARGET]) { + /* System Information */ - GtkWidget *child; + if (ctrl_target) { - /* - * XXX For now, just use the first handle in the list - * to communicate with the X server for these two - * pages and the app profile page below. - */ + GtkWidget *child; - server_target = NvCtrlGetDefaultTargetByType(system, X_SCREEN_TARGET); - if (server_target) { + child = ctk_server_new(ctrl_target, ctk_config); + add_page(child, + ctk_server_create_help(tag_table, CTK_SERVER(child)), + ctk_window, NULL, NULL, "System Information", + NULL, NULL, NULL); + } - /* X Server information */ + /* X Server Display Configuration */ - child = ctk_server_new(server_target, ctk_config); - add_page(child, - ctk_server_create_help(tag_table, - CTK_SERVER(child)), - ctk_window, NULL, NULL, "X Server Information", - NULL, NULL, NULL); + if (default_x_target) { - /* X Server Display Configuration */ + GtkWidget *child; - child = ctk_display_config_new(server_target, ctk_config); - if (child) { - ctk_window->display_config_widget = child; - add_page(child, - ctk_display_config_create_help(tag_table, - CTK_DISPLAY_CONFIG(child)), - ctk_window, NULL, NULL, - "X Server Display Configuration", - NULL, ctk_display_config_selected, - ctk_display_config_unselected); - } + child = ctk_display_config_new(default_x_target, ctk_config); + if (child) { + ctk_window->display_config_widget = child; + add_page(child, + ctk_display_config_create_help(tag_table, + CTK_DISPLAY_CONFIG(child)), + ctk_window, NULL, NULL, + "X Server Display Configuration", + NULL, ctk_display_config_selected, + ctk_display_config_unselected); } } /* Platform Power Mode */ - ctrl_target = NvCtrlGetDefaultTargetByType(system, GPU_TARGET); - ctk_event = CTK_EVENT(ctk_event_new(ctrl_target)); - widget = ctk_powermode_new(ctrl_target, ctk_config, ctk_event); + ctk_event = CTK_EVENT(ctk_event_new(default_gpu_target)); + widget = ctk_powermode_new(default_gpu_target, ctk_config, ctk_event); if (widget) { help = ctk_powermode_create_help(tag_table, CTK_POWERMODE(widget)); add_page(widget, help, ctk_window, NULL, NULL, @@ -963,7 +968,7 @@ } /* app profile configuration */ - widget = ctk_app_profile_new(server_target, ctk_config); + widget = ctk_app_profile_new(ctrl_target, ctk_config); if (widget) { add_page(widget, ctk_app_profile_create_help(CTK_APP_PROFILE(widget), tag_table), ctk_window, NULL, NULL, "Application Profiles", @@ -1018,7 +1023,7 @@ /* set the window title */ - gtk_window_set_title(GTK_WINDOW(object), "NVIDIA X Server Settings"); + gtk_window_set_title(GTK_WINDOW(object), "NVIDIA Settings"); gtk_widget_show_all(GTK_WIDGET(object)); diff -Nru nvidia-settings-470.57.01/src/jansson/error.c nvidia-settings-510.47.03/src/jansson/error.c --- nvidia-settings-470.57.01/src/jansson/error.c 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/jansson/error.c 2022-01-24 23:51:09.000000000 +0000 @@ -25,7 +25,7 @@ length = strlen(source); if(length < JSON_ERROR_SOURCE_LENGTH) - strncpy(error->source, source, length + 1); + strcpy(error->source, source); else { size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4; memcpy(error->source, "...", 3); diff -Nru nvidia-settings-470.57.01/src/libXNVCtrl/NVCtrl.h nvidia-settings-510.47.03/src/libXNVCtrl/NVCtrl.h --- nvidia-settings-470.57.01/src/libXNVCtrl/NVCtrl.h 2021-07-07 22:48:21.000000000 +0000 +++ nvidia-settings-510.47.03/src/libXNVCtrl/NVCtrl.h 2022-01-24 23:51:09.000000000 +0000 @@ -49,6 +49,7 @@ #define NV_CTRL_TARGET_TYPE_THERMAL_SENSOR 6 #define NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER 7 #define NV_CTRL_TARGET_TYPE_DISPLAY 8 +#define NV_CTRL_TARGET_TYPE_MUX 9 /**************************************************************************/ @@ -2845,8 +2846,7 @@ #define NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR_TRUE 1 /* - * NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS - Returns GPU's processor - * clock freqs. + * NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS - not supported */ #define NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS 359 /* RW-G */ @@ -3161,30 +3161,14 @@ #define NV_CTRL_USED_DEDICATED_GPU_MEMORY 394 /* R--G */ /* - * NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE - * Some GPUs can make a tradeoff between double-precision floating-point - * performance and clock speed. Enabling double-precision floating point - * performance may benefit CUDA or OpenGL applications that require high - * bandwidth double-precision performance. Disabling this feature may benefit - * graphics applications that require higher clock speeds. - * - * This attribute is only available when toggling double precision boost - * can be done immediately (without need for a rebooot). + * NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE - not supported */ #define NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE 395 /* RW-G */ #define NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE_DISABLED 0 #define NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE_ENABLED 1 /* - * NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT - * Some GPUs can make a tradeoff between double-precision floating-point - * performance and clock speed. Enabling double-precision floating point - * performance may benefit CUDA or OpenGL applications that require high - * bandwidth double-precision performance. Disabling this feature may benefit - * graphics applications that require higher clock speeds. - * - * This attribute is only available when toggling double precision boost - * requires a reboot. + * NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT - not supported */ #define NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT 396 /* RW-G */ @@ -3628,9 +3612,32 @@ #define NV_CTRL_PLATFORM_CURRENT_POWER_MODE_QUIET 2 #define NV_CTRL_PLATFORM_CURRENT_POWER_MODE_LIMITED_POWER_POLICY 3 -#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_PLATFORM_CURRENT_POWER_MODE +/* + * NV_CTRL_MUX_AUTO_SWITCH - Controls whether the mux specified will + * automatically switch when possible. + */ +#define NV_CTRL_MUX_AUTO_SWITCH 436 +#define NV_CTRL_MUX_AUTO_SWITCH_DISABLED 0 +#define NV_CTRL_MUX_AUTO_SWITCH_ENABLED 1 +/* + * NV_CTRL_MUX_IS_INTERNAL - Returns whether the specified mux is an internal + * mux. + */ +#define NV_CTRL_MUX_IS_INTERNAL 437 + +/* + * NV_CTRL_RESIZABLE_BAR - Returns whether the system has resizable BAR support. + */ +#define NV_CTRL_RESIZABLE_BAR 438 + +/* + * NV_CTRL_DYNAMIC_BOOST_SUPPORT - Returns whether the system has Dynamic Boost support. + */ +#define NV_CTRL_DYNAMIC_BOOST_SUPPORT 439 + +#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_DYNAMIC_BOOST_SUPPORT /**************************************************************************/ @@ -3996,9 +4003,8 @@ * NV Clock and Memory Clock values. * Not all tokens will be reported on all GPUs, and additional tokens * may be added in the future. - * For backwards compatibility we still provide nvclock, memclock, and - * processorclock those are the same as nvclockmin, memclockmin and - * processorclockmin. + * For backwards compatibility we still provide nvclock and memclock; + * those are the same as nvclockmin and memclockmin. * * Note: These clock values take into account the offset * set by clients through NV_CTRL_GPU_NVCLOCK_OFFSET and @@ -4028,14 +4034,6 @@ * for the perf level * "memtransferrateeditable" integer - if the memory transfer rate is editable * for the perf level - * "processorclock" integer - the processor clocks (in MHz) - * for the perf level - * "processorclockmin" integer - the processor clocks min (in MHz) - * for the perf level - * "processorclockmax" integer - the processor clocks max (in MHz) - * for the perf level - * "processorclockeditable" integer - if the processor clock domain is editable - * for the perf level * * Example: * @@ -4101,11 +4099,8 @@ /* * NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS - returns a string with the - * associated NV Clock, Memory Clock and Processor Clock values. + * associated NV Clock and Memory Clock values. * - * Current valid tokens are "nvclock", "nvclockmin", "nvclockmax", - * "memclock", "memclockmin", "memclockmax", "processorclock", - * "processorclockmin" and "processorclockmax". * Not all tokens will be reported on all GPUs, and additional tokens * may be added in the future. * @@ -4136,14 +4131,6 @@ * for the perf level * "memtransferrateeditable" integer - if the memory transfer rate is editable * for the perf level - * "processorclock" integer - the processor clocks (in MHz) - * for the perf level - * "processorclockmin" integer - the processor clocks min (in MHz) - * for the perf level - * "processorclockmax" integer - the processor clocks max (in MHz) - * for the perf level - * "processorclockeditable" integer - if the processor clock domain is editable - * for the perf level * * Example: * @@ -4155,7 +4142,7 @@ * using an NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. */ -#define NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS 34 /* RW-G */ +#define NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS 34 /* R--G */ /* * NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_HARDWARE_REVISION - Returns the @@ -4351,9 +4338,15 @@ */ #define NV_CTRL_STRING_DISPLAY_NAME_CONNECTOR 56 /* R-D- */ +/* + * NV_CTRL_STRING_MUX_STATE - Controls whether the mux specified is configured to + * use the integrated or discrete GPU. + */ +#define NV_CTRL_STRING_MUX_STATE 57 /* RW--- */ + #define NV_CTRL_STRING_LAST_ATTRIBUTE \ - NV_CTRL_STRING_DISPLAY_NAME_CONNECTOR + NV_CTRL_STRING_MUX_STATE /**************************************************************************/ @@ -4748,8 +4741,24 @@ #define NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU 20 /* R--G */ +/* + * NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS - Returns volatile or aggregate + * detailed ECC error information of bit width specified. + * + * The format of the returned data is: + * + * 4 * n int number of ECC errors where n is equal to + NVML_MEMORY_LOCATION_COUNT. + * + * This attribute is queried through NVML. + */ +#define NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_SINGLE_BIT 21 /* R--G */ +#define NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_DOUBLE_BIT 22 /* R--G */ +#define NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_SINGLE_BIT_AGGREGATE 23 /* R--G */ +#define NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_DOUBLE_BIT_AGGREGATE 24 /* R--G */ + #define NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE \ - NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU + NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_DOUBLE_BIT_AGGREGATE /**************************************************************************/ @@ -5015,6 +5024,7 @@ * ATTRIBUTE_TYPE_COOLER - Attribute is valid for Cooler target types. * ATTRIBUTE_TYPE_3D_VISION_PRO_TRANSCEIVER - Attribute is valid for 3D Vision * Pro Transceiver target types. + * ATTRIBUTE_TYPE_MUX - Attribute is valid for Multiplexer target types. * * See 'Key to Integer Attribute "Permissions"' at the top of this * file for a description of what these permission bits mean. @@ -5043,6 +5053,7 @@ #define ATTRIBUTE_TYPE_COOLER 0x200 #define ATTRIBUTE_TYPE_THERMAL_SENSOR 0x400 #define ATTRIBUTE_TYPE_3D_VISION_PRO_TRANSCEIVER 0x800 +#define ATTRIBUTE_TYPE_MUX 0x1000 #define ATTRIBUTE_TYPE_ALL_TARGETS \ ((ATTRIBUTE_TYPE_DISPLAY) | \ @@ -5053,7 +5064,9 @@ (ATTRIBUTE_TYPE_GVI) | \ (ATTRIBUTE_TYPE_COOLER) | \ (ATTRIBUTE_TYPE_THERMAL_SENSOR) | \ - (ATTRIBUTE_TYPE_3D_VISION_PRO_TRANSCEIVER)) + (ATTRIBUTE_TYPE_3D_VISION_PRO_TRANSCEIVER) | \ + (ATTRIBUTE_TYPE_MUX)) + typedef struct _NVCTRLAttributeValidValues { int type; diff -Nru nvidia-settings-470.57.01/src/libXNVCtrl/utils.mk nvidia-settings-510.47.03/src/libXNVCtrl/utils.mk --- nvidia-settings-470.57.01/src/libXNVCtrl/utils.mk 2021-07-07 22:48:21.000000000 +0000 +++ nvidia-settings-510.47.03/src/libXNVCtrl/utils.mk 2022-01-24 23:51:09.000000000 +0000 @@ -59,6 +59,10 @@ HOST_CC_ONLY_CFLAGS += -Wno-format-zero-length HOST_CFLAGS += -Wno-unused-parameter +# Treat warnings as errors, if requested +WARNINGS_AS_ERRORS ?= +CFLAGS += $(if $(WARNINGS_AS_ERRORS),-Werror) + DEBUG ?= DEVELOP ?= @@ -182,6 +186,8 @@ NV_GENERATED_HEADERS ?= +PCIACCESS_CFLAGS ?= +PCIACCESS_LDFLAGS ?= ############################################################################## # This makefile uses the $(eval) builtin function, which was added in @@ -376,6 +382,7 @@ BUILD_OBJECT_LIST = \ $(call BUILD_OBJECT_LIST_WITH_DIR,$(1),$(OUTPUTDIR)) +$(call BUILD_OBJECT_LIST,nvpci-utils.c): CFLAGS += $(PCIACCESS_CFLAGS) ############################################################################## # function to generate a list of dependency files from their diff -Nru nvidia-settings-470.57.01/src/libXNVCtrl/version.mk nvidia-settings-510.47.03/src/libXNVCtrl/version.mk --- nvidia-settings-470.57.01/src/libXNVCtrl/version.mk 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/libXNVCtrl/version.mk 2022-01-24 23:51:09.000000000 +0000 @@ -1,4 +1,4 @@ -NVIDIA_VERSION = 470.57.01 +NVIDIA_VERSION = 510.47.03 # This file. VERSION_MK_FILE := $(lastword $(MAKEFILE_LIST)) diff -Nru nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributes.c nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributes.c --- nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributes.c 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributes.c 2022-01-24 23:51:09.000000000 +0000 @@ -100,6 +100,14 @@ CTRL_TARGET_PERM_BIT(DISPLAY_TARGET), /* permission_bit */ NV_FALSE, /* uses_display_devices */ 1, 27 }, /* required major,minor protocol rev */ + + [MUX_TARGET] = + { "Mux Device", /* name */ + "mux", /* parsed_name */ + NV_CTRL_TARGET_TYPE_MUX, /* nvctrl */ + CTRL_TARGET_PERM_BIT(MUX_TARGET), /* permission_bit */ + NV_FALSE, /* uses_display_devices */ + 1, 28 }, /* required major,minor protocol rev */ }; const int targetTypeInfoTableLen = ARRAY_LEN(targetTypeInfoTable); @@ -121,6 +129,7 @@ case THERMAL_SENSOR_TARGET: case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET: case DISPLAY_TARGET: + case MUX_TARGET: return TRUE; default: return FALSE; @@ -587,6 +596,7 @@ int *val) { const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target); + ReturnStatus ret = NvCtrlMissingExtension; if (h == NULL) { return NvCtrlBadHandle; @@ -597,9 +607,9 @@ case THERMAL_SENSOR_TARGET: case COOLER_TARGET: { - ReturnStatus ret = NvCtrlNvmlQueryTargetCount(ctrl_target, - target_type, - val); + ret = NvCtrlNvmlQueryTargetCount(ctrl_target, + target_type, + val); if ((ret != NvCtrlMissingExtension) && (ret != NvCtrlBadHandle) && (ret != NvCtrlNotSupported)) { @@ -611,6 +621,14 @@ case X_SCREEN_TARGET: case FRAMELOCK_TARGET: case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET: + case MUX_TARGET: + if (!h->nv) { + /* + * If there is no connection to the X Driver, return the + * non-success value from the NVML query, if available. + */ + return ret; + } return NvCtrlNvControlQueryTargetCount(h, target_type, val); default: return NvCtrlBadHandle; @@ -664,6 +682,7 @@ CtrlAttributePerms *perms) { const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target); + ReturnStatus ret = NvCtrlError; if (h == NULL) { return NvCtrlBadHandle; @@ -678,6 +697,12 @@ case CTRL_ATTRIBUTE_TYPE_STRING: case CTRL_ATTRIBUTE_TYPE_BINARY_DATA: case CTRL_ATTRIBUTE_TYPE_STRING_OPERATION: + + ret = NvCtrlNvmlGetAttributePerms(h, attr_type, attr, perms); + + if (ret == NvCtrlSuccess || h->dpy == NULL) { + return ret; + } return NvCtrlNvControlGetAttributePerms(h, attr_type, attr, perms); case CTRL_ATTRIBUTE_TYPE_COLOR: @@ -750,18 +775,17 @@ if (((attr >= 0) && (attr <= NV_CTRL_LAST_ATTRIBUTE)) || ((attr >= NV_CTRL_ATTR_NV_BASE) && (attr <= NV_CTRL_ATTR_NV_LAST_ATTRIBUTE))) { + ReturnStatus ret = NvCtrlMissingExtension; switch (h->target_type) { case GPU_TARGET: case THERMAL_SENSOR_TARGET: case COOLER_TARGET: { - ReturnStatus ret = NvCtrlNvmlGetAttribute(ctrl_target, - attr, - val); - if ((ret != NvCtrlMissingExtension) && - (ret != NvCtrlBadHandle) && - (ret != NvCtrlNotSupported)) { + ret = NvCtrlNvmlGetAttribute(ctrl_target, + attr, + val); + if (ret == NvCtrlSuccess) { return ret; } } @@ -770,7 +794,14 @@ case X_SCREEN_TARGET: case FRAMELOCK_TARGET: case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET: - if (!h->nv) return NvCtrlMissingExtension; + case MUX_TARGET: + if (!h->nv) { + /* + * If there is no connection to the X Driver, return the + * non-success value from the NVML query, if available. + */ + return ret; + } return NvCtrlNvControlGetAttribute(h, display_mask, attr, val); default: return NvCtrlBadHandle; @@ -804,6 +835,7 @@ int attr, int val) { NvCtrlAttributePrivateHandle *h = getPrivateHandle(ctrl_target); + ReturnStatus ret = NvCtrlMissingExtension; if (h == NULL) { return NvCtrlBadHandle; @@ -815,7 +847,6 @@ case THERMAL_SENSOR_TARGET: case COOLER_TARGET: { - ReturnStatus ret; ret = NvCtrlNvmlSetAttribute(ctrl_target, attr, display_mask, @@ -831,8 +862,13 @@ case X_SCREEN_TARGET: case FRAMELOCK_TARGET: case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET: + case MUX_TARGET: if (!h->nv) { - return NvCtrlMissingExtension; + /* + * If there is no connection to the X Driver, return the + * non-success value from the NVML query, if available. + */ + return ret; } return NvCtrlNvControlSetAttribute(h, display_mask, attr, val); default: @@ -879,6 +915,7 @@ CtrlAttributeValidValues *val) { const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target); + ReturnStatus ret = NvCtrlMissingExtension; if (h == NULL) { return NvCtrlBadHandle; @@ -890,13 +927,10 @@ case THERMAL_SENSOR_TARGET: case COOLER_TARGET: { - ReturnStatus ret; ret = NvCtrlNvmlGetValidAttributeValues(ctrl_target, attr, val); - if ((ret != NvCtrlMissingExtension) && - (ret != NvCtrlBadHandle) && - (ret != NvCtrlNotSupported)) { + if (ret == NvCtrlSuccess) { return ret; } } @@ -905,8 +939,13 @@ case X_SCREEN_TARGET: case FRAMELOCK_TARGET: case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET: + case MUX_TARGET: if (!h->nv) { - return NvCtrlMissingExtension; + /* + * If there is no connection to the X Driver, return the + * non-success value from the NVML query, if available. + */ + return ret; } return NvCtrlNvControlGetValidAttributeValues(h, display_mask, attr, val); @@ -952,6 +991,7 @@ CtrlAttributeValidValues *val) { const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target); + ReturnStatus ret = NvCtrlMissingExtension; if (h == NULL) { return NvCtrlBadHandle; @@ -963,13 +1003,10 @@ case THERMAL_SENSOR_TARGET: case COOLER_TARGET: { - ReturnStatus ret; ret = NvCtrlNvmlGetValidStringAttributeValues(ctrl_target, attr, val); - if ((ret != NvCtrlMissingExtension) && - (ret != NvCtrlBadHandle) && - (ret != NvCtrlNotSupported)) { + if (ret == NvCtrlSuccess) { return ret; } } @@ -978,8 +1015,13 @@ case X_SCREEN_TARGET: case FRAMELOCK_TARGET: case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET: + case MUX_TARGET: if (!h->nv) { - return NvCtrlMissingExtension; + /* + * If there is no connection to the X Driver, return the + * non-success value from the NVML query, if available. + */ + return ret; } return NvCtrlNvControlGetValidStringDisplayAttributeValues( h, display_mask, attr, val); @@ -1061,6 +1103,7 @@ case X_SCREEN_TARGET: case FRAMELOCK_TARGET: case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET: + case MUX_TARGET: if ((attr >= 0) && (attr <= NV_CTRL_STRING_LAST_ATTRIBUTE)) { if (!h->nv) return NvCtrlMissingExtension; return NvCtrlNvControlGetStringAttribute(h, display_mask, attr, ptr); @@ -1141,6 +1184,7 @@ case X_SCREEN_TARGET: case FRAMELOCK_TARGET: case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET: + case MUX_TARGET: if (!h->nv) return NvCtrlMissingExtension; return NvCtrlNvControlSetStringAttribute(h, display_mask, attr, ptr); @@ -1158,6 +1202,7 @@ unsigned char **data, int *len) { const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target); + ReturnStatus ret = NvCtrlMissingExtension; if (h == NULL) { return NvCtrlBadHandle; @@ -1168,10 +1213,10 @@ case THERMAL_SENSOR_TARGET: case COOLER_TARGET: { - ReturnStatus ret = NvCtrlNvmlGetBinaryAttribute(ctrl_target, - attr, - data, - len); + ret = NvCtrlNvmlGetBinaryAttribute(ctrl_target, + attr, + data, + len); if ((ret != NvCtrlMissingExtension) && (ret != NvCtrlBadHandle) && (ret != NvCtrlNotSupported)) { @@ -1183,6 +1228,13 @@ case X_SCREEN_TARGET: case FRAMELOCK_TARGET: case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET: + if (!h->nv) { + /* + * If there is no connection to the X Driver, return the + * non-success value from the NVML query, if available. + */ + return ret; + } return NvCtrlNvControlGetBinaryAttribute(h, display_mask, attr, data, len); default: return NvCtrlBadHandle; @@ -1621,6 +1673,11 @@ return NULL; } + if (!h->dpy && !h->nv && h->nvml) { + /* We are running with NVML lib only. Events not yet supported.*/ + return NULL; + } + /* Look for the event handle */ evt_h = NULL; for (evt_hnode = __event_handles; diff -Nru nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributes.h nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributes.h --- nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributes.h 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributes.h 2022-01-24 23:51:09.000000000 +0000 @@ -44,6 +44,7 @@ THERMAL_SENSOR_TARGET, NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET, DISPLAY_TARGET, + MUX_TARGET, MAX_TARGET_TYPES, INVALID_TARGET = -1 @@ -138,6 +139,7 @@ char *display; /* string for XOpenDisplay */ Display *dpy; /* X display connection */ Bool has_nv_control; + Bool has_nvml; CtrlTargetNode *targets[MAX_TARGET_TYPES]; /* Shadows targetTypeTable */ CtrlTargetNode *physical_screens; @@ -573,6 +575,17 @@ #define NV_CTRL_STRING_XV_LAST_ATTRIBUTE (NV_CTRL_STRING_XV_VERSION) +/* + * Additional XVideo string attributes for NvCtrlGetStringDisplayAttribute(); + */ + +#define NV_CTRL_STRING_NVML_BASE (NV_CTRL_STRING_XV_LAST_ATTRIBUTE + 1) + +#define NV_CTRL_STRING_NVML_VERSION (NV_CTRL_STRING_NVML_BASE) + +#define NV_CTRL_STRING_NVML_LAST_ATTRIBUTE (NV_CTRL_STRING_NVML_VERSION) + + #define NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM 0x1 #define NV_CTRL_ATTRIBUTES_XF86VIDMODE_SUBSYSTEM 0x2 diff -Nru nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c --- nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributesNvControl.c 2022-01-24 23:51:09.000000000 +0000 @@ -41,7 +41,12 @@ NvCtrlNvControlAttributes *nv; int ret, major, minor, event, error; const CtrlTargetTypeInfo *targetTypeInfo; - + + if (!h->dpy) { + nv_warning_msg("NV-CONTROL Display not found."); + return NULL; + } + ret = XNVCTRLQueryExtension (h->dpy, &event, &error); if (ret != True) { nv_warning_msg("NV-CONTROL extension not found on this Display."); @@ -160,6 +165,11 @@ return NvCtrlBadArgument; } + if (!h->dpy) { + nv_warning_msg("NV-CONTROL Display not found."); + return NvCtrlError; + } + ret = XNVCTRLQueryTargetCount(h->dpy, targetTypeInfo->nvctrl, val); return (ret) ? NvCtrlSuccess : NvCtrlError; @@ -174,6 +184,10 @@ int value_32; int major, minor; + if (!h->nv) { + return NvCtrlMissingExtension; + } + major = h->nv->major_version; minor = h->nv->minor_version; @@ -287,6 +301,9 @@ dst->valid_targets |= CTRL_TARGET_PERM_BIT(NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET); } + if (permissions & ATTRIBUTE_TYPE_MUX) { + dst->valid_targets |= CTRL_TARGET_PERM_BIT(MUX_TARGET); + } } diff -Nru nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c --- nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c 2022-01-24 23:51:09.000000000 +0000 @@ -39,6 +39,15 @@ #define MAX_NVML_STR_LEN 64 +static inline const NvCtrlNvmlAttributes * +getNvmlHandleConst(const NvCtrlAttributePrivateHandle *h) +{ + if ((h == NULL) || (h->nvml == NULL) || (h->target_type != GPU_TARGET)) { + return NULL; + } + + return h->nvml; +} static void printNvmlError(nvmlReturn_t error) { @@ -192,14 +201,29 @@ GET_SYMBOL_REQUIRED(deviceGetUUID, "nvmlDeviceGetUUID"); GET_SYMBOL_REQUIRED(deviceGetCount, "nvmlDeviceGetCount"); GET_SYMBOL_REQUIRED(deviceGetTemperature, "nvmlDeviceGetTemperature"); - GET_SYMBOL_REQUIRED(deviceGetFanSpeed, "nvmlDeviceGetFanSpeed"); GET_SYMBOL_REQUIRED(deviceGetName, "nvmlDeviceGetName"); GET_SYMBOL_REQUIRED(deviceGetVbiosVersion, "nvmlDeviceGetVbiosVersion"); GET_SYMBOL_REQUIRED(deviceGetMemoryInfo, "nvmlDeviceGetMemoryInfo"); GET_SYMBOL_REQUIRED(deviceGetPciInfo, "nvmlDeviceGetPciInfo"); + GET_SYMBOL_REQUIRED(deviceGetCurrPcieLinkWidth, "nvmlDeviceGetCurrPcieLinkWidth"); GET_SYMBOL_REQUIRED(deviceGetMaxPcieLinkGeneration, "nvmlDeviceGetMaxPcieLinkGeneration"); GET_SYMBOL_REQUIRED(deviceGetMaxPcieLinkWidth, "nvmlDeviceGetMaxPcieLinkWidth"); GET_SYMBOL_REQUIRED(deviceGetVirtualizationMode, "nvmlDeviceGetVirtualizationMode"); + GET_SYMBOL_REQUIRED(deviceGetUtilizationRates, "nvmlDeviceGetUtilizationRates"); + GET_SYMBOL_REQUIRED(deviceGetTemperatureThreshold, "nvmlDeviceGetTemperatureThreshold"); + GET_SYMBOL_REQUIRED(deviceGetFanSpeed_v2, "nvmlDeviceGetFanSpeed_v2"); + GET_SYMBOL_REQUIRED(systemGetDriverVersion, "nvmlSystemGetDriverVersion"); + GET_SYMBOL_REQUIRED(deviceGetEccMode, "nvmlDeviceGetEccMode"); + GET_SYMBOL_REQUIRED(deviceSetEccMode, "nvmlDeviceSetEccMode"); + GET_SYMBOL_REQUIRED(deviceGetTotalEccErrors, "nvmlDeviceGetTotalEccErrors"); + GET_SYMBOL_REQUIRED(deviceClearEccErrorCounts, "nvmlDeviceClearEccErrorCounts"); + GET_SYMBOL_REQUIRED(systemGetNVMLVersion, "nvmlSystemGetNVMLVersion"); + GET_SYMBOL_REQUIRED(deviceGetMemoryErrorCounter, "nvmlDeviceGetMemoryErrorCounter"); + GET_SYMBOL_REQUIRED(deviceGetNumGpuCores, "nvmlDeviceGetNumGpuCores"); + GET_SYMBOL_REQUIRED(deviceGetMemoryBusWidth, "nvmlDeviceGetMemoryBusWidth"); + GET_SYMBOL_REQUIRED(deviceGetIrqNum, "nvmlDeviceGetIrqNum"); + GET_SYMBOL_REQUIRED(deviceGetPowerSource, "nvmlDeviceGetPowerSource"); + GET_SYMBOL_REQUIRED(deviceGetNumFans, "nvmlDeviceGetNumFans"); #undef GET_SYMBOL_REQUIRED /* Do not fail with older drivers */ @@ -207,6 +231,7 @@ nvml->lib._proc = dlsym(nvml->lib.handle, _name); GET_SYMBOL_OPTIONAL(deviceGetGridLicensableFeatures, "nvmlDeviceGetGridLicensableFeatures_v4"); + GET_SYMBOL_OPTIONAL(deviceGetMemoryInfo_v2, "nvmlDeviceGetMemoryInfo_v2"); #undef GET_SYMBOL_OPTIONAL ret = nvml->lib.init(); @@ -243,8 +268,8 @@ int nvctrlGpuCount = 0; /* Get the gpu count returned by NV-CONTROL. */ - if (!XNVCTRLQueryTargetCount(h->dpy, NV_CTRL_TARGET_TYPE_GPU, - &nvctrlGpuCount)) { + if (h->nv && !XNVCTRLQueryTargetCount(h->dpy, NV_CTRL_TARGET_TYPE_GPU, + &nvctrlGpuCount)) { return FALSE; } @@ -367,7 +392,7 @@ nvmlReturn_t ret = nvml->lib.deviceGetHandleByIndex(devIdx, &device); if (ret == NVML_SUCCESS) { unsigned int temp; - unsigned int speed; + unsigned int fans; /* * XXX Currently, NVML only allows to get the GPU temperature so @@ -387,12 +412,7 @@ nvml->sensorCount++; } - /* - * XXX NVML assumes at most 1 fan per GPU so check for - * nvmlDeviceGetFanSpeed success to figure out if that fan is - * available. - */ - ret = nvml->lib.deviceGetFanSpeed(device, &speed); + ret = nvml->lib.deviceGetNumFans(device, &fans); if (ret == NVML_SUCCESS) { if ((h->target_type == COOLER_TARGET) && (h->target_id == nvml->coolerCount)) { @@ -400,21 +420,20 @@ nvml->deviceIdx = devIdx; } - nvml->coolerCountPerGPU[i] = 1; - nvml->coolerCount++; + nvml->coolerCountPerGPU[i] = fans; + nvml->coolerCount += fans; } } } /* - * NVML doesn't have support to handle more than 1 fan per GPU. Make sure - * total number of cooler probed by NVML are same as that of reported by - * NV-CONTROL, otherwise do not initialize NVML sub-system. + * Consistency check between X/NV-CONTROL and NVML. */ - if (!XNVCTRLQueryTargetCount(h->dpy, NV_CTRL_TARGET_TYPE_COOLER, - &nvctrlCoolerCount) || - (nvctrlCoolerCount != nvml->coolerCount)) { - goto fail; + if (h->nv && + (!XNVCTRLQueryTargetCount(h->dpy, NV_CTRL_TARGET_TYPE_COOLER, + &nvctrlCoolerCount) || + (nvctrlCoolerCount != nvml->coolerCount))) { + nv_warning_msg("Inconsistent number of fans detected."); } nvfree(nvctrlToNvmlId); @@ -495,10 +514,50 @@ /* - * Get NVML String Attribute Values + * Get NVML String Attribute Values that do not require a control target. */ -#ifdef NVML_EXPERIMENTAL +static ReturnStatus NvCtrlNvmlGetGeneralStringAttribute(const CtrlTarget *ctrl_target, + int attr, char **ptr) +{ + char res[MAX_NVML_STR_LEN]; + const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target); + nvmlReturn_t ret; + *ptr = NULL; + + if ((h == NULL) || (h->nvml == NULL)) { + return NvCtrlBadHandle; + } + + switch (attr) { + case NV_CTRL_STRING_NVIDIA_DRIVER_VERSION: + ret = h->nvml->lib.systemGetDriverVersion(res, MAX_NVML_STR_LEN); + break; + + case NV_CTRL_STRING_NVML_VERSION: + ret = h->nvml->lib.systemGetNVMLVersion(res, MAX_NVML_STR_LEN); + break; + + default: + /* This is expected to fall through silently. */ + return NvCtrlNotSupported; + } + + if (ret == NVML_SUCCESS) { + *ptr = strdup(res); + return NvCtrlSuccess; + } + + /* An NVML error occurred */ + printNvmlError(ret); + return NvCtrlNotSupported; +} + + + +/* + * Get NVML String Attribute Values + */ static ReturnStatus NvCtrlNvmlGetGPUStringAttribute(const CtrlTarget *ctrl_target, int attr, char **ptr) @@ -510,12 +569,11 @@ nvmlReturn_t ret; *ptr = NULL; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; - ret = nvml->lib.deviceGetHandleByIndex(nvml->deviceIdx, &device); if (ret == NVML_SUCCESS) { switch (attr) { @@ -531,11 +589,33 @@ ret = nvml->lib.deviceGetUUID(device, res, MAX_NVML_STR_LEN); break; - case NV_CTRL_STRING_NVIDIA_DRIVER_VERSION: + case NV_CTRL_STRING_GPU_UTILIZATION: + { + nvmlUtilization_t util; + + if (ctrl_target->system->has_nv_control) { + /* + * Not all utilization types are currently available via + * NVML so, if accessible, get the rates from X. + */ + return NvCtrlNotSupported; + } + + ret = nvml->lib.deviceGetUtilizationRates(device, &util); + + if (ret != NVML_SUCCESS) { + break; + } + + snprintf(res, sizeof(res), + "graphics=%d, memory=%d", + util.gpu, util.memory); + + break; + } case NV_CTRL_STRING_SLI_MODE: case NV_CTRL_STRING_PERFORMANCE_MODES: case NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS: - case NV_CTRL_STRING_GPU_UTILIZATION: case NV_CTRL_STRING_MULTIGPU_MODE: /* * XXX We'll eventually need to add support for this attributes @@ -562,22 +642,26 @@ return NvCtrlNotSupported; } -#endif // NVML_EXPERIMENTAL + ReturnStatus NvCtrlNvmlGetStringAttribute(const CtrlTarget *ctrl_target, int attr, char **ptr) { + ReturnStatus ret; + if (NvmlMissing(ctrl_target)) { return NvCtrlMissingExtension; } -#ifdef NVML_EXPERIMENTAL /* - * This shouldn't be reached for target types that are not handled through - * NVML (Keep TARGET_TYPE_IS_NVML_COMPATIBLE in NvCtrlAttributesPrivate.h up - * to date). + * Check for attributes that don't require a target, else continue to + * supported target types. */ - assert(TARGET_TYPE_IS_NVML_COMPATIBLE(NvCtrlGetTargetType(ctrl_target))); + ret = NvCtrlNvmlGetGeneralStringAttribute(ctrl_target, attr, ptr); + + if (ret == NvCtrlSuccess) { + return NvCtrlSuccess; + } switch (NvCtrlGetTargetType(ctrl_target)) { case GPU_TARGET: @@ -600,10 +684,6 @@ default: return NvCtrlBadHandle; } - -#else - return NvCtrlNotSupported; -#endif } @@ -612,7 +692,7 @@ * Set NVML String Attribute Values */ -#ifdef NVML_EXPERIMENTAL + static ReturnStatus NvCtrlNvmlSetGPUStringAttribute(CtrlTarget *ctrl_target, int attr, const char *ptr) @@ -622,12 +702,11 @@ nvmlDevice_t device; nvmlReturn_t ret; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; - ret = nvml->lib.deviceGetHandleByIndex(nvml->deviceIdx, &device); if (ret == NVML_SUCCESS) { switch (attr) { @@ -656,7 +735,7 @@ return NvCtrlNotSupported; } -#endif // NVML_EXPERIMENTAL + ReturnStatus NvCtrlNvmlSetStringAttribute(CtrlTarget *ctrl_target, int attr, const char *ptr) @@ -665,7 +744,6 @@ return NvCtrlMissingExtension; } -#ifdef NVML_EXPERIMENTAL /* * This shouldn't be reached for target types that are not handled through * NVML (Keep TARGET_TYPE_IS_NVML_COMPATIBLE in NvCtrlAttributesPrivate.h up @@ -695,10 +773,6 @@ default: return NvCtrlBadHandle; } - -#else - return NvCtrlNotSupported; -#endif } @@ -710,35 +784,49 @@ static ReturnStatus NvCtrlNvmlGetGPUAttribute(const CtrlTarget *ctrl_target, int attr, int64_t *val) { - unsigned int res; + unsigned int res = 0; const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target); const NvCtrlNvmlAttributes *nvml; nvmlDevice_t device; nvmlReturn_t ret; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; - ret = nvml->lib.deviceGetHandleByIndex(nvml->deviceIdx, &device); if (ret == NVML_SUCCESS) { switch (attr) { -#ifdef NVML_EXPERIMENTAL case NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY: case NV_CTRL_USED_DEDICATED_GPU_MEMORY: { - nvmlMemory_t memory; - ret = nvml->lib.deviceGetMemoryInfo(device, &memory); - if (ret == NVML_SUCCESS) { - switch (attr) { - case NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY: - res = memory.total >> 20; // bytes --> MB - break; - case NV_CTRL_USED_DEDICATED_GPU_MEMORY: - res = memory.used >> 20; // bytes --> MB - break; + if (nvml->lib.deviceGetMemoryInfo_v2) { + nvmlMemory_v2_t memory; + memory.version = nvmlMemory_v2; + ret = nvml->lib.deviceGetMemoryInfo_v2(device, &memory); + if (ret == NVML_SUCCESS) { + switch (attr) { + case NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY: + res = memory.total >> 20; // bytes --> MB + break; + case NV_CTRL_USED_DEDICATED_GPU_MEMORY: + res = memory.used >> 20; // bytes --> MB + break; + } + } + } else { + nvmlMemory_t memory; + ret = nvml->lib.deviceGetMemoryInfo(device, &memory); + if (ret == NVML_SUCCESS) { + switch (attr) { + case NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY: + res = memory.total >> 20; // bytes --> MB + break; + case NV_CTRL_USED_DEDICATED_GPU_MEMORY: + res = memory.used >> 20; // bytes --> MB + break; + } } } } @@ -787,43 +875,132 @@ ret = nvml->lib.deviceGetMaxPcieLinkGeneration(device, &res); break; + case NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH: + ret = nvml->lib.deviceGetCurrPcieLinkWidth(device, &res); + break; case NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH: ret = nvml->lib.deviceGetMaxPcieLinkWidth(device, &res); break; -#else - case NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY: - case NV_CTRL_USED_DEDICATED_GPU_MEMORY: - case NV_CTRL_PCI_DOMAIN: - case NV_CTRL_PCI_BUS: - case NV_CTRL_PCI_DEVICE: - case NV_CTRL_PCI_FUNCTION: - case NV_CTRL_PCI_ID: - case NV_CTRL_GPU_PCIE_GENERATION: - case NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH: -#endif // NVML_EXPERIMENTAL + case NV_CTRL_GPU_SLOWDOWN_THRESHOLD: + ret = nvml->lib.deviceGetTemperatureThreshold(device, + NVML_TEMPERATURE_THRESHOLD_SLOWDOWN ,&res); + break; + case NV_CTRL_GPU_SHUTDOWN_THRESHOLD: + ret = nvml->lib.deviceGetTemperatureThreshold(device, + NVML_TEMPERATURE_THRESHOLD_SHUTDOWN ,&res); + break; + case NV_CTRL_GPU_CORE_TEMPERATURE: + ret = nvml->lib.deviceGetTemperature(device, + NVML_TEMPERATURE_GPU, + &res); + break; + + case NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED: + case NV_CTRL_GPU_ECC_SUPPORTED: + { + nvmlEnableState_t current, pending; + ret = nvml->lib.deviceGetEccMode(device, ¤t, &pending); + switch (attr) { + case NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED: + res = (ret == NVML_SUCCESS) ? + NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED_TRUE : + NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED_FALSE; + break; + case NV_CTRL_GPU_ECC_SUPPORTED: + res = (ret == NVML_SUCCESS) ? + NV_CTRL_GPU_ECC_SUPPORTED_TRUE : + NV_CTRL_GPU_ECC_SUPPORTED_FALSE; + break; + } + + // Avoid printing misleading error message + if (ret == NVML_ERROR_NOT_SUPPORTED) { + ret = NVML_SUCCESS; + } + } + break; + + case NV_CTRL_GPU_ECC_CONFIGURATION: + case NV_CTRL_GPU_ECC_STATUS: + { + nvmlEnableState_t current, pending; + ret = nvml->lib.deviceGetEccMode(device, ¤t, &pending); + if (ret == NVML_SUCCESS) { + switch (attr) { + case NV_CTRL_GPU_ECC_STATUS: + res = current; + break; + case NV_CTRL_GPU_ECC_CONFIGURATION: + res = pending; + break; + } + } + } + break; + + case NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS: + case NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS: + case NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS: + case NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS: + { + unsigned long long eccCounts; + nvmlEccCounterType_t counterType; + nvmlMemoryErrorType_t errorType; + switch (attr) { + case NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS: + errorType = NVML_MEMORY_ERROR_TYPE_CORRECTED; + counterType = NVML_VOLATILE_ECC; + break; + case NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS: + errorType = NVML_MEMORY_ERROR_TYPE_CORRECTED; + counterType = NVML_AGGREGATE_ECC; + break; + case NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS: + errorType = NVML_MEMORY_ERROR_TYPE_UNCORRECTED; + counterType = NVML_VOLATILE_ECC; + break; + case NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS: + errorType = NVML_MEMORY_ERROR_TYPE_UNCORRECTED; + counterType = NVML_AGGREGATE_ECC; + break; + } + + ret = nvml->lib.deviceGetTotalEccErrors(device, errorType, + counterType, &eccCounts); + if (ret == NVML_SUCCESS) { + if (val) { + *val = eccCounts; + } + return NvCtrlSuccess; + } + } + break; + + case NV_CTRL_GPU_CORES: + ret = nvml->lib.deviceGetNumGpuCores(device, &res); + break; + case NV_CTRL_GPU_MEMORY_BUS_WIDTH: + ret = nvml->lib.deviceGetMemoryBusWidth(device, &res); + break; + case NV_CTRL_IRQ: + ret = nvml->lib.deviceGetIrqNum(device, &res); + break; + case NV_CTRL_GPU_POWER_SOURCE: + assert(NV_CTRL_GPU_POWER_SOURCE_AC == NVML_POWER_SOURCE_AC); + assert(NV_CTRL_GPU_POWER_SOURCE_BATTERY == NVML_POWER_SOURCE_BATTERY); + ret = nvml->lib.deviceGetPowerSource(device, &res); + break; + + case NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION: case NV_CTRL_VIDEO_RAM: - case NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH: case NV_CTRL_GPU_PCIE_MAX_LINK_SPEED: case NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED: case NV_CTRL_BUS_TYPE: - case NV_CTRL_GPU_MEMORY_BUS_WIDTH: - case NV_CTRL_GPU_CORES: - case NV_CTRL_IRQ: case NV_CTRL_GPU_COOLER_MANUAL_CONTROL: - case NV_CTRL_GPU_POWER_SOURCE: case NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL: case NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE: case NV_CTRL_GPU_POWER_MIZER_MODE: case NV_CTRL_GPU_POWER_MIZER_DEFAULT_MODE: - case NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE: - case NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT: - case NV_CTRL_GPU_ECC_SUPPORTED: - case NV_CTRL_GPU_ECC_STATUS: - case NV_CTRL_GPU_ECC_CONFIGURATION: - case NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION: - case NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS: - case NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS: - case NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED: case NV_CTRL_ENABLED_DISPLAYS: case NV_CTRL_CONNECTED_DISPLAYS: case NV_CTRL_MAX_SCREEN_WIDTH: @@ -838,10 +1015,8 @@ case NV_CTRL_ATTR_NV_MINOR_VERSION: case NV_CTRL_OPERATING_SYSTEM: case NV_CTRL_NO_SCANOUT: - case NV_CTRL_GPU_CORE_TEMPERATURE: case NV_CTRL_AMBIENT_TEMPERATURE: case NV_CTRL_GPU_CURRENT_CLOCK_FREQS: - case NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS: case NV_CTRL_VIDEO_ENCODER_UTILIZATION: case NV_CTRL_VIDEO_DECODER_UTILIZATION: case NV_CTRL_FRAMELOCK: @@ -888,14 +1063,16 @@ default: /* Did we forget to handle a GPU integer attribute? */ - nv_warning_msg("Unhandled integer attribute %s (%d) of GPU " - "(%d)", INT_ATTRIBUTE_NAME(attr), attr, - NvCtrlGetTargetId(ctrl_target)); + nv_info_msg("", "Unhandled integer attribute %s (%d) of GPU " + "(%d)", INT_ATTRIBUTE_NAME(attr), attr, + NvCtrlGetTargetId(ctrl_target)); return NvCtrlNotSupported; } if (ret == NVML_SUCCESS) { - *val = res; + if (val) { + *val = res; + } return NvCtrlSuccess; } } @@ -913,12 +1090,11 @@ nvmlDevice_t device; nvmlReturn_t ret; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; - ret = nvml->lib.deviceGetHandleByIndex(nvml->deviceIdx, &device); if (ret == NVML_SUCCESS) { switch (attr) { @@ -953,7 +1129,7 @@ return NvCtrlNotSupported; } -#ifdef NVML_EXPERIMENTAL + static int getThermalCoolerId(const NvCtrlAttributePrivateHandle *h, unsigned int thermalCoolerCount, @@ -987,12 +1163,11 @@ nvmlDevice_t device; nvmlReturn_t ret; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; - /* Get the proper device according to the sensor ID */ sensorId = getThermalCoolerId(h, nvml->sensorCount, nvml->sensorCountPerGPU); @@ -1005,11 +1180,7 @@ if (ret == NVML_SUCCESS) { switch (attr) { case NV_CTRL_THERMAL_SENSOR_READING: - ret = nvml->lib.deviceGetTemperature(device, - NVML_TEMPERATURE_GPU, - &res); - break; - + case NV_CTRL_THERMAL_SENSOR_PROVIDER: case NV_CTRL_THERMAL_SENSOR_TARGET: /* @@ -1020,9 +1191,9 @@ default: /* Did we forget to handle a sensor integer attribute? */ - nv_warning_msg("Unhandled integer attribute %s (%d) of " - "Thermal sensor (%d)", INT_ATTRIBUTE_NAME(attr), - attr, NvCtrlGetTargetId(ctrl_target)); + nv_info_msg("", "Unhandled integer attribute %s (%d) of " + "Thermal sensor (%d)", INT_ATTRIBUTE_NAME(attr), + attr, NvCtrlGetTargetId(ctrl_target)); return NvCtrlNotSupported; } @@ -1047,12 +1218,11 @@ nvmlDevice_t device; nvmlReturn_t ret; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; - /* Get the proper device according to the cooler ID */ coolerId = getThermalCoolerId(h, nvml->coolerCount, nvml->coolerCountPerGPU); @@ -1060,14 +1230,14 @@ return NvCtrlBadHandle; } - ret = nvml->lib.deviceGetHandleByIndex(nvml->deviceIdx, &device); if (ret == NVML_SUCCESS) { switch (attr) { - case NV_CTRL_THERMAL_COOLER_LEVEL: - ret = nvml->lib.deviceGetFanSpeed(device, &res); + case NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL: + ret = nvml->lib.deviceGetFanSpeed_v2(device, coolerId, &res); break; + case NV_CTRL_THERMAL_COOLER_LEVEL: case NV_CTRL_THERMAL_COOLER_SPEED: case NV_CTRL_THERMAL_COOLER_CONTROL_TYPE: case NV_CTRL_THERMAL_COOLER_TARGET: @@ -1079,9 +1249,9 @@ default: /* Did we forget to handle a cooler integer attribute? */ - nv_warning_msg("Unhandled integer attribute %s (%d) of Fan " - "(%d)", INT_ATTRIBUTE_NAME(attr), attr, - NvCtrlGetTargetId(ctrl_target)); + nv_info_msg("", "Unhandled integer attribute %s (%d) of Fan " + "(%d)", INT_ATTRIBUTE_NAME(attr), attr, + NvCtrlGetTargetId(ctrl_target)); return NvCtrlNotSupported; } @@ -1095,7 +1265,8 @@ printNvmlError(ret); return NvCtrlNotSupported; } -#endif // NVML_EXPERIMENTAL + + ReturnStatus NvCtrlNvmlGetAttribute(const CtrlTarget *ctrl_target, int attr, int64_t *val) @@ -1114,18 +1285,12 @@ switch (NvCtrlGetTargetType(ctrl_target)) { case GPU_TARGET: return NvCtrlNvmlGetGPUAttribute(ctrl_target, attr, val); -#ifdef NVML_EXPERIMENTAL case THERMAL_SENSOR_TARGET: return NvCtrlNvmlGetThermalAttribute(ctrl_target, attr, val); case COOLER_TARGET: return NvCtrlNvmlGetCoolerAttribute(ctrl_target, attr, val); -#else - case THERMAL_SENSOR_TARGET: - case COOLER_TARGET: - return NvCtrlNotSupported; -#endif default: - return NvCtrlBadHandle; + return NvCtrlNotSupported; } } @@ -1157,7 +1322,7 @@ * Set NVML Attribute Values */ -#ifdef NVML_EXPERIMENTAL + static ReturnStatus NvCtrlNvmlSetGPUAttribute(CtrlTarget *ctrl_target, int attr, int index, int val) @@ -1167,18 +1332,36 @@ nvmlDevice_t device; nvmlReturn_t ret; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; - ret = nvml->lib.deviceGetHandleByIndex(nvml->deviceIdx, &device); if (ret == NVML_SUCCESS) { switch (attr) { + case NV_CTRL_GPU_ECC_CONFIGURATION: + ret = nvml->lib.deviceSetEccMode(device, val); + break; + + case NV_CTRL_GPU_ECC_RESET_ERROR_STATUS: + { + nvmlEccCounterType_t counterType = 0; + switch (val) { + case NV_CTRL_GPU_ECC_RESET_ERROR_STATUS_VOLATILE: + counterType = NVML_VOLATILE_ECC; + break; + case NV_CTRL_GPU_ECC_RESET_ERROR_STATUS_AGGREGATE: + counterType = NVML_AGGREGATE_ECC; + break; + } + ret = nvml->lib.deviceClearEccErrorCounts(device, + counterType); + } + break; + case NV_CTRL_GPU_CURRENT_CLOCK_FREQS: case NV_CTRL_GPU_POWER_MIZER_MODE: - case NV_CTRL_GPU_ECC_CONFIGURATION: case NV_CTRL_GPU_COOLER_MANUAL_CONTROL: case NV_CTRL_DITHERING: case NV_CTRL_DITHERING_MODE: @@ -1195,9 +1378,9 @@ default: /* Did we forget to handle a GPU integer attribute? */ - nv_warning_msg("Unhandled integer attribute %s (%d) of GPU " - "(%d) (set to %d)", INT_ATTRIBUTE_NAME(attr), - attr, NvCtrlGetTargetId(ctrl_target), val); + nv_info_msg("", "Unhandled integer attribute %s (%d) of GPU " + "(%d) (set to %d)", INT_ATTRIBUTE_NAME(attr), + attr, NvCtrlGetTargetId(ctrl_target), val); return NvCtrlNotSupported; } @@ -1220,12 +1403,11 @@ nvmlDevice_t device; nvmlReturn_t ret; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; - /* Get the proper device according to the cooler ID */ coolerId = getThermalCoolerId(h, nvml->coolerCount, nvml->coolerCountPerGPU); @@ -1246,9 +1428,9 @@ default: /* Did we forget to handle a cooler integer attribute? */ - nv_warning_msg("Unhandled integer attribute %s (%d) of Fan " - "(%d) (set to %d)", INT_ATTRIBUTE_NAME(attr), - attr, NvCtrlGetTargetId(ctrl_target), val); + nv_info_msg("", "Unhandled integer attribute %s (%d) of Fan " + "(%d) (set to %d)", INT_ATTRIBUTE_NAME(attr), + attr, NvCtrlGetTargetId(ctrl_target), val); return NvCtrlNotSupported; } @@ -1262,7 +1444,7 @@ return NvCtrlNotSupported; } -#endif // NVML_EXPERIMENTAL + ReturnStatus NvCtrlNvmlSetAttribute(CtrlTarget *ctrl_target, int attr, int index, int val) @@ -1271,7 +1453,6 @@ return NvCtrlMissingExtension; } -#ifdef NVML_EXPERIMENTAL /* * This shouldn't be reached for target types that are not handled through * NVML (Keep TARGET_TYPE_IS_NVML_COMPATIBLE in NvCtrlAttributesPrivate.h up @@ -1285,9 +1466,9 @@ case THERMAL_SENSOR_TARGET: /* Did we forget to handle a sensor integer attribute? */ - nv_warning_msg("Unhandled integer attribute %s (%d) of Thermal " - "sensor (%d) (set to %d)", INT_ATTRIBUTE_NAME(attr), - attr, NvCtrlGetTargetId(ctrl_target), val); + nv_info_msg("", "Unhandled integer attribute %s (%d) of Thermal " + "sensor (%d) (set to %d)", INT_ATTRIBUTE_NAME(attr), + attr, NvCtrlGetTargetId(ctrl_target), val); return NvCtrlNotSupported; case COOLER_TARGET: @@ -1295,19 +1476,47 @@ default: return NvCtrlBadHandle; } - -#else - return NvCtrlNotSupported; -#endif } +static nvmlReturn_t getDeviceMemoryCounts(const CtrlTarget *ctrl_target, + const NvCtrlNvmlAttributes *nvml, + nvmlDevice_t device, + nvmlMemoryErrorType_t errorType, + nvmlEccCounterType_t counterType, + unsigned char **data, int *len) +{ + unsigned long long count; + int *counts = (int *) nvalloc(sizeof(int) * NVML_MEMORY_LOCATION_COUNT); + nvmlReturn_t ret, anySuccess = NVML_ERROR_NOT_SUPPORTED; + int i; + + for (i = NVML_MEMORY_LOCATION_L1_CACHE; + i < NVML_MEMORY_LOCATION_COUNT; + i++) { + + ret = nvml->lib.deviceGetMemoryErrorCounter(device, errorType, + counterType, i, &count); + if (ret == NVML_SUCCESS) { + anySuccess = NVML_SUCCESS; + counts[i] = (int) count; + } else { + counts[i] = -1; + } + } + + *data = (unsigned char *) counts; + *len = sizeof(int) * NVML_MEMORY_LOCATION_COUNT; + + return anySuccess; +} + /* * Get NVML Binary Attribute Values */ -#ifdef NVML_EXPERIMENTAL + static ReturnStatus NvCtrlNvmlGetGPUBinaryAttribute(const CtrlTarget *ctrl_target, @@ -1318,17 +1527,74 @@ nvmlDevice_t device; nvmlReturn_t ret; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; - ret = nvml->lib.deviceGetHandleByIndex(nvml->deviceIdx, &device); if (ret == NVML_SUCCESS) { switch (attr) { - case NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU: case NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU: + { + unsigned int *fan_data; + unsigned int count = 0; + int offset = 0; + int i = 0; + + ret = nvml->lib.deviceGetNumFans(device, &count); + if (ret != NVML_SUCCESS) { + return NvCtrlNotSupported; + } + + /* + * The format of the returned data is: + * + * int unsigned int number of COOLERS + * int * n unsigned int COOLER indices + */ + + *len = (count + 1) * sizeof(unsigned int); + fan_data = (unsigned int *) nvalloc(*len); + memset(fan_data, 0, *len); + *data = (unsigned char *) fan_data; + + /* Calculate global fan index offset for this GPU */ + for (i = 0; i < nvml->deviceIdx; i++) { + offset += nvml->coolerCountPerGPU[i]; + } + + fan_data[0] = count; + for (i = 0; i < count; i++) { + fan_data[i+1] = i + offset; + } + break; + } + case NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_SINGLE_BIT: + ret = getDeviceMemoryCounts(ctrl_target, nvml, device, + NVML_MEMORY_ERROR_TYPE_CORRECTED, + NVML_VOLATILE_ECC, + data, len); + break; + case NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_DOUBLE_BIT: + ret = getDeviceMemoryCounts(ctrl_target, nvml, device, + NVML_MEMORY_ERROR_TYPE_UNCORRECTED, + NVML_VOLATILE_ECC, + data, len); + break; + case NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_SINGLE_BIT_AGGREGATE: + ret = getDeviceMemoryCounts(ctrl_target, nvml, device, + NVML_MEMORY_ERROR_TYPE_CORRECTED, + NVML_AGGREGATE_ECC, + data, len); + break; + case NV_CTRL_BINARY_DATA_GPU_ECC_DETAILED_ERRORS_DOUBLE_BIT_AGGREGATE: + ret = getDeviceMemoryCounts(ctrl_target, nvml, device, + NVML_MEMORY_ERROR_TYPE_UNCORRECTED, + NVML_AGGREGATE_ECC, + data, len); + break; + case NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU: case NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU: case NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU: case NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU: @@ -1358,7 +1624,7 @@ return NvCtrlNotSupported; } -#endif // NVML_EXPERIMENTAL + ReturnStatus NvCtrlNvmlGetBinaryAttribute(const CtrlTarget *ctrl_target, @@ -1368,7 +1634,6 @@ return NvCtrlMissingExtension; } -#ifdef NVML_EXPERIMENTAL /* * This shouldn't be reached for target types that are not handled through * NVML (Keep TARGET_TYPE_IS_NVML_COMPATIBLE in NvCtrlAttributesPrivate.h up @@ -1400,10 +1665,6 @@ default: return NvCtrlBadHandle; } - -#else - return NvCtrlNotSupported; -#endif } @@ -1412,28 +1673,31 @@ * Get NVML Valid String Attribute Values */ -#ifdef NVML_EXPERIMENTAL + static ReturnStatus NvCtrlNvmlGetGPUValidStringAttributeValues(int attr, CtrlAttributeValidValues *val) { switch (attr) { + case NV_CTRL_STRING_NVIDIA_DRIVER_VERSION: case NV_CTRL_STRING_PRODUCT_NAME: case NV_CTRL_STRING_VBIOS_VERSION: - case NV_CTRL_STRING_NVIDIA_DRIVER_VERSION: + case NV_CTRL_STRING_GPU_UUID: + val->valid_type = CTRL_ATTRIBUTE_VALID_TYPE_STRING; + return NvCtrlSuccess; + case NV_CTRL_STRING_SLI_MODE: case NV_CTRL_STRING_PERFORMANCE_MODES: case NV_CTRL_STRING_MULTIGPU_MODE: case NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS: - case NV_CTRL_STRING_GPU_UUID: case NV_CTRL_STRING_GPU_UTILIZATION: /* * XXX We'll eventually need to add support for this attributes. For * string attributes, NV-CONTROL only sets the attribute type * and permissions so no actual NVML call will be needed. */ - return NvCtrlNotSupported; + return NvCtrlAttributeNotAvailable; default: /* The attribute queried is not GPU-targeted */ @@ -1443,25 +1707,54 @@ return NvCtrlSuccess; } -#endif // NVML_EXPERIMENTAL + + +static ReturnStatus convertValidTypeToAttributeType(CtrlAttributeValidType val, + CtrlAttributeType *type) +{ + switch (val) { + case CTRL_ATTRIBUTE_VALID_TYPE_INTEGER: + case CTRL_ATTRIBUTE_VALID_TYPE_BOOL: + case CTRL_ATTRIBUTE_VALID_TYPE_BITMASK: + case CTRL_ATTRIBUTE_VALID_TYPE_64BIT_INTEGER: + *type = CTRL_ATTRIBUTE_TYPE_INTEGER; + break; + case CTRL_ATTRIBUTE_VALID_TYPE_STRING: + *type = CTRL_ATTRIBUTE_TYPE_STRING; + break; + case CTRL_ATTRIBUTE_VALID_TYPE_STRING_OPERATION: + *type = CTRL_ATTRIBUTE_TYPE_STRING_OPERATION; + break; + case CTRL_ATTRIBUTE_VALID_TYPE_BINARY_DATA: + *type = CTRL_ATTRIBUTE_TYPE_BINARY_DATA; + break; + default: + return NvCtrlAttributeNotAvailable; + } + + return NvCtrlSuccess; +} + + ReturnStatus NvCtrlNvmlGetValidStringAttributeValues(const CtrlTarget *ctrl_target, int attr, CtrlAttributeValidValues *val) { + const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target); + ReturnStatus ret = NvCtrlAttributeNotAvailable; + CtrlAttributeType attr_type; + if (NvmlMissing(ctrl_target)) { return NvCtrlMissingExtension; } -#ifdef NVML_EXPERIMENTAL - ReturnStatus ret; - /* - * This shouldn't be reached for target types that are not handled through - * NVML (Keep TARGET_TYPE_IS_NVML_COMPATIBLE in NvCtrlAttributesPrivate.h up - * to date). - */ - assert(TARGET_TYPE_IS_NVML_COMPATIBLE(NvCtrlGetTargetType(ctrl_target))); + if (val) { + memset(val, 0, sizeof(*val)); + } else { + return NvCtrlBadArgument; + } switch (NvCtrlGetTargetType(ctrl_target)) { case GPU_TARGET: @@ -1479,31 +1772,17 @@ break; } - - /* - * XXX Did we forgot to handle this attribute? - REMOVE THIS after - * nvidia-settings NVML migration work is done - */ - if (ret == NvCtrlAttributeNotAvailable) { - const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target); - ReturnStatus ret2; - - if (!h->nv) { - return NvCtrlMissingExtension; - } - - ret2 = NvCtrlNvControlGetValidStringDisplayAttributeValues(h, 0, attr, val); + if (ret == NvCtrlSuccess) { + val->valid_type = CTRL_ATTRIBUTE_VALID_TYPE_STRING; + } - assert(ret2 == NvCtrlAttributeNotAvailable); + ret = convertValidTypeToAttributeType(val->valid_type, &attr_type); - return ret2; + if (ret != NvCtrlSuccess) { + return ret; } - return ret; - -#else - return NvCtrlNotSupported; -#endif + return NvCtrlNvmlGetAttributePerms(h, attr_type, attr, &val->permissions); } @@ -1512,7 +1791,7 @@ * Get NVML Valid Attribute Values */ -#ifdef NVML_EXPERIMENTAL + static ReturnStatus NvCtrlNvmlGetGPUValidAttributeValues(const CtrlTarget *ctrl_target, int attr, @@ -1523,16 +1802,16 @@ nvmlDevice_t device; nvmlReturn_t ret; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; + val->permissions.write = NV_FALSE; ret = nvml->lib.deviceGetHandleByIndex(nvml->deviceIdx, &device); if (ret == NVML_SUCCESS) { switch (attr) { - case NV_CTRL_VIDEO_RAM: case NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY: case NV_CTRL_USED_DEDICATED_GPU_MEMORY: case NV_CTRL_PCI_DOMAIN: @@ -1541,29 +1820,46 @@ case NV_CTRL_PCI_FUNCTION: case NV_CTRL_PCI_ID: case NV_CTRL_GPU_PCIE_GENERATION: - case NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH: case NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH: - case NV_CTRL_GPU_PCIE_MAX_LINK_SPEED: - case NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED: - case NV_CTRL_BUS_TYPE: + case NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH: + case NV_CTRL_GPU_SLOWDOWN_THRESHOLD: + case NV_CTRL_GPU_SHUTDOWN_THRESHOLD: + case NV_CTRL_GPU_CORE_TEMPERATURE: case NV_CTRL_GPU_MEMORY_BUS_WIDTH: case NV_CTRL_GPU_CORES: case NV_CTRL_IRQ: - case NV_CTRL_GPU_COOLER_MANUAL_CONTROL: case NV_CTRL_GPU_POWER_SOURCE: - case NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL: - case NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE: - case NV_CTRL_GPU_POWER_MIZER_MODE: - case NV_CTRL_GPU_POWER_MIZER_DEFAULT_MODE: - case NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE: - case NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT: + val->valid_type = CTRL_ATTRIBUTE_VALID_TYPE_INTEGER; + break; + case NV_CTRL_GPU_ECC_SUPPORTED: case NV_CTRL_GPU_ECC_STATUS: case NV_CTRL_GPU_ECC_CONFIGURATION: - case NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION: + case NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED: + val->valid_type = CTRL_ATTRIBUTE_VALID_TYPE_BOOL; + break; + + case NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS: + case NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS: case NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS: case NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS: - case NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED: + val->valid_type = CTRL_ATTRIBUTE_VALID_TYPE_64BIT_INTEGER; + break; + + case NV_CTRL_GPU_ECC_RESET_ERROR_STATUS: + val->valid_type = CTRL_ATTRIBUTE_VALID_TYPE_BITMASK; + break; + + case NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION: + case NV_CTRL_VIDEO_RAM: + case NV_CTRL_GPU_PCIE_MAX_LINK_SPEED: + case NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED: + case NV_CTRL_BUS_TYPE: + case NV_CTRL_GPU_COOLER_MANUAL_CONTROL: + case NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL: + case NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE: + case NV_CTRL_GPU_POWER_MIZER_MODE: + case NV_CTRL_GPU_POWER_MIZER_DEFAULT_MODE: case NV_CTRL_ENABLED_DISPLAYS: case NV_CTRL_CONNECTED_DISPLAYS: case NV_CTRL_MAX_SCREEN_WIDTH: @@ -1578,10 +1874,8 @@ case NV_CTRL_ATTR_NV_MINOR_VERSION: case NV_CTRL_OPERATING_SYSTEM: case NV_CTRL_NO_SCANOUT: - case NV_CTRL_GPU_CORE_TEMPERATURE: case NV_CTRL_AMBIENT_TEMPERATURE: case NV_CTRL_GPU_CURRENT_CLOCK_FREQS: - case NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS: case NV_CTRL_VIDEO_ENCODER_UTILIZATION: case NV_CTRL_VIDEO_DECODER_UTILIZATION: case NV_CTRL_FRAMELOCK: @@ -1603,7 +1897,7 @@ * XXX We'll eventually need to add support for this attributes * through NVML */ - return NvCtrlNotSupported; + return NvCtrlAttributeNotAvailable; default: /* The attribute queried is not GPU-targeted */ @@ -1617,7 +1911,7 @@ /* An NVML error occurred */ printNvmlError(ret); - return NvCtrlNotSupported; + return NvCtrlNoAttribute; } static ReturnStatus @@ -1631,12 +1925,11 @@ nvmlDevice_t device; nvmlReturn_t ret; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; - /* Get the proper device and sensor ID according to the target ID */ sensorId = getThermalCoolerId(h, nvml->sensorCount, nvml->sensorCountPerGPU); @@ -1655,7 +1948,7 @@ * XXX We'll eventually need to add support for this attributes * through NVML */ - return NvCtrlNotSupported; + return NvCtrlAttributeNotAvailable; default: /* The attribute queried is not sensor-targeted */ @@ -1669,7 +1962,7 @@ /* An NVML error occurred */ printNvmlError(ret); - return NvCtrlNotSupported; + return NvCtrlNoAttribute; } static ReturnStatus @@ -1683,12 +1976,11 @@ nvmlDevice_t device; nvmlReturn_t ret; - if ((h == NULL) || (h->nvml == NULL)) { + nvml = getNvmlHandleConst(h); + if (nvml == NULL) { return NvCtrlBadHandle; } - nvml = h->nvml; - /* Get the proper device and cooler ID according to the target ID */ coolerId = getThermalCoolerId(h, nvml->coolerCount, nvml->coolerCountPerGPU); @@ -1700,6 +1992,13 @@ ret = nvml->lib.deviceGetHandleByIndex(nvml->deviceIdx, &device); if (ret == NVML_SUCCESS) { switch (attr) { + case NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL: + /* Range as a percent */ + val->valid_type = CTRL_ATTRIBUTE_VALID_TYPE_RANGE; + val->range.min = 0; + val->range.max = 100; + return NvCtrlSuccess; + case NV_CTRL_THERMAL_COOLER_LEVEL: case NV_CTRL_THERMAL_COOLER_SPEED: case NV_CTRL_THERMAL_COOLER_CONTROL_TYPE: @@ -1708,7 +2007,7 @@ * XXX We'll eventually need to add support for this attributes * through NVML */ - return NvCtrlNotSupported; + return NvCtrlAttributeNotAvailable; default: /* The attribute queried is not fan-targeted */ @@ -1722,22 +2021,24 @@ /* An NVML error occurred */ printNvmlError(ret); - return NvCtrlNotSupported; + return NvCtrlNoAttribute; } -#endif // NVML_EXPERIMENTAL + ReturnStatus NvCtrlNvmlGetValidAttributeValues(const CtrlTarget *ctrl_target, int attr, CtrlAttributeValidValues *val) { + const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target); + ReturnStatus ret = NvCtrlAttributeNotAvailable; + CtrlAttributeType attr_type; + if (NvmlMissing(ctrl_target)) { return NvCtrlMissingExtension; } -#ifdef NVML_EXPERIMENTAL - ReturnStatus ret; /* * This shouldn't be reached for target types that are not handled through * NVML (Keep TARGET_TYPE_IS_NVML_COMPATIBLE in NvCtrlAttributesPrivate.h up @@ -1768,30 +2069,136 @@ ret = NvCtrlBadHandle; } - - /* - * XXX Did we forgot to handle this attribute? - REMOVE THIS after - * nvidia-settings NVML migration work is done - */ - if (ret == NvCtrlAttributeNotAvailable) { - const NvCtrlAttributePrivateHandle *h = getPrivateHandleConst(ctrl_target); - ReturnStatus ret2; + if (ret != NvCtrlSuccess) { + return ret; + } - if (!h->nv) { - return NvCtrlMissingExtension; - } + ret = convertValidTypeToAttributeType(val->valid_type, &attr_type); - ret2 = NvCtrlNvControlGetValidAttributeValues(h, 0, attr, val); + if (ret != NvCtrlSuccess) { + return ret; + } - assert(ret2 == NvCtrlAttributeNotAvailable); + return NvCtrlNvmlGetAttributePerms(h, attr_type, attr, &val->permissions); +} + +static ReturnStatus NvCtrlNvmlGetIntegerAttributePerms(int attr, + CtrlAttributePerms *perms) +{ + /* Set write permissions */ + switch (attr) { + case NV_CTRL_GPU_ECC_CONFIGURATION: + case NV_CTRL_GPU_ECC_RESET_ERROR_STATUS: + perms->write = NV_TRUE; + break; + default: + perms->write = NV_FALSE; + } + + /* Valid target and read permissions */ + switch (attr) { + case NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY: + case NV_CTRL_USED_DEDICATED_GPU_MEMORY: + case NV_CTRL_PCI_DOMAIN: + case NV_CTRL_PCI_BUS: + case NV_CTRL_PCI_DEVICE: + case NV_CTRL_PCI_FUNCTION: + case NV_CTRL_PCI_ID: + case NV_CTRL_GPU_PCIE_GENERATION: + case NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH: + case NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH: + case NV_CTRL_GPU_SLOWDOWN_THRESHOLD: + case NV_CTRL_GPU_SHUTDOWN_THRESHOLD: + case NV_CTRL_GPU_CORE_TEMPERATURE: + case NV_CTRL_GPU_MEMORY_BUS_WIDTH: + case NV_CTRL_GPU_CORES: + case NV_CTRL_IRQ: + case NV_CTRL_GPU_POWER_SOURCE: + /* CTRL_ATTRIBUTE_VALID_TYPE_BOOL */ + case NV_CTRL_GPU_ECC_SUPPORTED: + case NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED: + case NV_CTRL_GPU_ECC_STATUS: + case NV_CTRL_GPU_ECC_CONFIGURATION: + /* CTRL_ATTRIBUTE_VALID_TYPE_64BIT_INTEGER */ + case NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS: + case NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS: + case NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS: + case NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS: + perms->read = NV_TRUE; + perms->valid_targets = CTRL_TARGET_PERM_BIT(GPU_TARGET); + break; + + /* GPU_TARGET non-readable attribute */ + case NV_CTRL_GPU_ECC_RESET_ERROR_STATUS: + perms->read = NV_FALSE; + perms->valid_targets = CTRL_TARGET_PERM_BIT(GPU_TARGET); + break; + + case NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL: + perms->valid_targets = CTRL_TARGET_PERM_BIT(COOLER_TARGET); + perms->read = NV_TRUE; + break; - return ret2; + default: + perms->valid_targets = 0; + perms->read = NV_FALSE; + return NvCtrlNotSupported; + } + + return NvCtrlSuccess; +} + +static ReturnStatus NvCtrlNvmlGetStringAttributePerms(int attr, + CtrlAttributePerms *perms) +{ + perms->write = NV_FALSE; + + switch (attr) { + case NV_CTRL_STRING_NVIDIA_DRIVER_VERSION: + case NV_CTRL_STRING_PRODUCT_NAME: + case NV_CTRL_STRING_VBIOS_VERSION: + case NV_CTRL_STRING_GPU_UUID: + perms->valid_targets = CTRL_TARGET_PERM_BIT(GPU_TARGET); + perms->read = NV_TRUE; + break; + default: + perms->valid_targets = 0; + perms->read = NV_FALSE; + return NvCtrlNotSupported; + } + return NvCtrlSuccess; +} + + +ReturnStatus +NvCtrlNvmlGetAttributePerms(const NvCtrlAttributePrivateHandle *h, + CtrlAttributeType attr_type, int attr, + CtrlAttributePerms *perms) +{ + ReturnStatus ret = NvCtrlSuccess; + + if (!h->nvml) { + return NvCtrlBadArgument; + } + + switch (attr_type) { + case CTRL_ATTRIBUTE_TYPE_INTEGER: + ret = NvCtrlNvmlGetIntegerAttributePerms(attr, perms); + break; + + case CTRL_ATTRIBUTE_TYPE_STRING: + ret = NvCtrlNvmlGetStringAttributePerms(attr, perms); + break; + + case CTRL_ATTRIBUTE_TYPE_BINARY_DATA: + return NvCtrlBadArgument; + break; + + default: + return NvCtrlBadArgument; } return ret; -#else - return NvCtrlNotSupported; -#endif } diff -Nru nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h --- nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h 2022-01-24 23:51:09.000000000 +0000 @@ -85,7 +85,8 @@ #define TARGET_TYPE_IS_NVML_COMPATIBLE(_TARGET_TYPE_) \ (((_TARGET_TYPE_) == GPU_TARGET) || \ ((_TARGET_TYPE_) == THERMAL_SENSOR_TARGET) || \ - ((_TARGET_TYPE_) == COOLER_TARGET)) + ((_TARGET_TYPE_) == COOLER_TARGET) || \ + ((_TARGET_TYPE_) == MUX_TARGET)) #define TARGET_TYPE_NEEDS_NVCONTROL(_TARGET_TYPE_) \ (!(TARGET_TYPE_IS_NVML_COMPATIBLE(_TARGET_TYPE_))) @@ -169,15 +170,31 @@ typeof(nvmlDeviceGetUUID) (*deviceGetUUID); typeof(nvmlDeviceGetCount) (*deviceGetCount); typeof(nvmlDeviceGetTemperature) (*deviceGetTemperature); - typeof(nvmlDeviceGetFanSpeed) (*deviceGetFanSpeed); typeof(nvmlDeviceGetName) (*deviceGetName); typeof(nvmlDeviceGetVbiosVersion) (*deviceGetVbiosVersion); typeof(nvmlDeviceGetMemoryInfo) (*deviceGetMemoryInfo); + typeof(nvmlDeviceGetMemoryInfo_v2) (*deviceGetMemoryInfo_v2); typeof(nvmlDeviceGetPciInfo) (*deviceGetPciInfo); + typeof(nvmlDeviceGetCurrPcieLinkWidth) (*deviceGetCurrPcieLinkWidth); typeof(nvmlDeviceGetMaxPcieLinkGeneration) (*deviceGetMaxPcieLinkGeneration); typeof(nvmlDeviceGetMaxPcieLinkWidth) (*deviceGetMaxPcieLinkWidth); typeof(nvmlDeviceGetVirtualizationMode) (*deviceGetVirtualizationMode); typeof(nvmlDeviceGetGridLicensableFeatures_v4) (*deviceGetGridLicensableFeatures); + typeof(nvmlDeviceGetUtilizationRates) (*deviceGetUtilizationRates); + typeof(nvmlDeviceGetTemperatureThreshold) (*deviceGetTemperatureThreshold); + typeof(nvmlDeviceGetFanSpeed_v2) (*deviceGetFanSpeed_v2); + typeof(nvmlSystemGetDriverVersion) (*systemGetDriverVersion); + typeof(nvmlDeviceGetEccMode) (*deviceGetEccMode); + typeof(nvmlDeviceSetEccMode) (*deviceSetEccMode); + typeof(nvmlDeviceGetTotalEccErrors) (*deviceGetTotalEccErrors); + typeof(nvmlDeviceClearEccErrorCounts) (*deviceClearEccErrorCounts); + typeof(nvmlDeviceGetMemoryErrorCounter) (*deviceGetMemoryErrorCounter); + typeof(nvmlSystemGetNVMLVersion) (*systemGetNVMLVersion); + typeof(nvmlDeviceGetNumGpuCores) (*deviceGetNumGpuCores); + typeof(nvmlDeviceGetMemoryBusWidth) (*deviceGetMemoryBusWidth); + typeof(nvmlDeviceGetIrqNum) (*deviceGetIrqNum); + typeof(nvmlDeviceGetPowerSource) (*deviceGetPowerSource); + typeof(nvmlDeviceGetNumFans) (*deviceGetNumFans); } lib; @@ -456,4 +473,9 @@ int attr, CtrlAttributeValidValues *val); +ReturnStatus +NvCtrlNvmlGetAttributePerms(const NvCtrlAttributePrivateHandle *, + CtrlAttributeType, int, + CtrlAttributePerms *); + #endif /* __NVCTRL_ATTRIBUTES_PRIVATE__ */ diff -Nru nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c --- nvidia-settings-470.57.01/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c 2022-01-24 23:51:09.000000000 +0000 @@ -505,7 +505,9 @@ status = NvCtrlGetBinaryAttribute(target, 0, attr, (unsigned char **)(&pData), &len); if ((status != NvCtrlSuccess) || !pData) { - nv_error_msg("Error querying target relations"); + if (status != NvCtrlNotSupported) { + nv_error_msg("Error querying target relations"); + } return; } @@ -673,7 +675,7 @@ * not being specified in xorg.conf, it can cause errors down the line. */ - if (target_type == GPU_TARGET) { + if (target_type == GPU_TARGET && t->system->has_nv_control) { /* NV_CTRL_DEPTH_30_ALLOWED expected to succeed for any valid device */ status = NvCtrlGetAttribute(t, NV_CTRL_DEPTH_30_ALLOWED, &d); if (status != NvCtrlSuccess) { @@ -733,7 +735,7 @@ * (framelock), we just assign this to 0. */ - if (targetTypeInfo->uses_display_devices) { + if (targetTypeInfo->uses_display_devices && system->has_nv_control) { status = NvCtrlGetAttribute(t, NV_CTRL_ENABLED_DISPLAYS, &d); @@ -817,6 +819,16 @@ } +static const char *get_display_name(CtrlSystem *system) +{ + if (system->has_nv_control) { + return XDisplayName(system->display); + } else { + return system->display; + } +} + + static Bool load_system_info(CtrlSystem *system, const char *display) { ReturnStatus status; @@ -826,6 +838,8 @@ int unused; int *pData = NULL; const CtrlTargetTypeInfo *targetTypeInfo; + int subsystems = NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM | + NV_CTRL_ATTRIBUTES_NVML_SUBSYSTEM; if (!system) { return FALSE; @@ -841,19 +855,19 @@ system->dpy = XOpenDisplay(system->display); if (system->dpy == NULL) { - nv_error_msg("Unable to find display on any available system"); - return FALSE; + /* If it fails, just use NVML */ + subsystems = NV_CTRL_ATTRIBUTES_NVML_SUBSYSTEM; + } else { + system->has_nv_control = + XNVCTRLQueryExtension(system->dpy, &unused, &unused); } - system->has_nv_control = - XNVCTRLQueryExtension(system->dpy, &unused, &unused); - /* Try to initialize the NVML library */ - nvmlQueryTarget = nv_alloc_ctrl_target(system, GPU_TARGET, 0, - NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM | - NV_CTRL_ATTRIBUTES_NVML_SUBSYSTEM); + nvmlQueryTarget = nv_alloc_ctrl_target(system, GPU_TARGET, 0, subsystems); - if (nvmlQueryTarget == NULL) { + system->has_nvml = (nvmlQueryTarget != NULL); + + if (system->has_nvml == FALSE) { nv_error_msg("Unable to load info from any available system"); return FALSE; } @@ -883,6 +897,16 @@ target_count = ScreenCount(system->dpy); } } + else if (target_type == MUX_TARGET) { + + status = NvCtrlQueryTargetCount(nvmlQueryTarget, + target_type, + &val); + if (status == NvCtrlSuccess) { + target_count = val; + } + + } else if ((h != NULL) && (h->nvml != NULL) && TARGET_TYPE_IS_NVML_COMPATIBLE(target_type)) { @@ -942,7 +966,7 @@ nv_warning_msg("Unable to determine number of NVIDIA " "%ss on '%s'.", targetTypeInfo->name, - XDisplayName(system->display)); + get_display_name(system)); val = 0; } @@ -966,6 +990,7 @@ case COOLER_TARGET: case THERMAL_SENSOR_TARGET: case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET: + case MUX_TARGET: default: targetId = i; } @@ -1017,7 +1042,7 @@ if (status != NvCtrlSuccess) { nv_warning_msg("Unable to determine number of NVIDIA %ss on '%s'.", - targetTypeInfo->name, XDisplayName(system->display)); + targetTypeInfo->name, get_display_name(system)); val = 0; } diff -Nru nvidia-settings-470.57.01/src/Makefile nvidia-settings-510.47.03/src/Makefile --- nvidia-settings-470.57.01/src/Makefile 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/Makefile 2022-01-24 23:51:09.000000000 +0000 @@ -86,9 +86,7 @@ JANSSON_CFLAGS = -Wno-cast-qual JANSSON_CFLAGS += -Wno-unused-function JANSSON_CFLAGS += -DHAVE_CONFIG_H - ifeq ($(TARGET_ARCH),armv7l) - JANSSON_CFLAGS += -Wno-unused-but-set-variable - endif + JANSSON_CFLAGS += -Wno-format-truncation endif ############################################################################## @@ -141,9 +139,6 @@ LDFLAGS += $(XNVCTRL_LDFLAGS) -NVML_EXPERIMENTAL ?= -CFLAGS += $(if $(NVML_EXPERIMENTAL),-DNVML_EXPERIMENTAL) - # Some older Linux distributions do not have the dynamic library # libXxf86vm.so, though some newer Linux distributions do not have the diff -Nru nvidia-settings-470.57.01/src/nvidia-settings.c nvidia-settings-510.47.03/src/nvidia-settings.c --- nvidia-settings-470.57.01/src/nvidia-settings.c 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/nvidia-settings.c 2022-01-24 23:51:09.000000000 +0000 @@ -367,7 +367,7 @@ system = NvCtrlGetSystem(op->ctrl_display, &systems); - if (!system || !system->dpy) { + if (!system) { return 1; } diff -Nru nvidia-settings-470.57.01/src/nvml.h nvidia-settings-510.47.03/src/nvml.h --- nvidia-settings-470.57.01/src/nvml.h 2021-07-07 22:48:22.000000000 +0000 +++ nvidia-settings-510.47.03/src/nvml.h 2022-01-24 23:51:09.000000000 +0000 @@ -114,15 +114,19 @@ #define nvmlEventSetWait nvmlEventSetWait_v2 #define nvmlDeviceGetAttributes nvmlDeviceGetAttributes_v2 #define nvmlComputeInstanceGetInfo nvmlComputeInstanceGetInfo_v2 - #define nvmlDeviceGetComputeRunningProcesses nvmlDeviceGetComputeRunningProcesses_v2 - #define nvmlDeviceGetGraphicsRunningProcesses nvmlDeviceGetGraphicsRunningProcesses_v2 - #define nvmlDeviceGetMPSComputeRunningProcesses nvmlDeviceGetMPSComputeRunningProcesses_v2 + #define nvmlDeviceGetComputeRunningProcesses nvmlDeviceGetComputeRunningProcesses_v3 + #define nvmlDeviceGetGraphicsRunningProcesses nvmlDeviceGetGraphicsRunningProcesses_v3 + #define nvmlDeviceGetMPSComputeRunningProcesses nvmlDeviceGetMPSComputeRunningProcesses_v3 #define nvmlBlacklistDeviceInfo_t nvmlExcludedDeviceInfo_t #define nvmlGetBlacklistDeviceCount nvmlGetExcludedDeviceCount #define nvmlGetBlacklistDeviceInfoByIndex nvmlGetExcludedDeviceInfoByIndex #define nvmlDeviceGetGpuInstancePossiblePlacements nvmlDeviceGetGpuInstancePossiblePlacements_v2 + #define nvmlVgpuInstanceGetLicenseInfo nvmlVgpuInstanceGetLicenseInfo_v2 #endif // #ifndef NVML_NO_UNVERSIONED_FUNC_DEFS +#define NVML_STRUCT_VERSION(data, ver) (unsigned int)(sizeof(nvml ## data ## _v ## ver ## _t) | \ + (ver << 24U)) + /***************************************************************************************************/ /** @defgroup nvmlDeviceStructs Device Structs * @{ @@ -208,16 +212,35 @@ } nvmlUtilization_t; /** - * Memory allocation information for a device. + * Memory allocation information for a device (v1). + * The total amount is equal to the sum of the amounts of free and used memory. */ typedef struct nvmlMemory_st { - unsigned long long total; //!< Total installed FB memory (in bytes) - unsigned long long free; //!< Unallocated FB memory (in bytes) - unsigned long long used; //!< Allocated FB memory (in bytes). Note that the driver/GPU always sets aside a small amount of memory for bookkeeping + unsigned long long total; //!< Total physical device memory (in bytes) + unsigned long long free; //!< Unallocated device memory (in bytes) + unsigned long long used; //!< Sum of Reserved and Allocated device memory (in bytes). + //!< Note that the driver/GPU always sets aside a small amount of memory for bookkeeping } nvmlMemory_t; /** + * Memory allocation information for a device (v2). + * + * Version 2 adds versioning for the struct and the amount of system-reserved memory as an output. + * @note The \ref nvmlMemory_v2_t.used amount also includes the \ref nvmlMemory_v2_t.reserved amount. + */ +typedef struct nvmlMemory_v2_st +{ + unsigned int version; //!< Structure format version (must be 2) + unsigned long long total; //!< Total physical device memory (in bytes) + unsigned long long reserved; //!< Device memory (in bytes) reserved for system use (driver or firmware) + unsigned long long free; //!< Unallocated device memory (in bytes) + unsigned long long used; //!< Allocated device memory (in bytes). Note that the driver/GPU always sets aside a small amount of memory for bookkeeping +} nvmlMemory_v2_t; + +#define nvmlMemory_v2 NVML_STRUCT_VERSION(Memory, 2) + +/** * BAR1 Memory allocation Information for a device */ typedef struct nvmlBAR1Memory_st @@ -242,6 +265,22 @@ /** * Information about running compute processes on the GPU */ +typedef struct nvmlProcessInfo_v2_st +{ + unsigned int pid; //!< Process ID + unsigned long long usedGpuMemory; //!< Amount of used GPU memory in bytes. + //! Under WDDM, \ref NVML_VALUE_NOT_AVAILABLE is always reported + //! because Windows KMD manages all the memory and not the NVIDIA driver + unsigned int gpuInstanceId; //!< If MIG is enabled, stores a valid GPU instance ID. gpuInstanceId is set to + // 0xFFFFFFFF otherwise. + unsigned int computeInstanceId; //!< If MIG is enabled, stores a valid compute instance ID. computeInstanceId is set to + // 0xFFFFFFFF otherwise. +} nvmlProcessInfo_v2_t; + +/** + * Information about running compute processes on the GPU + * Version 2 adds versioning for the struct and the conf compute protected memory in output. + */ typedef struct nvmlProcessInfo_st { unsigned int pid; //!< Process ID @@ -567,23 +606,24 @@ * */ typedef enum nvmlBrandType_enum { - NVML_BRAND_UNKNOWN = 0, - NVML_BRAND_QUADRO = 1, - NVML_BRAND_TESLA = 2, - NVML_BRAND_NVS = 3, - NVML_BRAND_GRID = 4, // Deprecated from API reporting. Keeping definition for backward compatibility. - NVML_BRAND_GEFORCE = 5, - NVML_BRAND_TITAN = 6, - NVML_BRAND_NVIDIA_VAPPS = 7, // NVIDIA Virtual Applications - NVML_BRAND_NVIDIA_VPC = 8, // NVIDIA Virtual PC - NVML_BRAND_NVIDIA_VCS = 9, // NVIDIA Virtual Compute Server - NVML_BRAND_NVIDIA_VWS = 10, // NVIDIA RTX Virtual Workstation - NVML_BRAND_NVIDIA_VGAMING = 11, // NVIDIA vGaming - NVML_BRAND_QUADRO_RTX = 12, - NVML_BRAND_NVIDIA_RTX = 13, - NVML_BRAND_NVIDIA = 14, - NVML_BRAND_GEFORCE_RTX = 15, // Unused - NVML_BRAND_TITAN_RTX = 16, // Unused + NVML_BRAND_UNKNOWN = 0, + NVML_BRAND_QUADRO = 1, + NVML_BRAND_TESLA = 2, + NVML_BRAND_NVS = 3, + NVML_BRAND_GRID = 4, // Deprecated from API reporting. Keeping definition for backward compatibility. + NVML_BRAND_GEFORCE = 5, + NVML_BRAND_TITAN = 6, + NVML_BRAND_NVIDIA_VAPPS = 7, // NVIDIA Virtual Applications + NVML_BRAND_NVIDIA_VPC = 8, // NVIDIA Virtual PC + NVML_BRAND_NVIDIA_VCS = 9, // NVIDIA Virtual Compute Server + NVML_BRAND_NVIDIA_VWS = 10, // NVIDIA RTX Virtual Workstation + NVML_BRAND_NVIDIA_CLOUD_GAMING = 11, // NVIDIA Cloud Gaming + NVML_BRAND_NVIDIA_VGAMING = NVML_BRAND_NVIDIA_CLOUD_GAMING, // Deprecated from API reporting. Keeping definition for backward compatibility. + NVML_BRAND_QUADRO_RTX = 12, + NVML_BRAND_NVIDIA_RTX = 13, + NVML_BRAND_NVIDIA = 14, + NVML_BRAND_GEFORCE_RTX = 15, // Unused + NVML_BRAND_TITAN_RTX = 16, // Unused // Keep this last NVML_BRAND_COUNT @@ -974,7 +1014,7 @@ } nvmlVgpuVmIdType_t; /** - * vGPU GUEST info state. + * vGPU GUEST info state */ typedef enum nvmlVgpuGuestInfoState_enum { @@ -1003,6 +1043,17 @@ #define NVML_GRID_LICENSE_EXPIRY_NOT_APPLICABLE 3 //!< Expiry not applicable #define NVML_GRID_LICENSE_EXPIRY_PERMANENT 4 //!< Permanent expiry +/** + * vGPU queryable capabilities + */ +typedef enum nvmlVgpuCapability_enum +{ + NVML_VGPU_CAP_NVLINK_P2P = 0, //!< P2P over NVLink is supported + NVML_VGPU_CAP_GPUDIRECT = 1, //!< GPUDirect capability is supported + // Keep this last + NVML_VGPU_CAP_COUNT +} nvmlVgpuCapability_t; + /** @} */ /***************************************************************************************************/ @@ -1056,12 +1107,12 @@ */ typedef struct nvmlVgpuInstanceUtilizationSample_st { - nvmlVgpuInstance_t vgpuInstance; //!< vGPU Instance - unsigned long long timeStamp; //!< CPU Timestamp in microseconds - nvmlValue_t smUtil; //!< SM (3D/Compute) Util Value - nvmlValue_t memUtil; //!< Frame Buffer Memory Util Value - nvmlValue_t encUtil; //!< Encoder Util Value - nvmlValue_t decUtil; //!< Decoder Util Value + nvmlVgpuInstance_t vgpuInstance; //!< vGPU Instance + unsigned long long timeStamp; //!< CPU Timestamp in microseconds + nvmlValue_t smUtil; //!< SM (3D/Compute) Util Value + nvmlValue_t memUtil; //!< Frame Buffer Memory Util Value + nvmlValue_t encUtil; //!< Encoder Util Value + nvmlValue_t decUtil; //!< Decoder Util Value } nvmlVgpuInstanceUtilizationSample_t; /** @@ -1069,27 +1120,58 @@ */ typedef struct nvmlVgpuProcessUtilizationSample_st { - nvmlVgpuInstance_t vgpuInstance; //!< vGPU Instance - unsigned int pid; //!< PID of process running within the vGPU VM - char processName[NVML_VGPU_NAME_BUFFER_SIZE]; //!< Name of process running within the vGPU VM - unsigned long long timeStamp; //!< CPU Timestamp in microseconds - unsigned int smUtil; //!< SM (3D/Compute) Util Value - unsigned int memUtil; //!< Frame Buffer Memory Util Value - unsigned int encUtil; //!< Encoder Util Value - unsigned int decUtil; //!< Decoder Util Value + nvmlVgpuInstance_t vgpuInstance; //!< vGPU Instance + unsigned int pid; //!< PID of process running within the vGPU VM + char processName[NVML_VGPU_NAME_BUFFER_SIZE]; //!< Name of process running within the vGPU VM + unsigned long long timeStamp; //!< CPU Timestamp in microseconds + unsigned int smUtil; //!< SM (3D/Compute) Util Value + unsigned int memUtil; //!< Frame Buffer Memory Util Value + unsigned int encUtil; //!< Encoder Util Value + unsigned int decUtil; //!< Decoder Util Value } nvmlVgpuProcessUtilizationSample_t; /** + * Structure to store the vGPU license expiry details + */ +typedef struct nvmlVgpuLicenseExpiry_st +{ + unsigned int year; //!< Year of license expiry + unsigned short month; //!< Month of license expiry + unsigned short day; //!< Day of license expiry + unsigned short hour; //!< Hour of license expiry + unsigned short min; //!< Minutes of license expiry + unsigned short sec; //!< Seconds of license expiry + unsigned char status; //!< License expiry status +} nvmlVgpuLicenseExpiry_t; + +/** + * vGPU license state + */ +#define NVML_GRID_LICENSE_STATE_UNKNOWN 0 //!< Unknown state +#define NVML_GRID_LICENSE_STATE_UNINITIALIZED 1 //!< Uninitialized state +#define NVML_GRID_LICENSE_STATE_UNLICENSED_UNRESTRICTED 2 //!< Unlicensed unrestricted state +#define NVML_GRID_LICENSE_STATE_UNLICENSED_RESTRICTED 3 //!< Unlicensed restricted state +#define NVML_GRID_LICENSE_STATE_UNLICENSED 4 //!< Unlicensed state +#define NVML_GRID_LICENSE_STATE_LICENSED 5 //!< Licensed state + +typedef struct nvmlVgpuLicenseInfo_st +{ + unsigned char isLicensed; //!< License status + nvmlVgpuLicenseExpiry_t licenseExpiry; //!< License expiry information + unsigned int currentState; //!< Current license state +} nvmlVgpuLicenseInfo_t; + +/** * Structure to store utilization value and process Id */ typedef struct nvmlProcessUtilizationSample_st { - unsigned int pid; //!< PID of process - unsigned long long timeStamp; //!< CPU Timestamp in microseconds - unsigned int smUtil; //!< SM (3D/Compute) Util Value - unsigned int memUtil; //!< Frame Buffer Memory Util Value - unsigned int encUtil; //!< Encoder Util Value - unsigned int decUtil; //!< Decoder Util Value + unsigned int pid; //!< PID of process + unsigned long long timeStamp; //!< CPU Timestamp in microseconds + unsigned int smUtil; //!< SM (3D/Compute) Util Value + unsigned int memUtil; //!< Frame Buffer Memory Util Value + unsigned int encUtil; //!< Encoder Util Value + unsigned int decUtil; //!< Decoder Util Value } nvmlProcessUtilizationSample_t; /** @@ -1103,7 +1185,6 @@ unsigned short hour; //!< Hour value of license expiry unsigned short min; //!< Minutes value of license expiry unsigned short sec; //!< Seconds value of license expiry - unsigned char status; //!< License expiry status } nvmlGridLicenseExpiry_t; @@ -1145,6 +1226,41 @@ typedef unsigned int nvmlDeviceArchitecture_t; +/** + * PCI bus types + */ +#define NVML_BUS_TYPE_UNKNOWN 0 +#define NVML_BUS_TYPE_PCI 1 +#define NVML_BUS_TYPE_PCIE 2 +#define NVML_BUS_TYPE_FPCI 3 +#define NVML_BUS_TYPE_AGP 4 + +typedef unsigned int nvmlBusType_t; + +/** + * Device Power Source + */ +#define NVML_POWER_SOURCE_AC 0x00000000 +#define NVML_POWER_SOURCE_BATTERY 0x00000001 + +typedef unsigned int nvmlPowerSource_t; + +/* + * Device PCIE link Max Speed + */ +#define NVML_PCIE_LINK_MAX_SPEED_INVALID 0x00000000 +#define NVML_PCIE_LINK_MAX_SPEED_2500MBPS 0x00000001 +#define NVML_PCIE_LINK_MAX_SPEED_5000MBPS 0x00000002 +#define NVML_PCIE_LINK_MAX_SPEED_8000MBPS 0x00000003 +#define NVML_PCIE_LINK_MAX_SPEED_16000MBPS 0x00000004 +#define NVML_PCIE_LINK_MAX_SPEED_32000MBPS 0x00000005 + +/* + * Adaptive clocking status + */ +#define NVML_ADAPTIVE_CLOCKING_INFO_STATUS_DISABLED 0x00000000 +#define NVML_ADAPTIVE_CLOCKING_INFO_STATUS_ENABLED 0x00000001 + /** @} */ /** @} */ @@ -3579,6 +3695,23 @@ */ nvmlReturn_t DECLDIR nvmlDeviceGetFanSpeed_v2(nvmlDevice_t device, unsigned int fan, unsigned int * speed); +/** + * Retrieves the number of fans on the device. + * + * For all discrete products with dedicated fans. + * + * @param device The identifier of the target device + * @param numFans The number of fans + * + * @return + * - \ref NVML_SUCCESS if \a fan number query was successful + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a numFans is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not have a fan + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetNumFans(nvmlDevice_t device, unsigned int *numFans); /** * Retrieves the current temperature readings for the device, in degrees C. @@ -3911,7 +4044,8 @@ nvmlReturn_t DECLDIR nvmlDeviceGetGpuOperationMode(nvmlDevice_t device, nvmlGpuOperationMode_t *current, nvmlGpuOperationMode_t *pending); /** - * Retrieves the amount of used, free and total memory available on the device, in bytes. + * Retrieves the amount of used, free, reserved and total memory available on the device, in bytes. + * The reserved amount is supported on version 2 only. * * For all products. * @@ -3921,11 +4055,13 @@ * Under Linux and Windows TCC, the reported amount of used memory is equal to the sum of memory allocated * by all active channels on the device. * - * See \ref nvmlMemory_t for details on available memory info. + * See \ref nvmlMemory_v2_t for details on available memory info. * * @note In MIG mode, if device handle is provided, the API returns aggregate * information, only if the caller has appropriate privileges. Per-instance * information can be queried by using specific MIG device handles. + * + * @note nvmlDeviceGetMemoryInfo_v2 adds additional memory information. * * @param device The identifier of the target device * @param memory Reference in which to return the memory information @@ -3939,6 +4075,7 @@ * - \ref NVML_ERROR_UNKNOWN on any unexpected error */ nvmlReturn_t DECLDIR nvmlDeviceGetMemoryInfo(nvmlDevice_t device, nvmlMemory_t *memory); +nvmlReturn_t DECLDIR nvmlDeviceGetMemoryInfo_v2(nvmlDevice_t device, nvmlMemory_v2_t *memory); /** * Retrieves the current compute mode for the device. @@ -4462,7 +4599,7 @@ * * @see \ref nvmlSystemGetProcessName */ -nvmlReturn_t DECLDIR nvmlDeviceGetComputeRunningProcesses_v2(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_t *infos); +nvmlReturn_t DECLDIR nvmlDeviceGetComputeRunningProcesses_v3(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_t *infos); /** * Get information about processes with a graphics context on a device @@ -4505,7 +4642,7 @@ * * @see \ref nvmlSystemGetProcessName */ -nvmlReturn_t DECLDIR nvmlDeviceGetGraphicsRunningProcesses_v2(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_t *infos); +nvmlReturn_t DECLDIR nvmlDeviceGetGraphicsRunningProcesses_v3(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_t *infos); /** * Get information about processes with a MPS compute context on a device @@ -4548,7 +4685,7 @@ * * @see \ref nvmlSystemGetProcessName */ -nvmlReturn_t DECLDIR nvmlDeviceGetMPSComputeRunningProcesses_v2(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_t *infos); +nvmlReturn_t DECLDIR nvmlDeviceGetMPSComputeRunningProcesses_v3(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_t *infos); /** * Check if the GPU devices are on the same physical board. @@ -4695,6 +4832,102 @@ nvmlReturn_t DECLDIR nvmlDeviceGetViolationStatus(nvmlDevice_t device, nvmlPerfPolicyType_t perfPolicyType, nvmlViolationTime_t *violTime); /** + * Gets the device's interrupt number + * + * @param device The identifier of the target device + * @param irqNum The interrupt number associated with the specified device + * + * @return + * - \ref NVML_SUCCESS if irq number is successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a irqNum is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * + */ +nvmlReturn_t DECLDIR nvmlDeviceGetIrqNum(nvmlDevice_t device, unsigned int *irqNum); + +/** + * Gets the device's core count + * + * @param device The identifier of the target device + * @param numCores The number of cores for the specified device + * + * @return + * - \ref NVML_SUCCESS if Gpu core count is successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a numCores is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * + */ +nvmlReturn_t DECLDIR nvmlDeviceGetNumGpuCores(nvmlDevice_t device, unsigned int *numCores); + +/** + * Gets the devices power source + * + * @param device The identifier of the target device + * @param powerSource The power source of the device + * + * @return + * - \ref NVML_SUCCESS if the current power source was successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a powerSource is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * + */ +nvmlReturn_t DECLDIR nvmlDeviceGetPowerSource(nvmlDevice_t device, nvmlPowerSource_t *powerSource); + +/** + * Gets the device's memory bus width + * + * @param device The identifier of the target device + * @param maxSpeed The devices's memory bus width + * + * @return + * - \ref NVML_SUCCESS if the memory bus width is successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a busWidth is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * + */ +nvmlReturn_t DECLDIR nvmlDeviceGetMemoryBusWidth(nvmlDevice_t device, unsigned int *busWidth); + +/** + * Gets the device's PCIE Max Link speed in MBPS + * + * @param device The identifier of the target device + * @param maxSpeed The devices's PCIE Max Link speed in MBPS + * + * @return + * - \ref NVML_SUCCESS if Pcie Max Link Speed is successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a maxSpeed is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * + */ +nvmlReturn_t DECLDIR nvmlDeviceGetPcieLinkMaxSpeed(nvmlDevice_t device, unsigned int *maxSpeed); + +/** + * Gets the device's Adaptive Clock status + * + * @param device The identifier of the target device + * @param adaptiveClockStatus The current adaptive clocking status + * + * @return + * - \ref NVML_SUCCESS if the current adaptive clocking status is successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a adaptiveClockStatus is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * + */ +nvmlReturn_t DECLDIR nvmlDeviceGetAdaptiveClockInfoStatus(nvmlDevice_t device, unsigned int *adaptiveClockStatus); + +/** * @} */ @@ -6588,6 +6821,8 @@ nvmlReturn_t DECLDIR nvmlVgpuInstanceGetFbUsage(nvmlVgpuInstance_t vgpuInstance, unsigned long long *fbUsage); /** + * @deprecated Use \ref nvmlVgpuInstanceGetLicenseInfo_v2. + * * Retrieve the current licensing state of the vGPU instance. * * If the vGPU is currently licensed, \a licensed is set to 1, otherwise it is set to 0. @@ -6813,6 +7048,45 @@ */ nvmlReturn_t DECLDIR nvmlVgpuInstanceGetGpuInstanceId(nvmlVgpuInstance_t vgpuInstance, unsigned int *gpuInstanceId); +/** +* Retrieves the PCI Id of the given vGPU Instance i.e. the PCI Id of the GPU as seen inside the VM. +* +* The vGPU PCI id is returned as "00000000:00:00.0" if NVIDIA driver is not installed on the vGPU instance. +* +* @param vgpuInstance Identifier of the target vGPU instance +* @param vgpuPciId Caller-supplied buffer to return vGPU PCI Id string +* @param length Size of the vgpuPciId buffer +* +* @return +* - \ref NVML_SUCCESS if vGPU PCI Id is sucessfully retrieved +* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized +* - \ref NVML_ERROR_INVALID_ARGUMENT if \a vgpuInstance is 0, or \a vgpuPciId is NULL +* - \ref NVML_ERROR_NOT_FOUND if \a vgpuInstance does not match a valid active vGPU instance on the system +* - \ref NVML_ERROR_DRIVER_NOT_LOADED if NVIDIA driver is not running on the vGPU instance +* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a length is too small, \a length is set to required length +* - \ref NVML_ERROR_UNKNOWN on any unexpected error +*/ +nvmlReturn_t DECLDIR nvmlVgpuInstanceGetGpuPciId(nvmlVgpuInstance_t vgpuInstance, char *vgpuPciId, unsigned int *length); + +/** +* Retrieve the requested capability for a given vGPU type. Refer to the \a nvmlVgpuCapability_t structure +* for the specific capabilities that can be queried. The return value in \a capResult should be treated as +* a boolean, with a non-zero value indicating that the capability is supported. +* +* For Maxwell &tm; or newer fully supported devices. +* +* @param vgpuTypeId Handle to vGPU type +* @param capability Specifies the \a nvmlVgpuCapability_t to be queried +* @param capResult A boolean for the queried capability indicating that feature is supported +* +* @return +* - \ref NVML_SUCCESS successful completion +* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized +* - \ref NVML_ERROR_INVALID_ARGUMENT if \a vgpuTypeId is invalid, or \a capability is invalid, or \a capResult is NULL +* - \ref NVML_ERROR_UNKNOWN on any unexpected error +*/ +nvmlReturn_t DECLDIR nvmlVgpuTypeGetCapabilities(nvmlVgpuTypeId_t vgpuTypeId, nvmlVgpuCapability_t capability, unsigned int *capResult); + /** @} */ /***************************************************************************************************/ @@ -7260,6 +7534,23 @@ * - \ref NVML_ERROR_UNKNOWN on any unexpected error */ nvmlReturn_t DECLDIR nvmlVgpuInstanceClearAccountingPids(nvmlVgpuInstance_t vgpuInstance); + +/** + * Query the license information of the vGPU instance. + * + * For Maxwell &tm; or newer fully supported devices. + * + * @param vgpuInstance Identifier of the target vGPU instance + * @param licenseInfo Pointer to vGPU license information structure + * + * @return + * - \ref NVML_SUCCESS if information is successfully retrieved + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a vgpuInstance is 0, or \a licenseInfo is NULL + * - \ref NVML_ERROR_NOT_FOUND if \a vgpuInstance does not match a valid active vGPU instance on the system + * - \ref NVML_ERROR_DRIVER_NOT_LOADED if NVIDIA driver is not running on the vGPU instance + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlVgpuInstanceGetLicenseInfo_v2(nvmlVgpuInstance_t vgpuInstance, nvmlVgpuLicenseInfo_t *licenseInfo); /** @} */ /***************************************************************************************************/ @@ -7348,10 +7639,13 @@ typedef struct nvmlGpuInstancePlacement_st { - unsigned int start; - unsigned int size; + unsigned int start; //!< Index of first occupied memory slice + unsigned int size; //!< Number of memory slices occupied } nvmlGpuInstancePlacement_t; +/** + * GPU instance profile information. + */ typedef struct nvmlGpuInstanceProfileInfo_st { unsigned int id; //!< Unique profile ID within the device @@ -7367,6 +7661,36 @@ unsigned long long memorySizeMB; //!< Memory size in MBytes } nvmlGpuInstanceProfileInfo_t; +/** + * GPU instance profile information (v2). + * + * Version 2 adds the \ref nvmlGpuInstanceProfileInfo_v2_t.version field + * to the start of the structure, and the \ref nvmlGpuInstanceProfileInfo_v2_t.name + * field to the end. This structure is not backwards-compatible with + * \ref nvmlGpuInstanceProfileInfo_t. + */ +typedef struct nvmlGpuInstanceProfileInfo_v2_st +{ + unsigned int version; //!< Structure version identifier (set to \ref nvmlGpuInstanceProfileInfo_v2) + unsigned int id; //!< Unique profile ID within the device + unsigned int isP2pSupported; //!< Peer-to-Peer support + unsigned int sliceCount; //!< GPU Slice count + unsigned int instanceCount; //!< GPU instance count + unsigned int multiprocessorCount; //!< Streaming Multiprocessor count + unsigned int copyEngineCount; //!< Copy Engine count + unsigned int decoderCount; //!< Decoder Engine count + unsigned int encoderCount; //!< Encoder Engine count + unsigned int jpegCount; //!< JPEG Engine count + unsigned int ofaCount; //!< OFA Engine count + unsigned long long memorySizeMB; //!< Memory size in MBytes + char name[NVML_DEVICE_NAME_V2_BUFFER_SIZE]; //!< Profile name +} nvmlGpuInstanceProfileInfo_v2_t; + +/** + * Version identifier value for \ref nvmlGpuInstanceProfileInfo_v2_t.version. + */ +#define nvmlGpuInstanceProfileInfo_v2 NVML_STRUCT_VERSION(GpuInstanceProfileInfo, 2) + typedef struct nvmlGpuInstanceInfo_st { nvmlDevice_t device; //!< Parent device @@ -7397,10 +7721,13 @@ typedef struct nvmlComputeInstancePlacement_st { - unsigned int start; - unsigned int size; + unsigned int start; //!< Index of first occupied compute slice + unsigned int size; //!< Number of compute slices occupied } nvmlComputeInstancePlacement_t; +/** + * Compute instance profile information. + */ typedef struct nvmlComputeInstanceProfileInfo_st { unsigned int id; //!< Unique profile ID within the GPU instance @@ -7414,13 +7741,41 @@ unsigned int sharedOfaCount; //!< Shared OFA Engine count } nvmlComputeInstanceProfileInfo_t; +/** + * Compute instance profile information (v2). + * + * Version 2 adds the \ref nvmlComputeInstanceProfileInfo_v2_t.version field + * to the start of the structure, and the \ref nvmlComputeInstanceProfileInfo_v2_t.name + * field to the end. This structure is not backwards-compatible with + * \ref nvmlComputeInstanceProfileInfo_t. + */ +typedef struct nvmlComputeInstanceProfileInfo_v2_st +{ + unsigned int version; //!< Structure version identifier (set to \ref nvmlComputeInstanceProfileInfo_v2) + unsigned int id; //!< Unique profile ID within the GPU instance + unsigned int sliceCount; //!< GPU Slice count + unsigned int instanceCount; //!< Compute instance count + unsigned int multiprocessorCount; //!< Streaming Multiprocessor count + unsigned int sharedCopyEngineCount; //!< Shared Copy Engine count + unsigned int sharedDecoderCount; //!< Shared Decoder Engine count + unsigned int sharedEncoderCount; //!< Shared Encoder Engine count + unsigned int sharedJpegCount; //!< Shared JPEG Engine count + unsigned int sharedOfaCount; //!< Shared OFA Engine count + char name[NVML_DEVICE_NAME_V2_BUFFER_SIZE]; //!< Profile name +} nvmlComputeInstanceProfileInfo_v2_t; + +/** + * Version identifier value for \ref nvmlComputeInstanceProfileInfo_v2_t.version. + */ +#define nvmlComputeInstanceProfileInfo_v2 NVML_STRUCT_VERSION(ComputeInstanceProfileInfo, 2) + typedef struct nvmlComputeInstanceInfo_st { nvmlDevice_t device; //!< Parent device nvmlGpuInstance_t gpuInstance; //!< Parent GPU instance unsigned int id; //!< Unique instance ID within the GPU instance unsigned int profileId; //!< Unique profile ID within the GPU instance - nvmlComputeInstancePlacement_t placement; //!< Placement for this instance within the GPU instance's slice range {0, sliceCount} + nvmlComputeInstancePlacement_t placement; //!< Placement for this instance within the GPU instance's compute slice range {0, sliceCount} } nvmlComputeInstanceInfo_t; typedef struct nvmlComputeInstance_st* nvmlComputeInstance_t; @@ -7489,7 +7844,6 @@ * * For Ampere &tm; or newer fully supported devices. * Supported on Linux only. - * Requires privileged user. * * @param device The identifier of the target device * @param profile One of the NVML_GPU_INSTANCE_PROFILE_* @@ -7506,10 +7860,43 @@ nvmlGpuInstanceProfileInfo_t *info); /** + * Versioned wrapper around \ref nvmlDeviceGetGpuInstanceProfileInfo that accepts a versioned + * \ref nvmlGpuInstanceProfileInfo_v2_t or later output structure. + * + * @note The caller must set the \ref nvmlGpuInstanceProfileInfo_v2_t.version field to the + * appropriate version prior to calling this function. For example: + * \code + * nvmlGpuInstanceProfileInfo_v2_t profileInfo = + * { .version = nvmlGpuInstanceProfileInfo_v2 }; + * nvmlReturn_t result = nvmlDeviceGetGpuInstanceProfileInfoV(device, + * profile, + * &profileInfo); + * \endcode + * + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux only. + * + * @param device The identifier of the target device + * @param profile One of the NVML_GPU_INSTANCE_PROFILE_* + * @param info Returns detailed profile information + * + * @return + * - \ref NVML_SUCCESS Upon success + * - \ref NVML_ERROR_UNINITIALIZED If library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT If \a device, \a profile, \a info, or \a info->version are invalid + * - \ref NVML_ERROR_NOT_SUPPORTED If \a device doesn't have MIG mode enabled or \a profile isn't supported + * - \ref NVML_ERROR_NO_PERMISSION If user doesn't have permission to perform the operation + */ +nvmlReturn_t DECLDIR nvmlDeviceGetGpuInstanceProfileInfoV(nvmlDevice_t device, unsigned int profile, + nvmlGpuInstanceProfileInfo_v2_t *info); + +/** * Get GPU instance placements. * * A placement represents the location of a GPU instance within a device. This API only returns all the possible * placements for the given profile. + * A created GPU instance occupies memory slices described by its placement. Creation of new GPU instance will + * fail if there is overlap with the already occupied memory slices. * * For Ampere &tm; or newer fully supported devices. * Supported on Linux only. @@ -7696,7 +8083,6 @@ * * For Ampere &tm; or newer fully supported devices. * Supported on Linux only. - * Requires privileged user. * * @param gpuInstance The identifier of the target GPU instance * @param profile One of the NVML_COMPUTE_INSTANCE_PROFILE_* @@ -7715,6 +8101,40 @@ nvmlComputeInstanceProfileInfo_t *info); /** + * Versioned wrapper around \ref nvmlGpuInstanceGetComputeInstanceProfileInfo that accepts a versioned + * \ref nvmlComputeInstanceProfileInfo_v2_t or later output structure. + * + * @note The caller must set the \ref nvmlGpuInstanceProfileInfo_v2_t.version field to the + * appropriate version prior to calling this function. For example: + * \code + * nvmlComputeInstanceProfileInfo_v2_t profileInfo = + * { .version = nvmlComputeInstanceProfileInfo_v2 }; + * nvmlReturn_t result = nvmlGpuInstanceGetComputeInstanceProfileInfoV(gpuInstance, + * profile, + * engProfile, + * &profileInfo); + * \endcode + * + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux only. + * + * @param gpuInstance The identifier of the target GPU instance + * @param profile One of the NVML_COMPUTE_INSTANCE_PROFILE_* + * @param engProfile One of the NVML_COMPUTE_INSTANCE_ENGINE_PROFILE_* + * @param info Returns detailed profile information + * + * @return + * - \ref NVML_SUCCESS Upon success + * - \ref NVML_ERROR_UNINITIALIZED If library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT If \a gpuInstance, \a profile, \a engProfile, \a info, or \a info->version are invalid + * - \ref NVML_ERROR_NOT_SUPPORTED If \a profile isn't supported + * - \ref NVML_ERROR_NO_PERMISSION If user doesn't have permission to perform the operation + */ +nvmlReturn_t DECLDIR nvmlGpuInstanceGetComputeInstanceProfileInfoV(nvmlGpuInstance_t gpuInstance, unsigned int profile, + unsigned int engProfile, + nvmlComputeInstanceProfileInfo_v2_t *info); + +/** * Get compute instance profile capacity. * * For Ampere &tm; or newer fully supported devices. @@ -7975,6 +8395,20 @@ */ nvmlReturn_t DECLDIR nvmlDeviceGetDeviceHandleFromMigDeviceHandle(nvmlDevice_t migDevice, nvmlDevice_t *device); +/** + * Get the type of the GPU Bus (PCIe, PCI, ...) + * + * @param device The identifier of the target device + * @param type The PCI Bus type + * + * return + * - \ref NVML_SUCCESS if the bus \a type is successfully retreived + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \device is invalid or \type is NULL + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetBusType(nvmlDevice_t device, nvmlBusType_t *type); + /** @} */ /** @@ -7997,9 +8431,13 @@ nvmlReturn_t DECLDIR nvmlDeviceGetAttributes(nvmlDevice_t device, nvmlDeviceAttributes_t *attributes); nvmlReturn_t DECLDIR nvmlComputeInstanceGetInfo(nvmlComputeInstance_t computeInstance, nvmlComputeInstanceInfo_t *info); nvmlReturn_t DECLDIR nvmlDeviceGetComputeRunningProcesses(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_v1_t *infos); +nvmlReturn_t DECLDIR nvmlDeviceGetComputeRunningProcesses_v2(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_v2_t *infos); nvmlReturn_t DECLDIR nvmlDeviceGetGraphicsRunningProcesses(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_v1_t *infos); +nvmlReturn_t DECLDIR nvmlDeviceGetGraphicsRunningProcesses_v2(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_v2_t *infos); nvmlReturn_t DECLDIR nvmlDeviceGetMPSComputeRunningProcesses(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_v1_t *infos); +nvmlReturn_t DECLDIR nvmlDeviceGetMPSComputeRunningProcesses_v2(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_v2_t *infos); nvmlReturn_t DECLDIR nvmlDeviceGetGpuInstancePossiblePlacements(nvmlDevice_t device, unsigned int profileId, nvmlGpuInstancePlacement_t *placements, unsigned int *count); +nvmlReturn_t DECLDIR nvmlVgpuInstanceGetLicenseInfo(nvmlVgpuInstance_t vgpuInstance, nvmlVgpuLicenseInfo_t *licenseInfo); #endif // #ifdef NVML_NO_UNVERSIONED_FUNC_DEFS #if defined(NVML_NO_UNVERSIONED_FUNC_DEFS) @@ -8024,6 +8462,7 @@ #undef nvmlGetBlacklistDeviceCount #undef nvmlGetBlacklistDeviceInfoByIndex #undef nvmlDeviceGetGpuInstancePossiblePlacements +#undef nvmlVgpuInstanceGetLicenseInfo #endif #ifdef __cplusplus diff -Nru nvidia-settings-470.57.01/src/option-table.h nvidia-settings-510.47.03/src/option-table.h --- nvidia-settings-470.57.01/src/option-table.h 2021-07-07 22:48:17.000000000 +0000 +++ nvidia-settings-510.47.03/src/option-table.h 2022-01-24 23:51:09.000000000 +0000 @@ -181,7 +181,7 @@ 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." }, + "By default, the \"System Information\" page is displayed." }, { "list-targets-only", 'L', NVGETOPT_HELP_ALWAYS, NULL, "When performing an attribute query (from the '--query' command line " diff -Nru nvidia-settings-470.57.01/src/parse.c nvidia-settings-510.47.03/src/parse.c --- nvidia-settings-470.57.01/src/parse.c 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/parse.c 2022-01-24 23:51:09.000000000 +0000 @@ -67,7 +67,7 @@ */ /* Version information */ - { "OperatingSystem", NV_CTRL_OPERATING_SYSTEM, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "The operating system on which the X server is running. 0-Linux, 1-FreeBSD, 2-SunOS." }, + { "OperatingSystem", NV_CTRL_OPERATING_SYSTEM, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "The operating system on which the NVIDIA driver is running. 0-Linux, 1-FreeBSD, 2-SunOS." }, { "NvidiaDriverVersion", NV_CTRL_STRING_NVIDIA_DRIVER_VERSION, STR_ATTR, {0,0,0,1,0}, {}, "The NVIDIA X driver version." }, { "NvControlVersion", NV_CTRL_STRING_NV_CONTROL_VERSION, STR_ATTR, {0,0,0,1,0}, {}, "The NV-CONTROL X driver extension version." }, { "GLXServerVersion", NV_CTRL_STRING_GLX_SERVER_VERSION, STR_ATTR, {0,0,0,1,0}, {}, "The GLX X server extension version." }, @@ -142,6 +142,7 @@ { "PCIECurrentLinkWidth", NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the current PCIe link width of the GPU, in number of lanes." }, { "VideoRam", NV_CTRL_VIDEO_RAM, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the total amount of memory available to the specified GPU (or the GPU driving the specified X screen). Note: if the GPU supports TurboCache(TM), the value reported may exceed the amount of video memory installed on the GPU. The value reported for integrated GPUs may likewise exceed the amount of dedicated system memory set aside by the system BIOS for use by the integrated GPU." }, { "TotalDedicatedGPUMemory", NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the amount of total dedicated memory on the specified GPU in MB." }, + { "GPUResizableBAR", NV_CTRL_RESIZABLE_BAR, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns whether Resizable BAR is supported." }, { "UsedDedicatedGPUMemory", NV_CTRL_USED_DEDICATED_GPU_MEMORY, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the amount of dedicated memory used on the specified GPU in MB." }, { "Irq", NV_CTRL_IRQ, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the interrupt request line used by the specified device. If the target is an X screen, then it uses the GPU driving the X screen as the device." }, { "CUDACores", NV_CTRL_GPU_CORES, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns number of CUDA cores supported by the graphics pipeline." }, @@ -160,7 +161,6 @@ { "GPUDefault2DClockFreqs", NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "NOT SUPPORTED." }, { "GPUDefault3DClockFreqs", NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "NOT SUPPORTED." }, { "GPUCurrentClockFreqs", NV_CTRL_GPU_CURRENT_CLOCK_FREQS, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,1,0,0,0,0} }, "Returns the current GPU and memory clocks of the graphics device driving the X screen." }, - { "GPUCurrentProcessorClockFreqs", NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the current processor clock of the graphics device driving the X screen." }, { "BusRate", NV_CTRL_BUS_RATE, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "If the device is on an AGP bus, then BusRate returns the configured AGP rate. If the device is on a PCI Express bus, then this attribute returns the width of the physical link." }, { "PCIDomain", NV_CTRL_PCI_DOMAIN, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the PCI domain number for the specified device." }, { "PCIBus", NV_CTRL_PCI_BUS, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the PCI bus number for the specified device." }, @@ -196,8 +196,6 @@ { "ThermalSensorReading", NV_CTRL_THERMAL_SENSOR_READING, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the thermal sensor's current reading." }, { "ThermalSensorProvider", NV_CTRL_THERMAL_SENSOR_PROVIDER, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the hardware device that provides the thermal sensor." }, { "ThermalSensorTarget", NV_CTRL_THERMAL_SENSOR_TARGET, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns what hardware component the thermal sensor is measuring." }, - { "GPUDoublePrecisionBoostImmediate", NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Toggles GPU double precision; the change is applied immediately. Only available when the change can be made immediately." }, - { "GPUDoublePrecisionBoostReboot", NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Toggles GPU double precision; the change is applied on the next reboot. Only available when the change requires a reboot." }, { "BaseMosaic", NV_CTRL_BASE_MOSAIC, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns the current Base Mosaic configuration." }, { "MultiGpuPrimaryPossible", NV_CTRL_MULTIGPU_PRIMARY_POSSIBLE, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "Returns whether or not the GPU can be configured as the primary GPU for a Multi GPU configuration (SLI, SLI Mosaic, Base Mosaic, ...)." }, { "MultiGpuMasterPossible", NV_CTRL_MULTIGPU_PRIMARY_POSSIBLE, INT_ATTR, {0,0,0,1,0}, { .int_flags = {0,0,0,0,0,0,0} }, "This attribute is deprecated. Please use 'MultiGpuPrimaryPossible' instead." }, @@ -330,10 +328,18 @@ { "3DVisionProGlassesAddress", NV_CTRL_STRING_3D_VISION_PRO_GLASSES_ADDRESS, STR_ATTR, {0,0,1,1,0}, {}, "Returns the RF address of the glasses."}, { "3DVisionProGlassesName", NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME, STR_ATTR, {0,0,1,1,0}, {}, "Controls the name the glasses should use."}, + /* Mux Control */ + { "MuxState", NV_CTRL_STRING_MUX_STATE, STR_ATTR, {0,0,0,1,0}, {}, "Controls whether the specified mux is configured to use the discrete or integrated GPU."}, + { "MuxAutoSwitch", NV_CTRL_MUX_AUTO_SWITCH, INT_ATTR, {0,0,0,1,0}, {}, "Controls whether the specified mux switches automatically."}, + { "MuxIsInternal", NV_CTRL_MUX_IS_INTERNAL, INT_ATTR, {0,0,0,1,0}, {}, "Returns whether the specified mux is internal."}, + + /* Misc */ { "GTFModeline", NV_CTRL_STRING_OPERATION_GTF_MODELINE, SOP_ATTR, {0,0,0,1,1}, { }, "Builds a modeline using the GTF formula." }, { "CVTModeline", NV_CTRL_STRING_OPERATION_CVT_MODELINE, SOP_ATTR, {0,0,0,1,1}, { }, "Builds a modeline using the CVT formula." }, + /* Dynamic Boost */ + { "DynamicBoostSupport", NV_CTRL_DYNAMIC_BOOST_SUPPORT, INT_ATTR, {0,0,0,1,0}, {}, "Returns whether the system supports Dynamic Boost." }, }; const int attributeTableLen = ARRAY_LEN(attributeTable); @@ -344,11 +350,11 @@ * the last attribute that the table knows about. */ -#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_PLATFORM_CURRENT_POWER_MODE +#if NV_CTRL_LAST_ATTRIBUTE != NV_CTRL_DYNAMIC_BOOST_SUPPORT #warning "Have you forgotten to add a new integer attribute to attributeTable?" #endif -#if NV_CTRL_STRING_LAST_ATTRIBUTE != NV_CTRL_STRING_DISPLAY_NAME_CONNECTOR +#if NV_CTRL_STRING_LAST_ATTRIBUTE != NV_CTRL_STRING_MUX_STATE #warning "Have you forgotten to add a new string attribute to attributeTable?" #endif diff -Nru nvidia-settings-470.57.01/src/query-assign.c nvidia-settings-510.47.03/src/query-assign.c --- nvidia-settings-470.57.01/src/query-assign.c 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/query-assign.c 2022-01-24 23:51:09.000000000 +0000 @@ -601,7 +601,7 @@ const char *whence) { CtrlAttributePerms perms; - CtrlTarget *ctrl_target; + CtrlTarget *ctrl_target = NULL; ReturnStatus status; int ret = NV_PARSER_STATUS_SUCCESS; int i; @@ -614,7 +614,13 @@ return NV_PARSER_STATUS_BAD_ARGUMENT; } - ctrl_target = NvCtrlGetDefaultTarget(system); + if (system->has_nvml) { + ctrl_target = NvCtrlGetDefaultTargetByType(system, GPU_TARGET); + } + if (!ctrl_target) { + ctrl_target = NvCtrlGetDefaultTarget(system); + } + if (ctrl_target == NULL) { return NV_PARSER_STATUS_TARGET_SPEC_NO_TARGETS; } @@ -774,6 +780,11 @@ continue; } + if (nv_strcasecmp(queries[query], "muxes")) { + query_all_targets(display_name, MUX_TARGET, systems); + continue; + } + /* call the parser to parse queries[query] */ ret = nv_parse_attribute_string(queries[query], NV_PARSER_QUERY, &a); @@ -1436,7 +1447,8 @@ goto exit_bit_loop; } - if (status != NvCtrlSuccess) { + if (status != NvCtrlSuccess && + status != NvCtrlMissingExtension) { nv_error_msg("Error while querying valid values for " "attribute '%s' on %s (%s).", a->name, t->name, @@ -1675,6 +1687,7 @@ case COOLER_TARGET: case FRAMELOCK_TARGET: case X_SCREEN_TARGET: + case MUX_TARGET: default: break; } @@ -1743,7 +1756,11 @@ /* build the standard X server name */ - str = nv_standardize_screen_name(XDisplayName(system->display), -2); + if (system->has_nv_control) { + str = nv_standardize_screen_name(XDisplayName(system->display), -2); + } else { + str = strdup(system->display); + } /* warn if we don't have any of the target type */ @@ -1786,6 +1803,7 @@ case COOLER_TARGET: case THERMAL_SENSOR_TARGET: case NVIDIA_3D_VISION_PRO_TRANSCEIVER_TARGET: + case MUX_TARGET: snprintf(product_name, PRODUCT_NAME_LEN, "%s %d", targetTypeInfo->name, target_id); break; @@ -1909,6 +1927,10 @@ GPU_TARGET); break; + case MUX_TARGET: + /* Target connections not yet supported. */ + break; + default: break; } @@ -2123,7 +2145,7 @@ /* if we don't have a Display connection, abort now */ - if (system == NULL || system->dpy == NULL) { + if (system == NULL) { nv_error_msg("Unable to %s attribute %s specified %s (no Display " "connection).", assign ? "assign" : "query", a->name, whence); diff -Nru nvidia-settings-470.57.01/src/version.mk nvidia-settings-510.47.03/src/version.mk --- nvidia-settings-470.57.01/src/version.mk 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/src/version.mk 2022-01-24 23:51:09.000000000 +0000 @@ -1,4 +1,4 @@ -NVIDIA_VERSION = 470.57.01 +NVIDIA_VERSION = 510.47.03 # This file. VERSION_MK_FILE := $(lastword $(MAKEFILE_LIST)) diff -Nru nvidia-settings-470.57.01/utils.mk nvidia-settings-510.47.03/utils.mk --- nvidia-settings-470.57.01/utils.mk 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/utils.mk 2022-01-24 23:51:09.000000000 +0000 @@ -59,6 +59,10 @@ HOST_CC_ONLY_CFLAGS += -Wno-format-zero-length HOST_CFLAGS += -Wno-unused-parameter +# Treat warnings as errors, if requested +WARNINGS_AS_ERRORS ?= +CFLAGS += $(if $(WARNINGS_AS_ERRORS),-Werror) + DEBUG ?= DEVELOP ?= @@ -182,6 +186,8 @@ NV_GENERATED_HEADERS ?= +PCIACCESS_CFLAGS ?= +PCIACCESS_LDFLAGS ?= ############################################################################## # This makefile uses the $(eval) builtin function, which was added in @@ -376,6 +382,7 @@ BUILD_OBJECT_LIST = \ $(call BUILD_OBJECT_LIST_WITH_DIR,$(1),$(OUTPUTDIR)) +$(call BUILD_OBJECT_LIST,nvpci-utils.c): CFLAGS += $(PCIACCESS_CFLAGS) ############################################################################## # function to generate a list of dependency files from their diff -Nru nvidia-settings-470.57.01/version.mk nvidia-settings-510.47.03/version.mk --- nvidia-settings-470.57.01/version.mk 2021-07-07 22:48:13.000000000 +0000 +++ nvidia-settings-510.47.03/version.mk 2022-01-24 23:51:09.000000000 +0000 @@ -1,4 +1,4 @@ -NVIDIA_VERSION = 470.57.01 +NVIDIA_VERSION = 510.47.03 # This file. VERSION_MK_FILE := $(lastword $(MAKEFILE_LIST))