diff options
| -rw-r--r-- | src/core/hle/service/apm/controller.cpp | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/src/core/hle/service/apm/controller.cpp b/src/core/hle/service/apm/controller.cpp index d9e8d247d..25a886238 100644 --- a/src/core/hle/service/apm/controller.cpp +++ b/src/core/hle/service/apm/controller.cpp | |||
| @@ -2,6 +2,10 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 6 | #include <array> | ||
| 7 | #include <utility> | ||
| 8 | |||
| 5 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 6 | #include "core/core_timing.h" | 10 | #include "core/core_timing.h" |
| 7 | #include "core/hle/service/apm/controller.h" | 11 | #include "core/hle/service/apm/controller.h" |
| @@ -9,8 +13,7 @@ | |||
| 9 | 13 | ||
| 10 | namespace Service::APM { | 14 | namespace Service::APM { |
| 11 | 15 | ||
| 12 | constexpr PerformanceConfiguration DEFAULT_PERFORMANCE_CONFIGURATION = | 16 | constexpr auto DEFAULT_PERFORMANCE_CONFIGURATION = PerformanceConfiguration::Config7; |
| 13 | PerformanceConfiguration::Config7; | ||
| 14 | 17 | ||
| 15 | Controller::Controller(Core::Timing::CoreTiming& core_timing) | 18 | Controller::Controller(Core::Timing::CoreTiming& core_timing) |
| 16 | : core_timing{core_timing}, configs{ | 19 | : core_timing{core_timing}, configs{ |
| @@ -22,18 +25,35 @@ Controller::~Controller() = default; | |||
| 22 | 25 | ||
| 23 | void Controller::SetPerformanceConfiguration(PerformanceMode mode, | 26 | void Controller::SetPerformanceConfiguration(PerformanceMode mode, |
| 24 | PerformanceConfiguration config) { | 27 | PerformanceConfiguration config) { |
| 25 | static const std::map<PerformanceConfiguration, u32> PCONFIG_TO_SPEED_MAP{ | 28 | static constexpr std::array<std::pair<PerformanceConfiguration, u32>, 16> config_to_speed{{ |
| 26 | {PerformanceConfiguration::Config1, 1020}, {PerformanceConfiguration::Config2, 1020}, | 29 | {PerformanceConfiguration::Config1, 1020}, |
| 27 | {PerformanceConfiguration::Config3, 1224}, {PerformanceConfiguration::Config4, 1020}, | 30 | {PerformanceConfiguration::Config2, 1020}, |
| 28 | {PerformanceConfiguration::Config5, 1020}, {PerformanceConfiguration::Config6, 1224}, | 31 | {PerformanceConfiguration::Config3, 1224}, |
| 29 | {PerformanceConfiguration::Config7, 1020}, {PerformanceConfiguration::Config8, 1020}, | 32 | {PerformanceConfiguration::Config4, 1020}, |
| 30 | {PerformanceConfiguration::Config9, 1020}, {PerformanceConfiguration::Config10, 1020}, | 33 | {PerformanceConfiguration::Config5, 1020}, |
| 31 | {PerformanceConfiguration::Config11, 1020}, {PerformanceConfiguration::Config12, 1020}, | 34 | {PerformanceConfiguration::Config6, 1224}, |
| 32 | {PerformanceConfiguration::Config13, 1785}, {PerformanceConfiguration::Config14, 1785}, | 35 | {PerformanceConfiguration::Config7, 1020}, |
| 33 | {PerformanceConfiguration::Config15, 1020}, {PerformanceConfiguration::Config16, 1020}, | 36 | {PerformanceConfiguration::Config8, 1020}, |
| 34 | }; | 37 | {PerformanceConfiguration::Config9, 1020}, |
| 35 | 38 | {PerformanceConfiguration::Config10, 1020}, | |
| 36 | SetClockSpeed(PCONFIG_TO_SPEED_MAP.find(config)->second); | 39 | {PerformanceConfiguration::Config11, 1020}, |
| 40 | {PerformanceConfiguration::Config12, 1020}, | ||
| 41 | {PerformanceConfiguration::Config13, 1785}, | ||
| 42 | {PerformanceConfiguration::Config14, 1785}, | ||
| 43 | {PerformanceConfiguration::Config15, 1020}, | ||
| 44 | {PerformanceConfiguration::Config16, 1020}, | ||
| 45 | }}; | ||
| 46 | |||
| 47 | const auto iter = std::find_if(config_to_speed.cbegin(), config_to_speed.cend(), | ||
| 48 | [config](const auto& entry) { return entry.first == config; }); | ||
| 49 | |||
| 50 | if (iter == config_to_speed.cend()) { | ||
| 51 | LOG_ERROR(Service_APM, "Invalid performance configuration value provided: {}", | ||
| 52 | static_cast<u32>(config)); | ||
| 53 | return; | ||
| 54 | } | ||
| 55 | |||
| 56 | SetClockSpeed(iter->second); | ||
| 37 | configs.insert_or_assign(mode, config); | 57 | configs.insert_or_assign(mode, config); |
| 38 | } | 58 | } |
| 39 | 59 | ||