summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/apm
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/apm/apm.cpp2
-rw-r--r--src/core/hle/service/apm/apm_controller.cpp89
-rw-r--r--src/core/hle/service/apm/apm_controller.h (renamed from src/core/hle/service/apm/controller.h)0
-rw-r--r--src/core/hle/service/apm/apm_interface.cpp138
-rw-r--r--src/core/hle/service/apm/apm_interface.h (renamed from src/core/hle/service/apm/interface.h)0
-rw-r--r--src/core/hle/service/apm/controller.cpp89
-rw-r--r--src/core/hle/service/apm/interface.cpp138
7 files changed, 228 insertions, 228 deletions
diff --git a/src/core/hle/service/apm/apm.cpp b/src/core/hle/service/apm/apm.cpp
index 97d6619dd..f5ebfe8d6 100644
--- a/src/core/hle/service/apm/apm.cpp
+++ b/src/core/hle/service/apm/apm.cpp
@@ -5,7 +5,7 @@
#include "core/core.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/apm/apm.h"
-#include "core/hle/service/apm/interface.h"
+#include "core/hle/service/apm/apm_interface.h"
namespace Service::APM {
diff --git a/src/core/hle/service/apm/apm_controller.cpp b/src/core/hle/service/apm/apm_controller.cpp
new file mode 100644
index 000000000..98839fe97
--- /dev/null
+++ b/src/core/hle/service/apm/apm_controller.cpp
@@ -0,0 +1,89 @@
+// Copyright 2019 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include <algorithm>
+#include <array>
+#include <utility>
+
+#include "common/logging/log.h"
+#include "common/settings.h"
+#include "core/core_timing.h"
+#include "core/hle/service/apm/apm_controller.h"
+
+namespace Service::APM {
+
+constexpr auto DEFAULT_PERFORMANCE_CONFIGURATION = PerformanceConfiguration::Config7;
+
+Controller::Controller(Core::Timing::CoreTiming& core_timing_)
+ : core_timing{core_timing_}, configs{
+ {PerformanceMode::Handheld, DEFAULT_PERFORMANCE_CONFIGURATION},
+ {PerformanceMode::Docked, DEFAULT_PERFORMANCE_CONFIGURATION},
+ } {}
+
+Controller::~Controller() = default;
+
+void Controller::SetPerformanceConfiguration(PerformanceMode mode,
+ PerformanceConfiguration config) {
+ static constexpr std::array<std::pair<PerformanceConfiguration, u32>, 16> config_to_speed{{
+ {PerformanceConfiguration::Config1, 1020},
+ {PerformanceConfiguration::Config2, 1020},
+ {PerformanceConfiguration::Config3, 1224},
+ {PerformanceConfiguration::Config4, 1020},
+ {PerformanceConfiguration::Config5, 1020},
+ {PerformanceConfiguration::Config6, 1224},
+ {PerformanceConfiguration::Config7, 1020},
+ {PerformanceConfiguration::Config8, 1020},
+ {PerformanceConfiguration::Config9, 1020},
+ {PerformanceConfiguration::Config10, 1020},
+ {PerformanceConfiguration::Config11, 1020},
+ {PerformanceConfiguration::Config12, 1020},
+ {PerformanceConfiguration::Config13, 1785},
+ {PerformanceConfiguration::Config14, 1785},
+ {PerformanceConfiguration::Config15, 1020},
+ {PerformanceConfiguration::Config16, 1020},
+ }};
+
+ const auto iter = std::find_if(config_to_speed.cbegin(), config_to_speed.cend(),
+ [config](const auto& entry) { return entry.first == config; });
+
+ if (iter == config_to_speed.cend()) {
+ LOG_ERROR(Service_APM, "Invalid performance configuration value provided: {}", config);
+ return;
+ }
+
+ SetClockSpeed(iter->second);
+ configs.insert_or_assign(mode, config);
+}
+
+void Controller::SetFromCpuBoostMode(CpuBoostMode mode) {
+ constexpr std::array<PerformanceConfiguration, 3> BOOST_MODE_TO_CONFIG_MAP{{
+ PerformanceConfiguration::Config7,
+ PerformanceConfiguration::Config13,
+ PerformanceConfiguration::Config15,
+ }};
+
+ SetPerformanceConfiguration(PerformanceMode::Docked,
+ BOOST_MODE_TO_CONFIG_MAP.at(static_cast<u32>(mode)));
+}
+
+PerformanceMode Controller::GetCurrentPerformanceMode() const {
+ return Settings::values.use_docked_mode.GetValue() ? PerformanceMode::Docked
+ : PerformanceMode::Handheld;
+}
+
+PerformanceConfiguration Controller::GetCurrentPerformanceConfiguration(PerformanceMode mode) {
+ if (configs.find(mode) == configs.end()) {
+ configs.insert_or_assign(mode, DEFAULT_PERFORMANCE_CONFIGURATION);
+ }
+
+ return configs[mode];
+}
+
+void Controller::SetClockSpeed(u32 mhz) {
+ LOG_INFO(Service_APM, "called, mhz={:08X}", mhz);
+ // TODO(DarkLordZach): Actually signal core_timing to change clock speed.
+ // TODO(Rodrigo): Remove [[maybe_unused]] when core_timing is used.
+}
+
+} // namespace Service::APM
diff --git a/src/core/hle/service/apm/controller.h b/src/core/hle/service/apm/apm_controller.h
index 8d48e0104..8d48e0104 100644
--- a/src/core/hle/service/apm/controller.h
+++ b/src/core/hle/service/apm/apm_controller.h
diff --git a/src/core/hle/service/apm/apm_interface.cpp b/src/core/hle/service/apm/apm_interface.cpp
new file mode 100644
index 000000000..e58bad083
--- /dev/null
+++ b/src/core/hle/service/apm/apm_interface.cpp
@@ -0,0 +1,138 @@
+// Copyright 2018 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "common/logging/log.h"
+#include "core/hle/ipc_helpers.h"
+#include "core/hle/service/apm/apm.h"
+#include "core/hle/service/apm/apm_controller.h"
+#include "core/hle/service/apm/apm_interface.h"
+
+namespace Service::APM {
+
+class ISession final : public ServiceFramework<ISession> {
+public:
+ explicit ISession(Core::System& system_, Controller& controller_)
+ : ServiceFramework{system_, "ISession"}, controller{controller_} {
+ static const FunctionInfo functions[] = {
+ {0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"},
+ {1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"},
+ {2, nullptr, "SetCpuOverclockEnabled"},
+ };
+ RegisterHandlers(functions);
+ }
+
+private:
+ void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+
+ const auto mode = rp.PopEnum<PerformanceMode>();
+ const auto config = rp.PopEnum<PerformanceConfiguration>();
+ LOG_DEBUG(Service_APM, "called mode={} config={}", mode, config);
+
+ controller.SetPerformanceConfiguration(mode, config);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
+ }
+
+ void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+
+ const auto mode = rp.PopEnum<PerformanceMode>();
+ LOG_DEBUG(Service_APM, "called mode={}", mode);
+
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(ResultSuccess);
+ rb.PushEnum(controller.GetCurrentPerformanceConfiguration(mode));
+ }
+
+ Controller& controller;
+};
+
+APM::APM(Core::System& system_, std::shared_ptr<Module> apm_, Controller& controller_,
+ const char* name)
+ : ServiceFramework{system_, name}, apm(std::move(apm_)), controller{controller_} {
+ static const FunctionInfo functions[] = {
+ {0, &APM::OpenSession, "OpenSession"},
+ {1, &APM::GetPerformanceMode, "GetPerformanceMode"},
+ {6, &APM::IsCpuOverclockEnabled, "IsCpuOverclockEnabled"},
+ };
+ RegisterHandlers(functions);
+}
+
+APM::~APM() = default;
+
+void APM::OpenSession(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Service_APM, "called");
+
+ IPC::ResponseBuilder rb{ctx, 2, 0, 1};
+ rb.Push(ResultSuccess);
+ rb.PushIpcInterface<ISession>(system, controller);
+}
+
+void APM::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Service_APM, "called");
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.PushEnum(controller.GetCurrentPerformanceMode());
+}
+
+void APM::IsCpuOverclockEnabled(Kernel::HLERequestContext& ctx) {
+ LOG_WARNING(Service_APM, "(STUBBED) called");
+
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(ResultSuccess);
+ rb.Push(false);
+}
+
+APM_Sys::APM_Sys(Core::System& system_, Controller& controller_)
+ : ServiceFramework{system_, "apm:sys"}, controller{controller_} {
+ // clang-format off
+ static const FunctionInfo functions[] = {
+ {0, nullptr, "RequestPerformanceMode"},
+ {1, &APM_Sys::GetPerformanceEvent, "GetPerformanceEvent"},
+ {2, nullptr, "GetThrottlingState"},
+ {3, nullptr, "GetLastThrottlingState"},
+ {4, nullptr, "ClearLastThrottlingState"},
+ {5, nullptr, "LoadAndApplySettings"},
+ {6, &APM_Sys::SetCpuBoostMode, "SetCpuBoostMode"},
+ {7, &APM_Sys::GetCurrentPerformanceConfiguration, "GetCurrentPerformanceConfiguration"},
+ };
+ // clang-format on
+
+ RegisterHandlers(functions);
+}
+
+APM_Sys::~APM_Sys() = default;
+
+void APM_Sys::GetPerformanceEvent(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Service_APM, "called");
+
+ IPC::ResponseBuilder rb{ctx, 2, 0, 1};
+ rb.Push(ResultSuccess);
+ rb.PushIpcInterface<ISession>(system, controller);
+}
+
+void APM_Sys::SetCpuBoostMode(Kernel::HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ const auto mode = rp.PopEnum<CpuBoostMode>();
+
+ LOG_DEBUG(Service_APM, "called, mode={:08X}", mode);
+
+ controller.SetFromCpuBoostMode(mode);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ResultSuccess);
+}
+
+void APM_Sys::GetCurrentPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Service_APM, "called");
+
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(ResultSuccess);
+ rb.PushEnum(
+ controller.GetCurrentPerformanceConfiguration(controller.GetCurrentPerformanceMode()));
+}
+
+} // namespace Service::APM
diff --git a/src/core/hle/service/apm/interface.h b/src/core/hle/service/apm/apm_interface.h
index 063ad5308..063ad5308 100644
--- a/src/core/hle/service/apm/interface.h
+++ b/src/core/hle/service/apm/apm_interface.h
diff --git a/src/core/hle/service/apm/controller.cpp b/src/core/hle/service/apm/controller.cpp
deleted file mode 100644
index 8bfa7c0e4..000000000
--- a/src/core/hle/service/apm/controller.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2019 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include <algorithm>
-#include <array>
-#include <utility>
-
-#include "common/logging/log.h"
-#include "common/settings.h"
-#include "core/core_timing.h"
-#include "core/hle/service/apm/controller.h"
-
-namespace Service::APM {
-
-constexpr auto DEFAULT_PERFORMANCE_CONFIGURATION = PerformanceConfiguration::Config7;
-
-Controller::Controller(Core::Timing::CoreTiming& core_timing_)
- : core_timing{core_timing_}, configs{
- {PerformanceMode::Handheld, DEFAULT_PERFORMANCE_CONFIGURATION},
- {PerformanceMode::Docked, DEFAULT_PERFORMANCE_CONFIGURATION},
- } {}
-
-Controller::~Controller() = default;
-
-void Controller::SetPerformanceConfiguration(PerformanceMode mode,
- PerformanceConfiguration config) {
- static constexpr std::array<std::pair<PerformanceConfiguration, u32>, 16> config_to_speed{{
- {PerformanceConfiguration::Config1, 1020},
- {PerformanceConfiguration::Config2, 1020},
- {PerformanceConfiguration::Config3, 1224},
- {PerformanceConfiguration::Config4, 1020},
- {PerformanceConfiguration::Config5, 1020},
- {PerformanceConfiguration::Config6, 1224},
- {PerformanceConfiguration::Config7, 1020},
- {PerformanceConfiguration::Config8, 1020},
- {PerformanceConfiguration::Config9, 1020},
- {PerformanceConfiguration::Config10, 1020},
- {PerformanceConfiguration::Config11, 1020},
- {PerformanceConfiguration::Config12, 1020},
- {PerformanceConfiguration::Config13, 1785},
- {PerformanceConfiguration::Config14, 1785},
- {PerformanceConfiguration::Config15, 1020},
- {PerformanceConfiguration::Config16, 1020},
- }};
-
- const auto iter = std::find_if(config_to_speed.cbegin(), config_to_speed.cend(),
- [config](const auto& entry) { return entry.first == config; });
-
- if (iter == config_to_speed.cend()) {
- LOG_ERROR(Service_APM, "Invalid performance configuration value provided: {}", config);
- return;
- }
-
- SetClockSpeed(iter->second);
- configs.insert_or_assign(mode, config);
-}
-
-void Controller::SetFromCpuBoostMode(CpuBoostMode mode) {
- constexpr std::array<PerformanceConfiguration, 3> BOOST_MODE_TO_CONFIG_MAP{{
- PerformanceConfiguration::Config7,
- PerformanceConfiguration::Config13,
- PerformanceConfiguration::Config15,
- }};
-
- SetPerformanceConfiguration(PerformanceMode::Docked,
- BOOST_MODE_TO_CONFIG_MAP.at(static_cast<u32>(mode)));
-}
-
-PerformanceMode Controller::GetCurrentPerformanceMode() const {
- return Settings::values.use_docked_mode.GetValue() ? PerformanceMode::Docked
- : PerformanceMode::Handheld;
-}
-
-PerformanceConfiguration Controller::GetCurrentPerformanceConfiguration(PerformanceMode mode) {
- if (configs.find(mode) == configs.end()) {
- configs.insert_or_assign(mode, DEFAULT_PERFORMANCE_CONFIGURATION);
- }
-
- return configs[mode];
-}
-
-void Controller::SetClockSpeed(u32 mhz) {
- LOG_INFO(Service_APM, "called, mhz={:08X}", mhz);
- // TODO(DarkLordZach): Actually signal core_timing to change clock speed.
- // TODO(Rodrigo): Remove [[maybe_unused]] when core_timing is used.
-}
-
-} // namespace Service::APM
diff --git a/src/core/hle/service/apm/interface.cpp b/src/core/hle/service/apm/interface.cpp
deleted file mode 100644
index d69ddd135..000000000
--- a/src/core/hle/service/apm/interface.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright 2018 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include "common/logging/log.h"
-#include "core/hle/ipc_helpers.h"
-#include "core/hle/service/apm/apm.h"
-#include "core/hle/service/apm/controller.h"
-#include "core/hle/service/apm/interface.h"
-
-namespace Service::APM {
-
-class ISession final : public ServiceFramework<ISession> {
-public:
- explicit ISession(Core::System& system_, Controller& controller_)
- : ServiceFramework{system_, "ISession"}, controller{controller_} {
- static const FunctionInfo functions[] = {
- {0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"},
- {1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"},
- {2, nullptr, "SetCpuOverclockEnabled"},
- };
- RegisterHandlers(functions);
- }
-
-private:
- void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
-
- const auto mode = rp.PopEnum<PerformanceMode>();
- const auto config = rp.PopEnum<PerformanceConfiguration>();
- LOG_DEBUG(Service_APM, "called mode={} config={}", mode, config);
-
- controller.SetPerformanceConfiguration(mode, config);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
- }
-
- void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
-
- const auto mode = rp.PopEnum<PerformanceMode>();
- LOG_DEBUG(Service_APM, "called mode={}", mode);
-
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(ResultSuccess);
- rb.PushEnum(controller.GetCurrentPerformanceConfiguration(mode));
- }
-
- Controller& controller;
-};
-
-APM::APM(Core::System& system_, std::shared_ptr<Module> apm_, Controller& controller_,
- const char* name)
- : ServiceFramework{system_, name}, apm(std::move(apm_)), controller{controller_} {
- static const FunctionInfo functions[] = {
- {0, &APM::OpenSession, "OpenSession"},
- {1, &APM::GetPerformanceMode, "GetPerformanceMode"},
- {6, &APM::IsCpuOverclockEnabled, "IsCpuOverclockEnabled"},
- };
- RegisterHandlers(functions);
-}
-
-APM::~APM() = default;
-
-void APM::OpenSession(Kernel::HLERequestContext& ctx) {
- LOG_DEBUG(Service_APM, "called");
-
- IPC::ResponseBuilder rb{ctx, 2, 0, 1};
- rb.Push(ResultSuccess);
- rb.PushIpcInterface<ISession>(system, controller);
-}
-
-void APM::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
- LOG_DEBUG(Service_APM, "called");
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.PushEnum(controller.GetCurrentPerformanceMode());
-}
-
-void APM::IsCpuOverclockEnabled(Kernel::HLERequestContext& ctx) {
- LOG_WARNING(Service_APM, "(STUBBED) called");
-
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(ResultSuccess);
- rb.Push(false);
-}
-
-APM_Sys::APM_Sys(Core::System& system_, Controller& controller_)
- : ServiceFramework{system_, "apm:sys"}, controller{controller_} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, nullptr, "RequestPerformanceMode"},
- {1, &APM_Sys::GetPerformanceEvent, "GetPerformanceEvent"},
- {2, nullptr, "GetThrottlingState"},
- {3, nullptr, "GetLastThrottlingState"},
- {4, nullptr, "ClearLastThrottlingState"},
- {5, nullptr, "LoadAndApplySettings"},
- {6, &APM_Sys::SetCpuBoostMode, "SetCpuBoostMode"},
- {7, &APM_Sys::GetCurrentPerformanceConfiguration, "GetCurrentPerformanceConfiguration"},
- };
- // clang-format on
-
- RegisterHandlers(functions);
-}
-
-APM_Sys::~APM_Sys() = default;
-
-void APM_Sys::GetPerformanceEvent(Kernel::HLERequestContext& ctx) {
- LOG_DEBUG(Service_APM, "called");
-
- IPC::ResponseBuilder rb{ctx, 2, 0, 1};
- rb.Push(ResultSuccess);
- rb.PushIpcInterface<ISession>(system, controller);
-}
-
-void APM_Sys::SetCpuBoostMode(Kernel::HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto mode = rp.PopEnum<CpuBoostMode>();
-
- LOG_DEBUG(Service_APM, "called, mode={:08X}", mode);
-
- controller.SetFromCpuBoostMode(mode);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
-}
-
-void APM_Sys::GetCurrentPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
- LOG_DEBUG(Service_APM, "called");
-
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(ResultSuccess);
- rb.PushEnum(
- controller.GetCurrentPerformanceConfiguration(controller.GetCurrentPerformanceMode()));
-}
-
-} // namespace Service::APM