mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
nvidia: put fan mode assignable in the "Fans" subtree
This commit is contained in:
parent
30ea5f10b5
commit
0e08359039
@ -570,10 +570,10 @@ NvidiaPlugin::NvidiaPlugin() : m_dpy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<UnspecializedAssignable<uint>> rawNVCTRLAssignables = {
|
std::vector<UnspecializedAssignable<uint>> rawNVCTRLFanModeAssignables = {
|
||||||
{
|
{
|
||||||
[=](uint index) -> std::optional<AssignableInfo> {
|
.assignableInfo = [=](uint index) -> std::optional<AssignableInfo> {
|
||||||
NVCTRLAttributeValidValuesRec values;
|
NVCTRLAttributeValidValuesRec values;
|
||||||
if (XNVCTRLQueryValidTargetAttributeValues(m_dpy, NV_CTRL_TARGET_TYPE_GPU,
|
if (XNVCTRLQueryValidTargetAttributeValues(m_dpy, NV_CTRL_TARGET_TYPE_GPU,
|
||||||
index, 0,
|
index, 0,
|
||||||
@ -584,7 +584,7 @@ NvidiaPlugin::NvidiaPlugin() : m_dpy() {
|
|||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
},
|
},
|
||||||
[=](uint index, AssignableInfo, AssignmentArgument a_arg) {
|
.func = [=](uint index, AssignableInfo, AssignmentArgument a_arg) {
|
||||||
std::optional<AssignmentError> ret = AssignmentError::InvalidType;
|
std::optional<AssignmentError> ret = AssignmentError::InvalidType;
|
||||||
if_let(pattern(as<uint>(arg)) = a_arg) = [=, &ret](auto u) {
|
if_let(pattern(as<uint>(arg)) = a_arg) = [=, &ret](auto u) {
|
||||||
switch(u) {
|
switch(u) {
|
||||||
@ -603,7 +603,7 @@ NvidiaPlugin::NvidiaPlugin() : m_dpy() {
|
|||||||
};
|
};
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
[=](uint index) -> std::optional<AssignmentArgument> {
|
.currentValueFunc = [=](uint index) -> std::optional<AssignmentArgument> {
|
||||||
int value;
|
int value;
|
||||||
auto valid = XNVCTRLQueryTargetAttribute(m_dpy, NV_CTRL_TARGET_TYPE_GPU, index, 0,
|
auto valid = XNVCTRLQueryTargetAttribute(m_dpy, NV_CTRL_TARGET_TYPE_GPU, index, 0,
|
||||||
NV_CTRL_GPU_COOLER_MANUAL_CONTROL, &value);
|
NV_CTRL_GPU_COOLER_MANUAL_CONTROL, &value);
|
||||||
@ -612,15 +612,14 @@ NvidiaPlugin::NvidiaPlugin() : m_dpy() {
|
|||||||
0u : 1u;
|
0u : 1u;
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
},
|
},
|
||||||
std::nullopt,
|
.unit = std::nullopt,
|
||||||
"Fan Mode",
|
.nodeName = "Fan Mode",
|
||||||
[](std::string uuid, uint) {
|
.hash = [](std::string uuid, uint) {
|
||||||
return md5(uuid + "Fan Mode");
|
return md5(uuid + "Fan Mode");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct NVMLFanInfo {
|
struct NVMLFanInfo {
|
||||||
nvmlDevice_t dev;
|
nvmlDevice_t dev;
|
||||||
uint index;
|
uint index;
|
||||||
@ -826,7 +825,11 @@ NvidiaPlugin::NvidiaPlugin() : m_dpy() {
|
|||||||
.name = "Clocks",
|
.name = "Clocks",
|
||||||
.hash = md5(nvOpt.uuid + "Clocks")
|
.hash = md5(nvOpt.uuid + "Clocks")
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
auto fanRoot = TreeNode(DeviceNode{
|
||||||
|
.name = "Fans",
|
||||||
|
.hash = md5(nvOpt.uuid + "Fans")
|
||||||
|
});
|
||||||
std::vector<DeviceNode> nvmlFanNodes;
|
std::vector<DeviceNode> nvmlFanNodes;
|
||||||
// Get nvml nodes if there is a device
|
// Get nvml nodes if there is a device
|
||||||
if_let(pattern(some(arg)) = nvOpt.devHandle) = [&](auto dev) {
|
if_let(pattern(some(arg)) = nvOpt.devHandle) = [&](auto dev) {
|
||||||
@ -884,11 +887,7 @@ NvidiaPlugin::NvidiaPlugin() : m_dpy() {
|
|||||||
for (auto &node : UnspecializedAssignable<NVClockInfo>::toDeviceNodes(
|
for (auto &node : UnspecializedAssignable<NVClockInfo>::toDeviceNodes(
|
||||||
rawNVCTRLClockAssignables, clockInfo, nvOpt.uuid))
|
rawNVCTRLClockAssignables, clockInfo, nvOpt.uuid))
|
||||||
clockRoot.appendChild(node);
|
clockRoot.appendChild(node);
|
||||||
|
|
||||||
for (auto &node : UnspecializedAssignable<uint>::toDeviceNodes(
|
|
||||||
rawNVCTRLAssignables, index, nvOpt.uuid))
|
|
||||||
gpuRoot.appendChild(node);
|
|
||||||
|
|
||||||
for (int i = 0; i < nvctrlFanCount(index); i++) {
|
for (int i = 0; i < nvctrlFanCount(index); i++) {
|
||||||
NVCtrlFanInfo info{index, i};
|
NVCtrlFanInfo info{index, i};
|
||||||
for (auto &node : UnspecializedAssignable<NVCtrlFanInfo>::toDeviceNodes(
|
for (auto &node : UnspecializedAssignable<NVCtrlFanInfo>::toDeviceNodes(
|
||||||
@ -902,6 +901,11 @@ NvidiaPlugin::NvidiaPlugin() : m_dpy() {
|
|||||||
for (auto &node : UnspecializedAssignable<uint>::toDeviceNodes(
|
for (auto &node : UnspecializedAssignable<uint>::toDeviceNodes(
|
||||||
rawNVCTRLVoltageAssignables, index, nvOpt.uuid))
|
rawNVCTRLVoltageAssignables, index, nvOpt.uuid))
|
||||||
gpuRoot.appendChild(node);
|
gpuRoot.appendChild(node);
|
||||||
|
|
||||||
|
// Fan mode node (really just one)
|
||||||
|
for (auto &node : UnspecializedAssignable<uint>::toDeviceNodes(
|
||||||
|
rawNVCTRLFanModeAssignables, index, nvOpt.uuid))
|
||||||
|
fanRoot.appendChild(node);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!utilRoot.children().empty())
|
if (!utilRoot.children().empty())
|
||||||
@ -910,13 +914,9 @@ NvidiaPlugin::NvidiaPlugin() : m_dpy() {
|
|||||||
if (!clockRoot.children().empty())
|
if (!clockRoot.children().empty())
|
||||||
gpuRoot.appendChild(clockRoot);
|
gpuRoot.appendChild(clockRoot);
|
||||||
|
|
||||||
TreeNode<DeviceNode> fanRoot = TreeNode(DeviceNode{
|
|
||||||
.name = "Fans",
|
|
||||||
.hash = md5(nvOpt.uuid + "Fans")
|
|
||||||
});
|
|
||||||
// Use a common subparent for readable and assignable fan nodes, if n > 1
|
// Use a common subparent for readable and assignable fan nodes, if n > 1
|
||||||
auto maxFanCount = std::max(nvmlFanNodes.size(), nvctrlFanNodes.size());
|
auto maxFanCount = std::max(nvmlFanNodes.size(), nvctrlFanNodes.size());
|
||||||
if (1) {
|
if (maxFanCount > 1) {
|
||||||
for (uint i = 0; i < maxFanCount; i++) {
|
for (uint i = 0; i < maxFanCount; i++) {
|
||||||
auto subFanRoot = TreeNode<DeviceNode>(DeviceNode{
|
auto subFanRoot = TreeNode<DeviceNode>(DeviceNode{
|
||||||
.name = std::to_string(i),
|
.name = std::to_string(i),
|
||||||
@ -928,17 +928,18 @@ NvidiaPlugin::NvidiaPlugin() : m_dpy() {
|
|||||||
subFanRoot.appendChild(nvmlFanNodes[i]);
|
subFanRoot.appendChild(nvmlFanNodes[i]);
|
||||||
fanRoot.appendChild(subFanRoot);
|
fanRoot.appendChild(subFanRoot);
|
||||||
}
|
}
|
||||||
gpuRoot.appendChild(fanRoot);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Add as direct children to GPU
|
// Add as direct children to GPU
|
||||||
for (auto &node : nvmlFanNodes)
|
for (auto &node : nvmlFanNodes)
|
||||||
gpuRoot.appendChild(node);
|
fanRoot.appendChild(node);
|
||||||
|
|
||||||
for (auto &node : nvctrlFanNodes)
|
for (auto &node : nvctrlFanNodes)
|
||||||
gpuRoot.appendChild(node);
|
fanRoot.appendChild(node);
|
||||||
}
|
}
|
||||||
|
if (!fanRoot.children().empty())
|
||||||
|
gpuRoot.appendChild(fanRoot);
|
||||||
|
|
||||||
return gpuRoot;
|
return gpuRoot;
|
||||||
}, optDataVec);
|
}, optDataVec);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user