def _get_PAT_parameter_value(config): pat_value = {"yes": 1, "no": 0}[config["nvidia"]["pat"]] if not checks.is_pat_available(): print("Warning : Page Attribute Tables are not available on your system.\n" "Disabling the PAT option for Nvidia.") pat_value = 0 return pat_value
def switch_to_nvidia(config): print("Switching to Nvidia") if config["optimus"]["switching"] == "bbswitch": # bbswitch module print("Loading bbswitch module") try: exec_bash("modprobe bbswitch") except BashError as e: raise SwitchError("Cannot load bbswitch : %s" % str(e)) # bbswitch switching print("Ordering ON via bbswitch") exec_bash("echo ON | tee /proc/acpi/bbswitch") if not checks.is_gpu_powered(): raise SwitchError("bbswitch refuses to turn ON the GPU") else: print("bbswitch reports that the GPU is ON") # Unloading nouveau print("Unloading nouveau module") try: exec_bash("modprobe -r nouveau") except BashError as e: raise SwitchError("Cannot unload nouveau : %s" % str(e)) # Nvidia modules print("Loading Nvidia modules") modeset_value = {"yes": 1, "no": 0}[config["nvidia"]["modeset"]] pat_value = {"yes": 1, "no": 0}[config["nvidia"]["PAT"]] if not checks.is_pat_available(): print( "Warning : Page Attribute Tables are not available on your system.\n" "Disabling the PAT option for Nvidia.") pat_value = 0 try: exec_bash("modprobe nvidia NVreg_UsePageAttributeTable=%d" % pat_value) exec_bash("modprobe nvidia_uvm nvidia_modeset") exec_bash("modprobe nvidia_drm modeset=%d" % modeset_value) except BashError as e: raise SwitchError("Cannot load Nvidia modules : %s" % str(e)) # Xorg configuration print("Configuring Xorg...") configure_xorg(config, mode="nvidia") # Login managers configuration print("Configuring login managers..") configure_login_managers(mode="nvidia")
def switch_to_nvidia(config): print("Switching to Nvidia") if config["optimus"]["switching"] == "bbswitch": if not checks.is_module_available("bbswitch"): print( "Module bbswitch not available for current kernel. Skipping bbswitch power switching." ) else: # bbswitch module print("Loading bbswitch module") try: exec_bash("modprobe bbswitch") except BashError as e: raise SwitchError("Cannot load bbswitch : %s" % str(e)) # bbswitch switching print("Ordering ON via bbswitch") exec_bash("echo ON | tee /proc/acpi/bbswitch") if not checks.is_gpu_powered(): raise SwitchError("bbswitch refuses to turn ON the GPU") else: print("bbswitch reports that the GPU is ON") # Unloading nouveau print("Unloading nouveau module") try: exec_bash("modprobe -r nouveau") except BashError as e: raise SwitchError("Cannot unload nouveau : %s" % str(e)) # Nvidia modules print("Loading Nvidia modules") pat_value = {"yes": 1, "no": 0}[config["nvidia"]["PAT"]] if not checks.is_pat_available(): print( "Warning : Page Attribute Tables are not available on your system.\n" "Disabling the PAT option for Nvidia.") pat_value = 0 try: exec_bash("modprobe nvidia NVreg_UsePageAttributeTable=%d" % pat_value) if config["nvidia"]["modeset"] == "yes": exec_bash("modprobe nvidia_drm modeset=1") else: exec_bash("modprobe nvidia_drm modeset=0") except BashError as e: raise SwitchError("Cannot load Nvidia modules : %s" % str(e)) # PCI power management if config["optimus"]["pci_power_control"] == "yes": if config["optimus"]["switching"] == "bbswitch": print("bbswitch is enabled, pci_power_control option ignored.") else: try: pci.set_power_management(False) except pci.PCIError as e: print("WARNING : Cannot set PCI power management : %s" % str(e)) # Xorg configuration print("Configuring Xorg...") configure_xorg(config, mode="nvidia") # Login managers configuration print("Configuring login managers..") configure_login_managers(config, mode="nvidia")