Debian Codegraph @

src/core/components/controls/amd/pm/powerstate/pmpowerstateprovider.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "pmpowerstateprovider.h"
5
6 #include "common/fileutils.h"
7 #include "core/info/igpuinfo.h"
8 #include "core/sysfsdatasource.h"
9 #include "pmpowerstate.h"
10 #include "pmpowerstatemodeprovider.h"
11 #include <filesystem>
12 #include <memory>
13 #include <string>
14
15 std::vector<std::unique_ptr<IControl>>
16 AMD::PMPowerStateProvider::provideGPUControls(IGPUInfo const &gpuInfo,
17 ISWInfo const &) const
18 {
19 if (gpuInfo.vendor() != Vendor::AMD)
20 return {};
21
22 auto driver = gpuInfo.info(IGPUInfo::Keys::driver);
23 if (driver != "radeon")
24 return {};
25
26 auto powerDpmStatePath = gpuInfo.path().sys / "power_dpm_state";
27 if (!Utils::File::isSysFSEntryValid(powerDpmStatePath))
28 return {};
29
30 std::vector<std::unique_ptr<IControl>> controls;
31 controls.emplace_back(std::make_unique<AMD::PMPowerState>(
32 std::make_unique<SysFSDataSource<std::string>>(powerDpmStatePath)));
33
34 return controls;
35 }
36
37 bool const AMD::PMPowerStateProvider::registered_ =
38 AMD::PMPowerStateModeProvider::registerProvider(
39 std::make_unique<AMD::PMPowerStateProvider>());