| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "core/idatasource.h" |
| 7 | #include "ippdpmhandler.h" |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | #include <units.h> |
| 11 | #include <utility> |
| 12 | #include <vector> |
| 13 | |
| 14 | namespace AMD { |
| 15 | |
| 16 | class PpDpmHandler : public IPpDpmHandler |
| 17 | { |
| 18 | public: |
| 19 | PpDpmHandler(std::unique_ptr<IDataSource<std::string>> &&perfLevelDataSource, |
| 20 | std::unique_ptr<IDataSource<std::vector<std::string>>> |
| 21 | &&ppDpmDataSource) noexcept; |
| 22 | |
| 23 | std::vector<std::pair<unsigned int, units::frequency::megahertz_t>> const & |
| 24 | states() const override; |
| 25 | |
| 26 | std::vector<unsigned int> const &active() const override; |
| 27 | void activate(std::vector<unsigned int> const &states) override; |
| 28 | |
| 29 | void saveState() override; |
| 30 | void restoreState(ICommandQueue &ctlCmds) override; |
| 31 | |
| 32 | void reset(ICommandQueue &ctlCmds) override; |
| 33 | void sync(ICommandQueue &ctlCmds) override; |
| 34 | |
| 35 | private: |
| 36 | void apply(ICommandQueue &ctlCmds); |
| 37 | |
| 38 | std::unique_ptr<IDataSource<std::string>> const perfLevelDataSource_; |
| 39 | std::unique_ptr<IDataSource<std::vector<std::string>>> const ppDpmDataSource_; |
| 40 | |
| 41 | std::string perfLevelValue_; |
| 42 | std::vector<std::string> ppDpmLines_; |
| 43 | |
| 44 | std::vector<std::pair<unsigned int, units::frequency::megahertz_t>> states_; |
| 45 | std::vector<unsigned int> active_; |
| 46 | |
| 47 | bool resync_; |
| 48 | }; |
| 49 | |
| 50 | } // namespace AMD |