|
6 | 6 | #include "../CommonUtilities/ref/GeneratedReflection.h" |
7 | 7 | #include "../CommonUtilities/ref/StaticReflection.h" |
8 | 8 | #include <regex> |
| 9 | +#include <ranges> |
9 | 10 |
|
10 | 11 | using namespace pmon; |
11 | 12 | using namespace util; |
| 13 | +namespace vi = std::views; |
12 | 14 |
|
13 | 15 | namespace pwr::intel |
14 | 16 | { |
@@ -60,6 +62,38 @@ namespace pwr::intel |
60 | 62 | else { |
61 | 63 | pmlog_error("ctlEnumPowerDomains failed to get count").code(result).pmwatch(GetName()); |
62 | 64 | } |
| 65 | + |
| 66 | + // enumerate fans |
| 67 | + uint32_t fanCount = 0; |
| 68 | + if (auto res = ctlEnumFans(deviceHandle, &fanCount, nullptr); res == CTL_RESULT_SUCCESS) { |
| 69 | + if (fanCount > 0) { |
| 70 | + std::vector<ctl_fan_handle_t> fanHandles(fanCount); |
| 71 | + if (auto res = ctlEnumFans(deviceHandle, &fanCount, fanHandles.data()); res == CTL_RESULT_SUCCESS) { |
| 72 | + for (auto&&[iFan, hFan] : vi::enumerate(fanHandles)) { |
| 73 | + if (hFan) { |
| 74 | + ctl_fan_properties_t props{ .Size = sizeof(ctl_fan_properties_t) }; |
| 75 | + if (auto res = ctlFanGetProperties(hFan, &props); res != CTL_RESULT_SUCCESS) { |
| 76 | + pmlog_error(std::format("failed to get properties for fan #{}", iFan)).code(res); |
| 77 | + maxFanSpeedsRpm_.push_back(0); |
| 78 | + } |
| 79 | + pmlog_verb(v::gpu)("Got fan properties").pmwatch(GetName()).pmwatch(iFan) |
| 80 | + .pmwatch(ref::DumpGenerated(props)); |
| 81 | + maxFanSpeedsRpm_.push_back(props.maxRPM); |
| 82 | + } |
| 83 | + else { |
| 84 | + pmlog_warn("null handle received from ctlEnumFans"); |
| 85 | + maxFanSpeedsRpm_.push_back(0); |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | + else { |
| 90 | + pmlog_error("failed getting fan handles").code(res); |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | + else { |
| 95 | + pmlog_error("failed getting fan count").code(res); |
| 96 | + } |
63 | 97 | } |
64 | 98 |
|
65 | 99 | bool IntelPowerTelemetryAdapter::Sample() noexcept |
|
0 commit comments