| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "pmfixedlegacy.h" |
| 5 | |
| 6 | #include "core/icommandqueue.h" |
| 7 | #include <utility> |
| 8 | |
| 9 | AMD::PMFixedLegacy::PMFixedLegacy( |
| 10 | std::unique_ptr<IDataSource<std::string>> &&powerMethodDataSource, |
| 11 | std::unique_ptr<IDataSource<std::string>> &&powerProfileDataSource) noexcept |
| 12 | : AMD::PMFixed(AMD::PMFixedLegacy::Profile::low) |
| 13 | , powerMethodDataSource_(std::move(powerMethodDataSource)) |
| 14 | , powerProfileDataSource_(std::move(powerProfileDataSource)) |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | void AMD::PMFixedLegacy::cleanControl(ICommandQueue &ctlCmds) |
| 19 | { |
| 20 | ctlCmds.add({powerMethodDataSource_->source(), |
| 21 | std::string(AMD::PMFixedLegacy::Method)}); |
| 22 | ctlCmds.add({powerProfileDataSource_->source(), |
| 23 | std::string(AMD::PMFixedLegacy::Profile::clean)}); |
| 24 | } |
| 25 | |
| 26 | void AMD::PMFixedLegacy::syncControl(ICommandQueue &ctlCmds) |
| 27 | { |
| 28 | if (powerMethodDataSource_->read(powerMethodEntry_) && |
| 29 | powerProfileDataSource_->read(powerProfileEntry_)) { |
| 30 | |
| 31 | if (powerMethodEntry_ != AMD::PMFixedLegacy::Method) { |
| 32 | ctlCmds.add({powerMethodDataSource_->source(), |
| 33 | std::string(AMD::PMFixedLegacy::Method)}); |
| 34 | ctlCmds.add({powerProfileDataSource_->source(), mode()}); |
| 35 | } |
| 36 | else if (powerProfileEntry_ != mode()) { |
| 37 | ctlCmds.add({powerProfileDataSource_->source(), mode()}); |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | std::vector<std::string> const &AMD::PMFixedLegacy::modes() const |
| 43 | { |
| 44 | return modes_; |
| 45 | } |
| 46 | |
| 47 | std::vector<std::string> const AMD::PMFixedLegacy::modes_{ |
| 48 | std::string(AMD::PMFixedLegacy::Profile::low), |
| 49 | std::string(AMD::PMFixedLegacy::Profile::mid), |
| 50 | std::string(AMD::PMFixedLegacy::Profile::high)}; |