From 6e929e6f6a939fc0daf587db14458eab6c2eedb4 Mon Sep 17 00:00:00 2001 From: MK73DS <10391562+MK73DS@users.noreply.github.com> Date: Mon, 28 Mar 2022 16:52:53 +0200 Subject: [PATCH] Stub ICommonStateGetter::SetCpuBoostMode This makes Metroid Dread boot --- .../am/controller/ICommonStateGetter.cpp | 15 ++++++++++++ .../am/controller/ICommonStateGetter.h | 23 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.cpp b/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.cpp index 6f51e19c..0f5fb82f 100644 --- a/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.cpp +++ b/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.cpp @@ -71,4 +71,19 @@ namespace skyline::service::am { } return {}; } + + Result ICommonStateGetter::SetCpuBoostMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + cpuBoostMode = request.Pop(); + switch (cpuBoostMode) { + case CpuBoostMode::Normal: + case CpuBoostMode::FastLoad: + case CpuBoostMode::PowerSaving: + Logger::Info("Set CPU boost mode to {}", ToString(cpuBoostMode)); + return {}; + default: + Logger::Error("Unknown CPU boost mode value: 0x{:X}", cpuBoostMode); + return result::InvalidParameters; + } + return {}; + } } diff --git a/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.h b/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.h index 2d8fc1e3..6220610d 100644 --- a/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.h +++ b/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.h @@ -5,10 +5,12 @@ #include #include +#include namespace skyline::service::am { namespace result { constexpr Result NoMessages(128, 3); + constexpr Result InvalidParameters(128, 506); } /** @@ -44,6 +46,18 @@ namespace skyline::service::am { Docked = 1, //!< The device is in docked mode } operationMode; + enum class CpuBoostMode : u32 { + Normal = 0, //!< The device runs at stock CPU and CPU clocks + FastLoad = 1, //!< The device runs at boosted CPU clocks and minimum GPU clocks + PowerSaving = 2 //!< The device runs at stock CPU clocks and minimum GPU clocks + } cpuBoostMode; + + ENUM_STRING(CpuBoostMode, { + ENUM_CASE_PAIR(Normal, "Normal"); + ENUM_CASE_PAIR(FastLoad, "Fast Load"); + ENUM_CASE_PAIR(PowerSaving, "Power Saving"); + }) + /** * @brief Queues a message for the application to read via ReceiveMessage * @param message The message to queue @@ -95,6 +109,12 @@ namespace skyline::service::am { */ Result GetDefaultDisplayResolution(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + /** + * @brief Sets the CPU boost mode to the supplied value + * @url https://switchbrew.org/wiki/Applet_Manager_services#SetCpuBoostMode + */ + Result SetCpuBoostMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + SERVICE_DECL( SFUNC(0x0, ICommonStateGetter, GetEventHandle), SFUNC(0x1, ICommonStateGetter, ReceiveMessage), @@ -102,7 +122,8 @@ namespace skyline::service::am { SFUNC(0x6, ICommonStateGetter, GetPerformanceMode), SFUNC(0x9, ICommonStateGetter, GetCurrentFocusState), SFUNC(0x32, ICommonStateGetter, IsVrModeEnabled), - SFUNC(0x3C, ICommonStateGetter, GetDefaultDisplayResolution) + SFUNC(0x3C, ICommonStateGetter, GetDefaultDisplayResolution), + SFUNC(0x42, ICommonStateGetter, SetCpuBoostMode) ) }; }