mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2024-11-21 15:57:25 -06:00
attempt to use NVML for clock setting on non-X
This commit is contained in:
parent
d41030d559
commit
38e178bf0f
@ -2,4 +2,5 @@ cd "$(dirname "$0")"
|
|||||||
|
|
||||||
sudo dbus-run-session --config-file=dbusconf.conf \
|
sudo dbus-run-session --config-file=dbusconf.conf \
|
||||||
sudo -E DBUS_SYSTEM_BUS_ADDRESS=unix:path=/tmp/tuxclocker-dbus-socket \
|
sudo -E DBUS_SYSTEM_BUS_ADDRESS=unix:path=/tmp/tuxclocker-dbus-socket \
|
||||||
|
XDG_SESSION_TYPE=$XDG_SESSION_TYPE \
|
||||||
LD_LIBRARY_PATH=../inst/lib ../inst/bin/tuxclockerd
|
LD_LIBRARY_PATH=../inst/lib ../inst/bin/tuxclockerd
|
||||||
|
@ -21,7 +21,7 @@ export TUXCLOCKER_PLUGIN_PATH=\"$tuxclockerPluginPath\"
|
|||||||
nvidiaVersion=\$(cat /sys/module/nvidia/version | sed 's/\./-/g')
|
nvidiaVersion=\$(cat /sys/module/nvidia/version | sed 's/\./-/g')
|
||||||
flatpakNvidiaPath=\$(find /var/lib/flatpak/runtime/org.freedesktop.Platform.GL.nvidia-\$nvidiaVersion/x86_64/*/active/files/lib)
|
flatpakNvidiaPath=\$(find /var/lib/flatpak/runtime/org.freedesktop.Platform.GL.nvidia-\$nvidiaVersion/x86_64/*/active/files/lib)
|
||||||
sudo -E dbus-run-session --config-file=dev/dbusconf.conf \
|
sudo -E dbus-run-session --config-file=dev/dbusconf.conf \
|
||||||
sudo -E LD_LIBRARY_PATH=\$flatpakNvidiaPath:\"\$LD_LIBRARY_PATH\" ./.tuxclockerd-wrapped & \
|
sudo -E LD_LIBRARY_PATH=\$flatpakNvidiaPath:\"\$LD_LIBRARY_PATH\" XDG_SESSION_TYPE=\$XDG_SESSION_TYPE ./.tuxclockerd-wrapped & \
|
||||||
(unset LD_LIBRARY_PATH; sleep 2) && ./.tuxclocker-qt-wrapped; \
|
(unset LD_LIBRARY_PATH; sleep 2) && ./.tuxclocker-qt-wrapped; \
|
||||||
unset LD_LIBRARY_PATH && \
|
unset LD_LIBRARY_PATH && \
|
||||||
sudo kill \$(pidof .tuxclockerd-wrapped)
|
sudo kill \$(pidof .tuxclockerd-wrapped)
|
||||||
|
@ -94,6 +94,15 @@ std::optional<NvidiaGPUData> fromIndex(Display *dpy, uint i) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isXorg() {
|
||||||
|
auto value = std::getenv("XDG_SESSION_TYPE");
|
||||||
|
if (!value)
|
||||||
|
// Assume X, since that will lead to the least amount of broken
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return std::string{value} == "x11";
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<TreeNode<DeviceNode>> getGPUName(NvidiaGPUData data) {
|
std::vector<TreeNode<DeviceNode>> getGPUName(NvidiaGPUData data) {
|
||||||
char name[NVML_DEVICE_NAME_BUFFER_SIZE];
|
char name[NVML_DEVICE_NAME_BUFFER_SIZE];
|
||||||
if (nvmlDeviceGetName(data.devHandle, name, NVML_DEVICE_NAME_BUFFER_SIZE) == NVML_SUCCESS)
|
if (nvmlDeviceGetName(data.devHandle, name, NVML_DEVICE_NAME_BUFFER_SIZE) == NVML_SUCCESS)
|
||||||
@ -247,6 +256,64 @@ std::vector<TreeNode<DeviceNode>> getCoreClockWrite(NvidiaGPUData data) {
|
|||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<TreeNode<DeviceNode>> getCoreClockWriteNoX(NvidiaGPUData data) {
|
||||||
|
// Try to use NVML function only on non-X, since seems to be broken on some GPUs
|
||||||
|
if (isXorg())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
// Completely made-up range
|
||||||
|
Range<int> range{-300, 1000};
|
||||||
|
|
||||||
|
auto setFunc = [=](AssignmentArgument a) -> std::optional<AssignmentError> {
|
||||||
|
if (!std::holds_alternative<int>(a))
|
||||||
|
return AssignmentError::InvalidType;
|
||||||
|
auto target = std::get<int>(a);
|
||||||
|
if (target < range.min || target > range.max)
|
||||||
|
return AssignmentError::OutOfRange;
|
||||||
|
|
||||||
|
auto retval = nvmlDeviceSetGpcClkVfOffset(data.devHandle, target);
|
||||||
|
return fromNVMLRet(retval);
|
||||||
|
};
|
||||||
|
|
||||||
|
// No way to get through NVML by the looks if it
|
||||||
|
auto getFunc = []() { return 0; };
|
||||||
|
|
||||||
|
return {DeviceNode{
|
||||||
|
.name = _("Core Clock Offset"),
|
||||||
|
.interface = Assignable{setFunc, range, getFunc, _("MHz")},
|
||||||
|
.hash = md5(data.uuid + "Core Clock Offset NVML"),
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<TreeNode<DeviceNode>> getMemoryClockWriteNoX(NvidiaGPUData data) {
|
||||||
|
// Try to use NVML function only on non-X, since seems to be broken on some GPUs
|
||||||
|
if (isXorg())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
// Completely made-up range
|
||||||
|
Range<int> range{-800, 1000};
|
||||||
|
|
||||||
|
auto setFunc = [=](AssignmentArgument a) -> std::optional<AssignmentError> {
|
||||||
|
if (!std::holds_alternative<int>(a))
|
||||||
|
return AssignmentError::InvalidType;
|
||||||
|
auto target = std::get<int>(a);
|
||||||
|
if (target < range.min || target > range.max)
|
||||||
|
return AssignmentError::OutOfRange;
|
||||||
|
|
||||||
|
auto retval = nvmlDeviceSetMemClkVfOffset(data.devHandle, target);
|
||||||
|
return fromNVMLRet(retval);
|
||||||
|
};
|
||||||
|
|
||||||
|
// No way to get through NVML by the looks if it
|
||||||
|
auto getFunc = []() { return 0; };
|
||||||
|
|
||||||
|
return {DeviceNode{
|
||||||
|
.name = _("Memory Clock Offset"),
|
||||||
|
.interface = Assignable{setFunc, range, getFunc, _("MHz")},
|
||||||
|
.hash = md5(data.uuid + "Memory Clock Offset NVML"),
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<TreeNode<DeviceNode>> getCoreClockRead(NvidiaGPUData data) {
|
std::vector<TreeNode<DeviceNode>> getCoreClockRead(NvidiaGPUData data) {
|
||||||
auto func = [data]() -> ReadResult {
|
auto func = [data]() -> ReadResult {
|
||||||
uint clock;
|
uint clock;
|
||||||
@ -827,7 +894,9 @@ auto gpuTree = TreeConstructor<NvidiaGPUData, DeviceNode>{
|
|||||||
{getCoreClockRead, {}},
|
{getCoreClockRead, {}},
|
||||||
{getCoreClockWrite, {}},
|
{getCoreClockWrite, {}},
|
||||||
{getMemClockRead, {}},
|
{getMemClockRead, {}},
|
||||||
{getMemClockWrite, {}}
|
{getMemClockWrite, {}},
|
||||||
|
{getCoreClockWriteNoX, {}},
|
||||||
|
{getMemoryClockWriteNoX, {}}
|
||||||
}},
|
}},
|
||||||
{getFanRoot, {
|
{getFanRoot, {
|
||||||
{getMultiFanRoots, {
|
{getMultiFanRoots, {
|
||||||
|
Loading…
Reference in New Issue
Block a user