summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-06-28 22:45:31 -0400
committerGravatar Zach Hilman2019-06-28 22:45:31 -0400
commit1c6e6305eab7a6e98a73d9ba5cdb880ac74d9116 (patch)
treebbabcac8371ee02f9f911f58b00daf2c24778e93 /src/core
parentapm: Add apm:am service (diff)
downloadyuzu-1c6e6305eab7a6e98a73d9ba5cdb880ac74d9116.tar.gz
yuzu-1c6e6305eab7a6e98a73d9ba5cdb880ac74d9116.tar.xz
yuzu-1c6e6305eab7a6e98a73d9ba5cdb880ac74d9116.zip
apm: Add getters for performance config and mode
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/apm/interface.cpp70
-rw-r--r--src/core/hle/service/apm/interface.h12
2 files changed, 49 insertions, 33 deletions
diff --git a/src/core/hle/service/apm/interface.cpp b/src/core/hle/service/apm/interface.cpp
index d058c0245..b2241366f 100644
--- a/src/core/hle/service/apm/interface.cpp
+++ b/src/core/hle/service/apm/interface.cpp
@@ -5,43 +5,32 @@
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6#include "core/hle/ipc_helpers.h" 6#include "core/hle/ipc_helpers.h"
7#include "core/hle/service/apm/apm.h" 7#include "core/hle/service/apm/apm.h"
8#include "core/hle/service/apm/controller.h"
8#include "core/hle/service/apm/interface.h" 9#include "core/hle/service/apm/interface.h"
9 10
10namespace Service::APM { 11namespace Service::APM {
11 12
12class ISession final : public ServiceFramework<ISession> { 13class ISession final : public ServiceFramework<ISession> {
13public: 14public:
14 ISession() : ServiceFramework("ISession") { 15 ISession(Controller& controller) : ServiceFramework("ISession"), controller(controller) {
15 static const FunctionInfo functions[] = { 16 static const FunctionInfo functions[] = {
16 {0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"}, 17 {0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"},
17 {1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"}, 18 {1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"},
19 {2, nullptr, "SetCpuOverclockEnabled"},
18 }; 20 };
19 RegisterHandlers(functions); 21 RegisterHandlers(functions);
20 } 22 }
21 23
22private: 24private:
23 enum class PerformanceConfiguration : u32 {
24 Config1 = 0x00010000,
25 Config2 = 0x00010001,
26 Config3 = 0x00010002,
27 Config4 = 0x00020000,
28 Config5 = 0x00020001,
29 Config6 = 0x00020002,
30 Config7 = 0x00020003,
31 Config8 = 0x00020004,
32 Config9 = 0x00020005,
33 Config10 = 0x00020006,
34 Config11 = 0x92220007,
35 Config12 = 0x92220008,
36 };
37
38 void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) { 25 void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
39 IPC::RequestParser rp{ctx}; 26 IPC::RequestParser rp{ctx};
40 27
41 auto mode = static_cast<PerformanceMode>(rp.Pop<u32>()); 28 const auto mode = rp.PopEnum<PerformanceMode>();
42 u32 config = rp.Pop<u32>(); 29 const auto config = rp.PopEnum<PerformanceConfiguration>();
43 LOG_WARNING(Service_APM, "(STUBBED) called mode={} config={}", static_cast<u32>(mode), 30 LOG_DEBUG(Service_APM, "called mode={} config={}", static_cast<u32>(mode),
44 config); 31 static_cast<u32>(config));
32
33 controller.SetPerformanceConfiguration(mode, config);
45 34
46 IPC::ResponseBuilder rb{ctx, 2}; 35 IPC::ResponseBuilder rb{ctx, 2};
47 rb.Push(RESULT_SUCCESS); 36 rb.Push(RESULT_SUCCESS);
@@ -50,20 +39,23 @@ private:
50 void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) { 39 void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
51 IPC::RequestParser rp{ctx}; 40 IPC::RequestParser rp{ctx};
52 41
53 auto mode = static_cast<PerformanceMode>(rp.Pop<u32>()); 42 const auto mode = rp.PopEnum<PerformanceMode>();
54 LOG_WARNING(Service_APM, "(STUBBED) called mode={}", static_cast<u32>(mode)); 43 LOG_DEBUG(Service_APM, "called mode={}", static_cast<u32>(mode));
55 44
56 IPC::ResponseBuilder rb{ctx, 3}; 45 IPC::ResponseBuilder rb{ctx, 3};
57 rb.Push(RESULT_SUCCESS); 46 rb.Push(RESULT_SUCCESS);
58 rb.Push<u32>(static_cast<u32>(PerformanceConfiguration::Config1)); 47 rb.PushEnum(controller.GetCurrentPerformanceConfiguration(mode));
59 } 48 }
49
50 Controller& controller;
60}; 51};
61 52
62APM::APM(std::shared_ptr<Module> apm, const char* name) 53APM::APM(std::shared_ptr<Module> apm, Controller& controller, const char* name)
63 : ServiceFramework(name), apm(std::move(apm)) { 54 : ServiceFramework(name), apm(std::move(apm)), controller(controller) {
64 static const FunctionInfo functions[] = { 55 static const FunctionInfo functions[] = {
65 {0, &APM::OpenSession, "OpenSession"}, 56 {0, &APM::OpenSession, "OpenSession"},
66 {1, nullptr, "GetPerformanceMode"}, 57 {1, &APM::GetPerformanceMode, "GetPerformanceMode"},
58 {6, nullptr, "IsCpuOverclockEnabled"},
67 }; 59 };
68 RegisterHandlers(functions); 60 RegisterHandlers(functions);
69} 61}
@@ -75,10 +67,17 @@ void APM::OpenSession(Kernel::HLERequestContext& ctx) {
75 67
76 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 68 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
77 rb.Push(RESULT_SUCCESS); 69 rb.Push(RESULT_SUCCESS);
78 rb.PushIpcInterface<ISession>(); 70 rb.PushIpcInterface<ISession>(controller);
79} 71}
80 72
81APM_Sys::APM_Sys() : ServiceFramework{"apm:sys"} { 73void APM::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
74 LOG_DEBUG(Service_APM, "called");
75
76 IPC::ResponseBuilder rb{ctx, 2};
77 rb.PushEnum(controller.GetCurrentPerformanceMode());
78}
79
80APM_Sys::APM_Sys(Controller& controller) : ServiceFramework{"apm:sys"}, controller(controller) {
82 // clang-format off 81 // clang-format off
83 static const FunctionInfo functions[] = { 82 static const FunctionInfo functions[] = {
84 {0, nullptr, "RequestPerformanceMode"}, 83 {0, nullptr, "RequestPerformanceMode"},
@@ -87,8 +86,8 @@ APM_Sys::APM_Sys() : ServiceFramework{"apm:sys"} {
87 {3, nullptr, "GetLastThrottlingState"}, 86 {3, nullptr, "GetLastThrottlingState"},
88 {4, nullptr, "ClearLastThrottlingState"}, 87 {4, nullptr, "ClearLastThrottlingState"},
89 {5, nullptr, "LoadAndApplySettings"}, 88 {5, nullptr, "LoadAndApplySettings"},
90 {6, nullptr, "SetCpuBoostMode"}, 89 {6, &APM_Sys::SetCpuBoostMode, "SetCpuBoostMode"},
91 {7, nullptr, "GetCurrentPerformanceConfiguration"}, 90 {7, &APM_Sys::GetCurrentPerformanceConfiguration, "GetCurrentPerformanceConfiguration"},
92 }; 91 };
93 // clang-format on 92 // clang-format on
94 93
@@ -102,7 +101,16 @@ void APM_Sys::GetPerformanceEvent(Kernel::HLERequestContext& ctx) {
102 101
103 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 102 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
104 rb.Push(RESULT_SUCCESS); 103 rb.Push(RESULT_SUCCESS);
105 rb.PushIpcInterface<ISession>(); 104 rb.PushIpcInterface<ISession>(controller);
105}
106
107void APM_Sys::GetCurrentPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
108 LOG_DEBUG(Service_APM, "called");
109
110 IPC::ResponseBuilder rb{ctx, 3};
111 rb.Push(RESULT_SUCCESS);
112 rb.PushEnum(
113 controller.GetCurrentPerformanceConfiguration(controller.GetCurrentPerformanceMode()));
106} 114}
107 115
108} // namespace Service::APM 116} // namespace Service::APM
diff --git a/src/core/hle/service/apm/interface.h b/src/core/hle/service/apm/interface.h
index 773541aa4..6d5fdf8ef 100644
--- a/src/core/hle/service/apm/interface.h
+++ b/src/core/hle/service/apm/interface.h
@@ -8,24 +8,32 @@
8 8
9namespace Service::APM { 9namespace Service::APM {
10 10
11class Controller;
12class Module;
13
11class APM final : public ServiceFramework<APM> { 14class APM final : public ServiceFramework<APM> {
12public: 15public:
13 explicit APM(std::shared_ptr<Module> apm, const char* name); 16 explicit APM(std::shared_ptr<Module> apm, Controller& controller, const char* name);
14 ~APM() override; 17 ~APM() override;
15 18
16private: 19private:
17 void OpenSession(Kernel::HLERequestContext& ctx); 20 void OpenSession(Kernel::HLERequestContext& ctx);
21 void GetPerformanceMode(Kernel::HLERequestContext& ctx);
18 22
19 std::shared_ptr<Module> apm; 23 std::shared_ptr<Module> apm;
24 Controller& controller;
20}; 25};
21 26
22class APM_Sys final : public ServiceFramework<APM_Sys> { 27class APM_Sys final : public ServiceFramework<APM_Sys> {
23public: 28public:
24 explicit APM_Sys(); 29 explicit APM_Sys(Controller& controller);
25 ~APM_Sys() override; 30 ~APM_Sys() override;
26 31
27private: 32private:
28 void GetPerformanceEvent(Kernel::HLERequestContext& ctx); 33 void GetPerformanceEvent(Kernel::HLERequestContext& ctx);
34 void GetCurrentPerformanceConfiguration(Kernel::HLERequestContext& ctx);
35
36 Controller& controller;
29}; 37};
30 38
31} // namespace Service::APM 39} // namespace Service::APM