Debian Codegraph @

src/core/components/controls/amd/pm/auto/pmautoprovider.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "pmautoprovider.h"
5
6 #include "../pmperfmodeprovider.h"
7 #include "common/fileutils.h"
8 #include "core/info/amd/gpuinfopm.h"
9 #include "core/sysfsdatasource.h"
10 #include "pmautolegacy.h"
11 #include "pmautor600.h"
12 #include <filesystem>
13 #include <memory>
14 #include <string>
15
16 std::vector<std::unique_ptr<IControl>>
17 AMD::PMAutoProvider::provideGPUControls(IGPUInfo const &gpuInfo,
18 ISWInfo const &) const
19 {
20 std::vector<std::unique_ptr<IControl>> controls;
21
22 if (gpuInfo.vendor() != Vendor::AMD)
23 return {};
24
25 if (gpuInfo.hasCapability(GPUInfoPM::Legacy)) {
26
27 auto powerMethod = gpuInfo.path().sys / "power_method";
28 auto powerProfile = gpuInfo.path().sys / "power_profile";
29 if (!(Utils::File::isSysFSEntryValid(powerMethod) &&
30 Utils::File::isSysFSEntryValid(powerProfile)))
31 return {};
32
33 controls.emplace_back(std::make_unique<AMD::PMAutoLegacy>(
34 std::make_unique<SysFSDataSource<std::string>>(powerMethod),
35 std::make_unique<SysFSDataSource<std::string>>(powerProfile)));
36 }
37 else if (gpuInfo.hasCapability(GPUInfoPM::Radeon) ||
38 gpuInfo.hasCapability(GPUInfoPM::Amdgpu)) {
39
40 auto perfLevel = gpuInfo.path().sys / "power_dpm_force_performance_level";
41 if (!Utils::File::isSysFSEntryValid(perfLevel))
42 return {};
43
44 controls.emplace_back(std::make_unique<AMD::PMAutoR600>(
45 std::make_unique<SysFSDataSource<std::string>>(perfLevel)));
46 }
47
48 return controls;
49 }
50
51 bool const AMD::PMAutoProvider::registered_ =
52 AMD::PMPerfModeProvider::registerProvider(
53 std::make_unique<AMD::PMAutoProvider>());