attempt to make AMD fan mode work as expected

This commit is contained in:
Jussi Kuokkanen 2023-11-01 14:30:13 +02:00
parent 379f3af6b6
commit 12306ab431

View File

@ -276,13 +276,16 @@ std::vector<TreeNode<DeviceNode>> getFanMode(AMDGPUData data) {
if (!string.has_value())
return std::nullopt;
// We don't handle 0 (no fan control at all)
// We only handle automatic, see below
auto value = static_cast<uint>(std::stoi(*string));
if (value == 0)
if (value != 2)
return std::nullopt;
return value;
return 2;
};
// TODO: this may be wrong
// Seems that fan speed is writable even with automatic mode, but writing '2'
// without writing fan speed afterwards seems to reset to automatic
auto setFunc = [=](AssignmentArgument a) -> std::optional<AssignmentError> {
if (!std::holds_alternative<uint>(a))
return AssignmentError::InvalidType;
@ -291,7 +294,7 @@ std::vector<TreeNode<DeviceNode>> getFanMode(AMDGPUData data) {
if (!hasEnum(value, enumVec))
return AssignmentError::OutOfRange;
if (std::ofstream{path} << value)
if (std::ofstream{path} << "2")
return std::nullopt;
return AssignmentError::UnknownError;
};