| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2023 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "gpuinfoodfanctrl.h" |
| 5 | |
| 6 | #include "common/fileutils.h" |
| 7 | #include "core/info/infoproviderregistry.h" |
| 8 | #include <exception> |
| 9 | #include <filesystem> |
| 10 | #include <memory> |
| 11 | #include <spdlog/spdlog.h> |
| 12 | |
| 13 | AMD::GPUInfoOdFanCtrl::GPUInfoOdFanCtrl() noexcept |
| 14 | { |
| 15 | } |
| 16 | |
| 17 | std::vector<std::pair<std::string, std::string>> |
| 18 | AMD::GPUInfoOdFanCtrl::provideInfo(Vendor, int, IGPUInfo::Path const &, |
| 19 | IHWIDTranslator const &) const |
| 20 | { |
| 21 | return {}; |
| 22 | } |
| 23 | |
| 24 | std::vector<std::string> |
| 25 | AMD::GPUInfoOdFanCtrl::provideCapabilities(Vendor vendor, int, |
| 26 | IGPUInfo::Path const &path) const |
| 27 | { |
| 28 | std::vector<std::string> cap; |
| 29 | |
| 30 | if (vendor == Vendor::AMD) { |
| 31 | auto fanCtlPath = path.sys / "gpu_od" / "fan_ctrl"; |
| 32 | try { |
| 33 | if (Utils::File::isDirectoryPathValid(fanCtlPath) && |
| 34 | !std::filesystem::is_empty(fanCtlPath)) { |
| 35 | cap.emplace_back(GPUInfoOdFanCtrl::ID); |
| 36 | } |
| 37 | } |
| 38 | catch (std::exception const &e) { |
| 39 | SPDLOG_DEBUG(e.what()); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | return cap; |
| 44 | } |
| 45 | |
| 46 | bool AMD::GPUInfoOdFanCtrl::registered_ = |
| 47 | InfoProviderRegistry::add(std::make_unique<AMD::GPUInfoOdFanCtrl>()); |