diff options
| author | 2019-06-28 22:43:51 -0400 | |
|---|---|---|
| committer | 2019-06-28 22:43:51 -0400 | |
| commit | 65eb9cbb289c7465cb19a772986ccaf87bf02f3e (patch) | |
| tree | 7e4164597957e375d82981119b9ed36fc3af4f71 | |
| parent | Merge pull request #2548 from DarkLordZach/applet-shopn (diff) | |
| download | yuzu-65eb9cbb289c7465cb19a772986ccaf87bf02f3e.tar.gz yuzu-65eb9cbb289c7465cb19a772986ccaf87bf02f3e.tar.xz yuzu-65eb9cbb289c7465cb19a772986ccaf87bf02f3e.zip | |
apm: Add Controller class to manage speed data and application
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/apm/controller.cpp | 68 | ||||
| -rw-r--r-- | src/core/hle/service/apm/controller.h | 70 |
3 files changed, 140 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d65659b44..0a922430f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -207,6 +207,8 @@ add_library(core STATIC | |||
| 207 | hle/service/aoc/aoc_u.h | 207 | hle/service/aoc/aoc_u.h |
| 208 | hle/service/apm/apm.cpp | 208 | hle/service/apm/apm.cpp |
| 209 | hle/service/apm/apm.h | 209 | hle/service/apm/apm.h |
| 210 | hle/service/apm/controller.cpp | ||
| 211 | hle/service/apm/controller.h | ||
| 210 | hle/service/apm/interface.cpp | 212 | hle/service/apm/interface.cpp |
| 211 | hle/service/apm/interface.h | 213 | hle/service/apm/interface.h |
| 212 | hle/service/audio/audctl.cpp | 214 | hle/service/audio/audctl.cpp |
diff --git a/src/core/hle/service/apm/controller.cpp b/src/core/hle/service/apm/controller.cpp new file mode 100644 index 000000000..4376612eb --- /dev/null +++ b/src/core/hle/service/apm/controller.cpp | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | // Copyright 2019 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/logging/log.h" | ||
| 6 | #include "core/core_timing.h" | ||
| 7 | #include "core/hle/service/apm/controller.h" | ||
| 8 | #include "core/settings.h" | ||
| 9 | |||
| 10 | namespace Service::APM { | ||
| 11 | |||
| 12 | constexpr PerformanceConfiguration DEFAULT_PERFORMANCE_CONFIGURATION = | ||
| 13 | PerformanceConfiguration::Config7; | ||
| 14 | |||
| 15 | Controller::Controller(Core::Timing::CoreTiming& core_timing) | ||
| 16 | : core_timing(core_timing), configs{ | ||
| 17 | {PerformanceMode::Handheld, DEFAULT_PERFORMANCE_CONFIGURATION}, | ||
| 18 | {PerformanceMode::Docked, DEFAULT_PERFORMANCE_CONFIGURATION}, | ||
| 19 | } {} | ||
| 20 | |||
| 21 | Controller::~Controller() = default; | ||
| 22 | |||
| 23 | void Controller::SetPerformanceConfiguration(PerformanceMode mode, | ||
| 24 | PerformanceConfiguration config) { | ||
| 25 | static const std::map<PerformanceConfiguration, u32> PCONFIG_TO_SPEED_MAP{ | ||
| 26 | {PerformanceConfiguration::Config1, 1020}, {PerformanceConfiguration::Config2, 1020}, | ||
| 27 | {PerformanceConfiguration::Config3, 1224}, {PerformanceConfiguration::Config4, 1020}, | ||
| 28 | {PerformanceConfiguration::Config5, 1020}, {PerformanceConfiguration::Config6, 1224}, | ||
| 29 | {PerformanceConfiguration::Config7, 1020}, {PerformanceConfiguration::Config8, 1020}, | ||
| 30 | {PerformanceConfiguration::Config9, 1020}, {PerformanceConfiguration::Config10, 1020}, | ||
| 31 | {PerformanceConfiguration::Config11, 1020}, {PerformanceConfiguration::Config12, 1020}, | ||
| 32 | {PerformanceConfiguration::Config13, 1785}, {PerformanceConfiguration::Config14, 1785}, | ||
| 33 | {PerformanceConfiguration::Config15, 1020}, {PerformanceConfiguration::Config16, 1020}, | ||
| 34 | }; | ||
| 35 | |||
| 36 | SetClockSpeed(PCONFIG_TO_SPEED_MAP.find(config)->second); | ||
| 37 | configs.insert_or_assign(mode, config); | ||
| 38 | } | ||
| 39 | |||
| 40 | void Controller::SetFromCpuBoostMode(CpuBoostMode mode) { | ||
| 41 | constexpr std::array<PerformanceConfiguration, 3> BOOST_MODE_TO_CONFIG_MAP{{ | ||
| 42 | PerformanceConfiguration::Config7, | ||
| 43 | PerformanceConfiguration::Config13, | ||
| 44 | PerformanceConfiguration::Config15, | ||
| 45 | }}; | ||
| 46 | |||
| 47 | SetPerformanceConfiguration(PerformanceMode::Docked, | ||
| 48 | BOOST_MODE_TO_CONFIG_MAP.at(static_cast<u32>(mode))); | ||
| 49 | } | ||
| 50 | |||
| 51 | PerformanceMode Controller::GetCurrentPerformanceMode() { | ||
| 52 | return Settings::values.use_docked_mode ? PerformanceMode::Docked : PerformanceMode::Handheld; | ||
| 53 | } | ||
| 54 | |||
| 55 | PerformanceConfiguration Controller::GetCurrentPerformanceConfiguration(PerformanceMode mode) { | ||
| 56 | if (configs.find(mode) == configs.end()) { | ||
| 57 | configs.insert_or_assign(mode, DEFAULT_PERFORMANCE_CONFIGURATION); | ||
| 58 | } | ||
| 59 | |||
| 60 | return configs[mode]; | ||
| 61 | } | ||
| 62 | |||
| 63 | void Controller::SetClockSpeed(u32 mhz) { | ||
| 64 | LOG_INFO(Service_APM, "called, mhz={:08X}", mhz); | ||
| 65 | // TODO(DarkLordZach): Actually signal core_timing to change clock speed. | ||
| 66 | } | ||
| 67 | |||
| 68 | } // namespace Service::APM | ||
diff --git a/src/core/hle/service/apm/controller.h b/src/core/hle/service/apm/controller.h new file mode 100644 index 000000000..8ac80eaea --- /dev/null +++ b/src/core/hle/service/apm/controller.h | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | // Copyright 2019 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <map> | ||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | namespace Core::Timing { | ||
| 11 | class CoreTiming; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::APM { | ||
| 15 | |||
| 16 | enum class PerformanceConfiguration : u32 { | ||
| 17 | Config1 = 0x00010000, | ||
| 18 | Config2 = 0x00010001, | ||
| 19 | Config3 = 0x00010002, | ||
| 20 | Config4 = 0x00020000, | ||
| 21 | Config5 = 0x00020001, | ||
| 22 | Config6 = 0x00020002, | ||
| 23 | Config7 = 0x00020003, | ||
| 24 | Config8 = 0x00020004, | ||
| 25 | Config9 = 0x00020005, | ||
| 26 | Config10 = 0x00020006, | ||
| 27 | Config11 = 0x92220007, | ||
| 28 | Config12 = 0x92220008, | ||
| 29 | Config13 = 0x92220009, | ||
| 30 | Config14 = 0x9222000A, | ||
| 31 | Config15 = 0x9222000B, | ||
| 32 | Config16 = 0x9222000C, | ||
| 33 | }; | ||
| 34 | |||
| 35 | enum class CpuBoostMode : u32 { | ||
| 36 | Disabled = 0, | ||
| 37 | Full = 1, // CPU + GPU -> Config 13, 14, 15, or 16 | ||
| 38 | Partial = 2, // GPU Only -> Config 15 or 16 | ||
| 39 | }; | ||
| 40 | |||
| 41 | enum class PerformanceMode : u8 { | ||
| 42 | Handheld = 0, | ||
| 43 | Docked = 1, | ||
| 44 | }; | ||
| 45 | |||
| 46 | // Class to manage the state and change of the emulated system performance. | ||
| 47 | // Specifically, this deals with PerformanceMode, which corresponds to the system being docked or | ||
| 48 | // undocked, and PerformanceConfig which specifies the exact CPU, GPU, and Memory clocks to operate | ||
| 49 | // at. Additionally, this manages 'Boost Mode', which allows games to temporarily overclock the | ||
| 50 | // system during times of high load -- this simply maps to different PerformanceConfigs to use. | ||
| 51 | class Controller { | ||
| 52 | public: | ||
| 53 | Controller(Core::Timing::CoreTiming& core_timing); | ||
| 54 | ~Controller(); | ||
| 55 | |||
| 56 | void SetPerformanceConfiguration(PerformanceMode mode, PerformanceConfiguration config); | ||
| 57 | void SetFromCpuBoostMode(CpuBoostMode mode); | ||
| 58 | |||
| 59 | PerformanceMode GetCurrentPerformanceMode(); | ||
| 60 | PerformanceConfiguration GetCurrentPerformanceConfiguration(PerformanceMode mode); | ||
| 61 | |||
| 62 | private: | ||
| 63 | void SetClockSpeed(u32 mhz); | ||
| 64 | |||
| 65 | std::map<PerformanceMode, PerformanceConfiguration> configs; | ||
| 66 | |||
| 67 | Core::Timing::CoreTiming& core_timing; | ||
| 68 | }; | ||
| 69 | |||
| 70 | } // namespace Service::APM | ||