summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt24
-rw-r--r--src/core/hle/service/am/service/common_state_getter.cpp1
-rw-r--r--src/core/hle/service/audio/audctl.cpp4
-rw-r--r--src/core/hle/service/glue/time/manager.cpp47
-rw-r--r--src/core/hle/service/glue/time/manager.h1
-rw-r--r--src/core/hle/service/glue/time/static.cpp17
-rw-r--r--src/core/hle/service/glue/time/worker.cpp2
-rw-r--r--src/core/hle/service/mii/mii.cpp9
-rw-r--r--src/core/hle/service/nvnflinger/binder.h5
-rw-r--r--src/core/hle/service/nvnflinger/buffer_queue_producer.cpp9
-rw-r--r--src/core/hle/service/nvnflinger/buffer_queue_producer.h3
-rw-r--r--src/core/hle/service/set/setting_formats/system_settings.h4
-rw-r--r--src/core/hle/service/set/settings_types.h7
-rw-r--r--src/core/hle/service/set/system_settings_server.cpp1394
-rw-r--r--src/core/hle/service/set/system_settings_server.h208
-rw-r--r--src/core/hle/service/vi/application_display_service.cpp319
-rw-r--r--src/core/hle/service/vi/application_display_service.h65
-rw-r--r--src/core/hle/service/vi/application_root_service.cpp34
-rw-r--r--src/core/hle/service/vi/application_root_service.h39
-rw-r--r--src/core/hle/service/vi/hos_binder_driver.cpp53
-rw-r--r--src/core/hle/service/vi/hos_binder_driver.h30
-rw-r--r--src/core/hle/service/vi/manager_display_service.cpp130
-rw-r--r--src/core/hle/service/vi/manager_display_service.h24
-rw-r--r--src/core/hle/service/vi/manager_root_service.cpp38
-rw-r--r--src/core/hle/service/vi/manager_root_service.h38
-rw-r--r--src/core/hle/service/vi/service_creator.cpp39
-rw-r--r--src/core/hle/service/vi/service_creator.h33
-rw-r--r--src/core/hle/service/vi/system_display_service.cpp145
-rw-r--r--src/core/hle/service/vi/system_display_service.h45
-rw-r--r--src/core/hle/service/vi/system_root_service.cpp33
-rw-r--r--src/core/hle/service/vi/system_root_service.h38
-rw-r--r--src/core/hle/service/vi/vi.cpp967
-rw-r--r--src/core/hle/service/vi/vi.h34
-rw-r--r--src/core/hle/service/vi/vi_m.cpp34
-rw-r--r--src/core/hle/service/vi/vi_m.h32
-rw-r--r--src/core/hle/service/vi/vi_s.cpp30
-rw-r--r--src/core/hle/service/vi/vi_s.h32
-rw-r--r--src/core/hle/service/vi/vi_types.h84
-rw-r--r--src/core/hle/service/vi/vi_u.cpp30
-rw-r--r--src/core/hle/service/vi/vi_u.h32
-rw-r--r--src/hid_core/resources/hid_firmware_settings.cpp37
-rw-r--r--src/hid_core/resources/npad/npad_vibration.cpp6
-rw-r--r--src/hid_core/resources/touch_screen/touch_screen_resource.cpp2
43 files changed, 1917 insertions, 2241 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index bc7f95fea..7770dbeae 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -959,14 +959,26 @@ add_library(core STATIC
959 hle/service/vi/display/vi_display.h 959 hle/service/vi/display/vi_display.h
960 hle/service/vi/layer/vi_layer.cpp 960 hle/service/vi/layer/vi_layer.cpp
961 hle/service/vi/layer/vi_layer.h 961 hle/service/vi/layer/vi_layer.h
962 hle/service/vi/application_display_service.cpp
963 hle/service/vi/application_display_service.h
964 hle/service/vi/application_root_service.cpp
965 hle/service/vi/application_root_service.h
966 hle/service/vi/hos_binder_driver.cpp
967 hle/service/vi/hos_binder_driver.h
968 hle/service/vi/manager_display_service.cpp
969 hle/service/vi/manager_display_service.h
970 hle/service/vi/manager_root_service.cpp
971 hle/service/vi/manager_root_service.h
972 hle/service/vi/service_creator.cpp
973 hle/service/vi/service_creator.h
974 hle/service/vi/system_display_service.cpp
975 hle/service/vi/system_display_service.h
976 hle/service/vi/system_root_service.cpp
977 hle/service/vi/system_root_service.h
978 hle/service/vi/vi_results.h
979 hle/service/vi/vi_types.h
962 hle/service/vi/vi.cpp 980 hle/service/vi/vi.cpp
963 hle/service/vi/vi.h 981 hle/service/vi/vi.h
964 hle/service/vi/vi_m.cpp
965 hle/service/vi/vi_m.h
966 hle/service/vi/vi_s.cpp
967 hle/service/vi/vi_s.h
968 hle/service/vi/vi_u.cpp
969 hle/service/vi/vi_u.h
970 internal_network/network.cpp 982 internal_network/network.cpp
971 internal_network/network.h 983 internal_network/network.h
972 internal_network/network_interface.cpp 984 internal_network/network_interface.cpp
diff --git a/src/core/hle/service/am/service/common_state_getter.cpp b/src/core/hle/service/am/service/common_state_getter.cpp
index 12d7e8cb1..548498e83 100644
--- a/src/core/hle/service/am/service/common_state_getter.cpp
+++ b/src/core/hle/service/am/service/common_state_getter.cpp
@@ -11,6 +11,7 @@
11#include "core/hle/service/pm/pm.h" 11#include "core/hle/service/pm/pm.h"
12#include "core/hle/service/sm/sm.h" 12#include "core/hle/service/sm/sm.h"
13#include "core/hle/service/vi/vi.h" 13#include "core/hle/service/vi/vi.h"
14#include "core/hle/service/vi/vi_types.h"
14 15
15namespace Service::AM { 16namespace Service::AM {
16 17
diff --git a/src/core/hle/service/audio/audctl.cpp b/src/core/hle/service/audio/audctl.cpp
index 3101cf447..cf4bb4034 100644
--- a/src/core/hle/service/audio/audctl.cpp
+++ b/src/core/hle/service/audio/audctl.cpp
@@ -106,7 +106,7 @@ void AudCtl::GetAudioOutputMode(HLERequestContext& ctx) {
106 const auto target{rp.PopEnum<Set::AudioOutputModeTarget>()}; 106 const auto target{rp.PopEnum<Set::AudioOutputModeTarget>()};
107 107
108 Set::AudioOutputMode output_mode{}; 108 Set::AudioOutputMode output_mode{};
109 const auto result = m_set_sys->GetAudioOutputMode(output_mode, target); 109 const auto result = m_set_sys->GetAudioOutputMode(&output_mode, target);
110 110
111 LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode); 111 LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode);
112 112
@@ -188,7 +188,7 @@ void AudCtl::SetSpeakerAutoMuteEnabled(HLERequestContext& ctx) {
188 188
189void AudCtl::IsSpeakerAutoMuteEnabled(HLERequestContext& ctx) { 189void AudCtl::IsSpeakerAutoMuteEnabled(HLERequestContext& ctx) {
190 bool is_speaker_auto_mute_enabled{}; 190 bool is_speaker_auto_mute_enabled{};
191 const auto result = m_set_sys->GetSpeakerAutoMuteFlag(is_speaker_auto_mute_enabled); 191 const auto result = m_set_sys->GetSpeakerAutoMuteFlag(&is_speaker_auto_mute_enabled);
192 192
193 LOG_WARNING(Audio, "(STUBBED) called, is_speaker_auto_mute_enabled={}", 193 LOG_WARNING(Audio, "(STUBBED) called, is_speaker_auto_mute_enabled={}",
194 is_speaker_auto_mute_enabled); 194 is_speaker_auto_mute_enabled);
diff --git a/src/core/hle/service/glue/time/manager.cpp b/src/core/hle/service/glue/time/manager.cpp
index 0c27e8029..059ac3fc9 100644
--- a/src/core/hle/service/glue/time/manager.cpp
+++ b/src/core/hle/service/glue/time/manager.cpp
@@ -21,19 +21,6 @@
21 21
22namespace Service::Glue::Time { 22namespace Service::Glue::Time {
23namespace { 23namespace {
24
25template <typename T>
26T GetSettingsItemValue(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys,
27 const char* category, const char* name) {
28 std::vector<u8> interval_buf;
29 auto res = set_sys->GetSettingsItemValue(interval_buf, category, name);
30 ASSERT(res == ResultSuccess);
31
32 T v{};
33 std::memcpy(&v, interval_buf.data(), sizeof(T));
34 return v;
35}
36
37s64 CalendarTimeToEpoch(Service::PSC::Time::CalendarTime calendar) { 24s64 CalendarTimeToEpoch(Service::PSC::Time::CalendarTime calendar) {
38 constexpr auto is_leap = [](s32 year) -> bool { 25 constexpr auto is_leap = [](s32 year) -> bool {
39 return (((year) % 4) == 0 && (((year) % 100) != 0 || ((year) % 400) == 0)); 26 return (((year) % 4) == 0 && (((year) % 100) != 0 || ((year) % 400) == 0));
@@ -65,13 +52,15 @@ s64 CalendarTimeToEpoch(Service::PSC::Time::CalendarTime calendar) {
65 52
66s64 GetEpochTimeFromInitialYear(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys) { 53s64 GetEpochTimeFromInitialYear(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys) {
67 Service::PSC::Time::CalendarTime calendar{ 54 Service::PSC::Time::CalendarTime calendar{
68 .year = GetSettingsItemValue<s16>(set_sys, "time", "standard_user_clock_initial_year"), 55 .year = 2000,
69 .month = 1, 56 .month = 1,
70 .day = 1, 57 .day = 1,
71 .hour = 0, 58 .hour = 0,
72 .minute = 0, 59 .minute = 0,
73 .second = 0, 60 .second = 0,
74 }; 61 };
62 set_sys->GetSettingsItemValueImpl<s16>(calendar.year, "time",
63 "standard_user_clock_initial_year");
75 return CalendarTimeToEpoch(calendar); 64 return CalendarTimeToEpoch(calendar);
76} 65}
77 66
@@ -124,7 +113,7 @@ TimeManager::TimeManager(Core::System& system)
124 ASSERT(res == ResultSuccess); 113 ASSERT(res == ResultSuccess);
125 114
126 Service::PSC::Time::SystemClockContext user_clock_context{}; 115 Service::PSC::Time::SystemClockContext user_clock_context{};
127 res = m_set_sys->GetUserSystemClockContext(user_clock_context); 116 res = m_set_sys->GetUserSystemClockContext(&user_clock_context);
128 ASSERT(res == ResultSuccess); 117 ASSERT(res == ResultSuccess);
129 118
130 // TODO the local clock should initialise with this epoch time, and be updated somewhere else on 119 // TODO the local clock should initialise with this epoch time, and be updated somewhere else on
@@ -140,11 +129,12 @@ TimeManager::TimeManager(Core::System& system)
140 ASSERT(res == ResultSuccess); 129 ASSERT(res == ResultSuccess);
141 130
142 Service::PSC::Time::SystemClockContext network_clock_context{}; 131 Service::PSC::Time::SystemClockContext network_clock_context{};
143 res = m_set_sys->GetNetworkSystemClockContext(network_clock_context); 132 res = m_set_sys->GetNetworkSystemClockContext(&network_clock_context);
144 ASSERT(res == ResultSuccess); 133 ASSERT(res == ResultSuccess);
145 134
146 auto network_accuracy_m{GetSettingsItemValue<s32>( 135 s32 network_accuracy_m{};
147 m_set_sys, "time", "standard_network_clock_sufficient_accuracy_minutes")}; 136 m_set_sys->GetSettingsItemValueImpl<s32>(network_accuracy_m, "time",
137 "standard_network_clock_sufficient_accuracy_minutes");
148 auto one_minute_ns{ 138 auto one_minute_ns{
149 std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::minutes(1)).count()}; 139 std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::minutes(1)).count()};
150 s64 network_accuracy_ns{network_accuracy_m * one_minute_ns}; 140 s64 network_accuracy_ns{network_accuracy_m * one_minute_ns};
@@ -153,12 +143,12 @@ TimeManager::TimeManager(Core::System& system)
153 ASSERT(res == ResultSuccess); 143 ASSERT(res == ResultSuccess);
154 144
155 bool is_automatic_correction_enabled{}; 145 bool is_automatic_correction_enabled{};
156 res = m_set_sys->IsUserSystemClockAutomaticCorrectionEnabled(is_automatic_correction_enabled); 146 res = m_set_sys->IsUserSystemClockAutomaticCorrectionEnabled(&is_automatic_correction_enabled);
157 ASSERT(res == ResultSuccess); 147 ASSERT(res == ResultSuccess);
158 148
159 Service::PSC::Time::SteadyClockTimePoint automatic_correction_time_point{}; 149 Service::PSC::Time::SteadyClockTimePoint automatic_correction_time_point{};
160 res = m_set_sys->GetUserSystemClockAutomaticCorrectionUpdatedTime( 150 res = m_set_sys->GetUserSystemClockAutomaticCorrectionUpdatedTime(
161 automatic_correction_time_point); 151 &automatic_correction_time_point);
162 ASSERT(res == ResultSuccess); 152 ASSERT(res == ResultSuccess);
163 153
164 res = m_time_m->SetupStandardUserSystemClockCore(is_automatic_correction_enabled, 154 res = m_time_m->SetupStandardUserSystemClockCore(is_automatic_correction_enabled,
@@ -196,13 +186,17 @@ TimeManager::TimeManager(Core::System& system)
196 } 186 }
197} 187}
198 188
189TimeManager::~TimeManager() {
190 ResetTimeZoneBinary();
191}
192
199Result TimeManager::SetupStandardSteadyClockCore() { 193Result TimeManager::SetupStandardSteadyClockCore() {
200 Common::UUID external_clock_source_id{}; 194 Common::UUID external_clock_source_id{};
201 auto res = m_set_sys->GetExternalSteadyClockSourceId(external_clock_source_id); 195 auto res = m_set_sys->GetExternalSteadyClockSourceId(&external_clock_source_id);
202 ASSERT(res == ResultSuccess); 196 ASSERT(res == ResultSuccess);
203 197
204 s64 external_steady_clock_internal_offset_s{}; 198 s64 external_steady_clock_internal_offset_s{};
205 res = m_set_sys->GetExternalSteadyClockInternalOffset(external_steady_clock_internal_offset_s); 199 res = m_set_sys->GetExternalSteadyClockInternalOffset(&external_steady_clock_internal_offset_s);
206 ASSERT(res == ResultSuccess); 200 ASSERT(res == ResultSuccess);
207 201
208 auto one_second_ns{ 202 auto one_second_ns{
@@ -210,8 +204,9 @@ Result TimeManager::SetupStandardSteadyClockCore() {
210 s64 external_steady_clock_internal_offset_ns{external_steady_clock_internal_offset_s * 204 s64 external_steady_clock_internal_offset_ns{external_steady_clock_internal_offset_s *
211 one_second_ns}; 205 one_second_ns};
212 206
213 s32 standard_steady_clock_test_offset_m{ 207 s32 standard_steady_clock_test_offset_m{};
214 GetSettingsItemValue<s32>(m_set_sys, "time", "standard_steady_clock_test_offset_minutes")}; 208 m_set_sys->GetSettingsItemValueImpl<s32>(standard_steady_clock_test_offset_m, "time",
209 "standard_steady_clock_test_offset_minutes");
215 auto one_minute_ns{ 210 auto one_minute_ns{
216 std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::minutes(1)).count()}; 211 std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::minutes(1)).count()};
217 s64 standard_steady_clock_test_offset_ns{standard_steady_clock_test_offset_m * one_minute_ns}; 212 s64 standard_steady_clock_test_offset_ns{standard_steady_clock_test_offset_m * one_minute_ns};
@@ -237,7 +232,7 @@ Result TimeManager::SetupStandardSteadyClockCore() {
237 232
238Result TimeManager::SetupTimeZoneServiceCore() { 233Result TimeManager::SetupTimeZoneServiceCore() {
239 Service::PSC::Time::LocationName name{}; 234 Service::PSC::Time::LocationName name{};
240 auto res = m_set_sys->GetDeviceTimeZoneLocationName(name); 235 auto res = m_set_sys->GetDeviceTimeZoneLocationName(&name);
241 ASSERT(res == ResultSuccess); 236 ASSERT(res == ResultSuccess);
242 237
243 auto configured_zone = GetTimeZoneString(name); 238 auto configured_zone = GetTimeZoneString(name);
@@ -255,7 +250,7 @@ Result TimeManager::SetupTimeZoneServiceCore() {
255 } 250 }
256 251
257 Service::PSC::Time::SteadyClockTimePoint time_point{}; 252 Service::PSC::Time::SteadyClockTimePoint time_point{};
258 res = m_set_sys->GetDeviceTimeZoneLocationUpdatedTime(time_point); 253 res = m_set_sys->GetDeviceTimeZoneLocationUpdatedTime(&time_point);
259 ASSERT(res == ResultSuccess); 254 ASSERT(res == ResultSuccess);
260 255
261 auto location_count = GetTimeZoneCount(); 256 auto location_count = GetTimeZoneCount();
diff --git a/src/core/hle/service/glue/time/manager.h b/src/core/hle/service/glue/time/manager.h
index 1de93f8f9..bb4b65049 100644
--- a/src/core/hle/service/glue/time/manager.h
+++ b/src/core/hle/service/glue/time/manager.h
@@ -26,6 +26,7 @@ namespace Service::Glue::Time {
26class TimeManager { 26class TimeManager {
27public: 27public:
28 explicit TimeManager(Core::System& system); 28 explicit TimeManager(Core::System& system);
29 ~TimeManager();
29 30
30 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; 31 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
31 32
diff --git a/src/core/hle/service/glue/time/static.cpp b/src/core/hle/service/glue/time/static.cpp
index f8c1218f3..ec9b0efb1 100644
--- a/src/core/hle/service/glue/time/static.cpp
+++ b/src/core/hle/service/glue/time/static.cpp
@@ -20,19 +20,6 @@
20#include "core/hle/service/sm/sm.h" 20#include "core/hle/service/sm/sm.h"
21 21
22namespace Service::Glue::Time { 22namespace Service::Glue::Time {
23namespace {
24template <typename T>
25T GetSettingsItemValue(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys,
26 const char* category, const char* name) {
27 std::vector<u8> interval_buf;
28 auto res = set_sys->GetSettingsItemValue(interval_buf, category, name);
29 ASSERT(res == ResultSuccess);
30
31 T v{};
32 std::memcpy(&v, interval_buf.data(), sizeof(T));
33 return v;
34}
35} // namespace
36 23
37StaticService::StaticService(Core::System& system_, 24StaticService::StaticService(Core::System& system_,
38 Service::PSC::Time::StaticServiceSetupInfo setup_info, 25 Service::PSC::Time::StaticServiceSetupInfo setup_info,
@@ -181,8 +168,8 @@ Result StaticService::SetStandardUserSystemClockAutomaticCorrectionEnabled(
181Result StaticService::GetStandardUserSystemClockInitialYear(Out<s32> out_year) { 168Result StaticService::GetStandardUserSystemClockInitialYear(Out<s32> out_year) {
182 SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_year={}", *out_year); }); 169 SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. out_year={}", *out_year); });
183 170
184 *out_year = GetSettingsItemValue<s32>(m_set_sys, "time", "standard_user_clock_initial_year"); 171 R_RETURN(m_set_sys->GetSettingsItemValueImpl<s32>(*out_year, "time",
185 R_SUCCEED(); 172 "standard_user_clock_initial_year"));
186} 173}
187 174
188Result StaticService::IsStandardNetworkSystemClockAccuracySufficient(Out<bool> out_is_sufficient) { 175Result StaticService::IsStandardNetworkSystemClockAccuracySufficient(Out<bool> out_is_sufficient) {
diff --git a/src/core/hle/service/glue/time/worker.cpp b/src/core/hle/service/glue/time/worker.cpp
index 8787f2dcd..b28569b68 100644
--- a/src/core/hle/service/glue/time/worker.cpp
+++ b/src/core/hle/service/glue/time/worker.cpp
@@ -27,7 +27,7 @@ template <typename T>
27T GetSettingsItemValue(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys, 27T GetSettingsItemValue(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys,
28 const char* category, const char* name) { 28 const char* category, const char* name) {
29 std::vector<u8> interval_buf; 29 std::vector<u8> interval_buf;
30 auto res = set_sys->GetSettingsItemValue(interval_buf, category, name); 30 auto res = set_sys->GetSettingsItemValueImpl(interval_buf, category, name);
31 ASSERT(res == ResultSuccess); 31 ASSERT(res == ResultSuccess);
32 32
33 T v{}; 33 T v{};
diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp
index 0086f82c5..adaaea571 100644
--- a/src/core/hle/service/mii/mii.cpp
+++ b/src/core/hle/service/mii/mii.cpp
@@ -207,7 +207,8 @@ private:
207 207
208 Result DestroyFile() { 208 Result DestroyFile() {
209 bool is_db_test_mode_enabled{}; 209 bool is_db_test_mode_enabled{};
210 m_set_sys->GetSettingsItemValue(is_db_test_mode_enabled, "mii", "is_db_test_mode_enabled"); 210 m_set_sys->GetSettingsItemValueImpl(is_db_test_mode_enabled, "mii",
211 "is_db_test_mode_enabled");
211 212
212 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled); 213 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
213 R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly); 214 R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly);
@@ -217,7 +218,8 @@ private:
217 218
218 Result DeleteFile() { 219 Result DeleteFile() {
219 bool is_db_test_mode_enabled{}; 220 bool is_db_test_mode_enabled{};
220 m_set_sys->GetSettingsItemValue(is_db_test_mode_enabled, "mii", "is_db_test_mode_enabled"); 221 m_set_sys->GetSettingsItemValueImpl(is_db_test_mode_enabled, "mii",
222 "is_db_test_mode_enabled");
221 223
222 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled); 224 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
223 R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly); 225 R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly);
@@ -227,7 +229,8 @@ private:
227 229
228 Result Format() { 230 Result Format() {
229 bool is_db_test_mode_enabled{}; 231 bool is_db_test_mode_enabled{};
230 m_set_sys->GetSettingsItemValue(is_db_test_mode_enabled, "mii", "is_db_test_mode_enabled"); 232 m_set_sys->GetSettingsItemValueImpl(is_db_test_mode_enabled, "mii",
233 "is_db_test_mode_enabled");
231 234
232 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled); 235 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
233 R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly); 236 R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly);
diff --git a/src/core/hle/service/nvnflinger/binder.h b/src/core/hle/service/nvnflinger/binder.h
index aef1477e3..179938192 100644
--- a/src/core/hle/service/nvnflinger/binder.h
+++ b/src/core/hle/service/nvnflinger/binder.h
@@ -6,6 +6,8 @@
6 6
7#pragma once 7#pragma once
8 8
9#include <span>
10
9#include "common/common_types.h" 11#include "common/common_types.h"
10 12
11namespace Kernel { 13namespace Kernel {
@@ -38,7 +40,8 @@ enum class TransactionId {
38class IBinder { 40class IBinder {
39public: 41public:
40 virtual ~IBinder() = default; 42 virtual ~IBinder() = default;
41 virtual void Transact(HLERequestContext& ctx, android::TransactionId code, u32 flags) = 0; 43 virtual void Transact(android::TransactionId code, u32 flags, std::span<const u8> parcel_data,
44 std::span<u8> parcel_reply) = 0;
42 virtual Kernel::KReadableEvent& GetNativeHandle() = 0; 45 virtual Kernel::KReadableEvent& GetNativeHandle() = 0;
43}; 46};
44 47
diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp
index 5d8762d25..ec83beb9b 100644
--- a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp
+++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp
@@ -807,9 +807,10 @@ Status BufferQueueProducer::SetPreallocatedBuffer(s32 slot,
807 return Status::NoError; 807 return Status::NoError;
808} 808}
809 809
810void BufferQueueProducer::Transact(HLERequestContext& ctx, TransactionId code, u32 flags) { 810void BufferQueueProducer::Transact(TransactionId code, u32 flags, std::span<const u8> parcel_data,
811 std::span<u8> parcel_reply) {
811 Status status{Status::NoError}; 812 Status status{Status::NoError};
812 InputParcel parcel_in{ctx.ReadBuffer()}; 813 InputParcel parcel_in{parcel_data};
813 OutputParcel parcel_out{}; 814 OutputParcel parcel_out{};
814 815
815 switch (code) { 816 switch (code) {
@@ -917,7 +918,9 @@ void BufferQueueProducer::Transact(HLERequestContext& ctx, TransactionId code, u
917 918
918 parcel_out.Write(status); 919 parcel_out.Write(status);
919 920
920 ctx.WriteBuffer(parcel_out.Serialize()); 921 const auto serialized = parcel_out.Serialize();
922 std::memcpy(parcel_reply.data(), serialized.data(),
923 std::min(parcel_reply.size(), serialized.size()));
921} 924}
922 925
923Kernel::KReadableEvent& BufferQueueProducer::GetNativeHandle() { 926Kernel::KReadableEvent& BufferQueueProducer::GetNativeHandle() {
diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.h b/src/core/hle/service/nvnflinger/buffer_queue_producer.h
index 64c17d56c..4682b0f84 100644
--- a/src/core/hle/service/nvnflinger/buffer_queue_producer.h
+++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.h
@@ -47,7 +47,8 @@ public:
47 Service::Nvidia::NvCore::NvMap& nvmap_); 47 Service::Nvidia::NvCore::NvMap& nvmap_);
48 ~BufferQueueProducer(); 48 ~BufferQueueProducer();
49 49
50 void Transact(HLERequestContext& ctx, android::TransactionId code, u32 flags) override; 50 void Transact(android::TransactionId code, u32 flags, std::span<const u8> parcel_data,
51 std::span<u8> parcel_reply) override;
51 52
52 Kernel::KReadableEvent& GetNativeHandle() override; 53 Kernel::KReadableEvent& GetNativeHandle() override;
53 54
diff --git a/src/core/hle/service/set/setting_formats/system_settings.h b/src/core/hle/service/set/setting_formats/system_settings.h
index 40230182a..a5b1552a5 100644
--- a/src/core/hle/service/set/setting_formats/system_settings.h
+++ b/src/core/hle/service/set/setting_formats/system_settings.h
@@ -244,7 +244,7 @@ struct SystemSettings {
244 INSERT_PADDING_BYTES(0x60); // Reserved 244 INSERT_PADDING_BYTES(0x60); // Reserved
245 245
246 // nn::settings::system::AccountNotificationSettings 246 // nn::settings::system::AccountNotificationSettings
247 u32 account_notification_settings_count; 247 s32 account_notification_settings_count;
248 INSERT_PADDING_BYTES(0xC); // Reserved 248 INSERT_PADDING_BYTES(0xC); // Reserved
249 std::array<AccountNotificationSettings, 8> account_notification_settings; 249 std::array<AccountNotificationSettings, 8> account_notification_settings;
250 INSERT_PADDING_BYTES(0x140); // Reserved 250 INSERT_PADDING_BYTES(0x140); // Reserved
@@ -308,7 +308,7 @@ struct SystemSettings {
308 INSERT_PADDING_BYTES(0x34); // Reserved 308 INSERT_PADDING_BYTES(0x34); // Reserved
309 309
310 // nn::settings::system::EulaVersion 310 // nn::settings::system::EulaVersion
311 u32 eula_version_count; 311 s32 eula_version_count;
312 INSERT_PADDING_BYTES(0xC); // Reserved 312 INSERT_PADDING_BYTES(0xC); // Reserved
313 std::array<EulaVersion, 32> eula_versions; 313 std::array<EulaVersion, 32> eula_versions;
314 INSERT_PADDING_BYTES(0x200); // Reserved 314 INSERT_PADDING_BYTES(0x200); // Reserved
diff --git a/src/core/hle/service/set/settings_types.h b/src/core/hle/service/set/settings_types.h
index 83ef6635b..29664e88c 100644
--- a/src/core/hle/service/set/settings_types.h
+++ b/src/core/hle/service/set/settings_types.h
@@ -12,6 +12,7 @@
12#include "core/hle/service/psc/time/common.h" 12#include "core/hle/service/psc/time/common.h"
13 13
14namespace Service::Set { 14namespace Service::Set {
15using SettingItemName = std::array<u8, 0x48>;
15 16
16/// This is nn::settings::system::AudioOutputMode 17/// This is nn::settings::system::AudioOutputMode
17enum class AudioOutputMode : u32 { 18enum class AudioOutputMode : u32 {
@@ -413,16 +414,18 @@ struct FirmwareVersionFormat {
413 u8 major; 414 u8 major;
414 u8 minor; 415 u8 minor;
415 u8 micro; 416 u8 micro;
416 INSERT_PADDING_BYTES(1); 417 INSERT_PADDING_BYTES_NOINIT(1);
417 u8 revision_major; 418 u8 revision_major;
418 u8 revision_minor; 419 u8 revision_minor;
419 INSERT_PADDING_BYTES(2); 420 INSERT_PADDING_BYTES_NOINIT(2);
420 std::array<char, 0x20> platform; 421 std::array<char, 0x20> platform;
421 std::array<u8, 0x40> version_hash; 422 std::array<u8, 0x40> version_hash;
422 std::array<char, 0x18> display_version; 423 std::array<char, 0x18> display_version;
423 std::array<char, 0x80> display_title; 424 std::array<char, 0x80> display_title;
424}; 425};
425static_assert(sizeof(FirmwareVersionFormat) == 0x100, "FirmwareVersionFormat is an invalid size"); 426static_assert(sizeof(FirmwareVersionFormat) == 0x100, "FirmwareVersionFormat is an invalid size");
427static_assert(std::is_trivial_v<FirmwareVersionFormat>,
428 "FirmwareVersionFormat type must be trivially copyable.");
426 429
427/// This is nn::settings::system::HomeMenuScheme 430/// This is nn::settings::system::HomeMenuScheme
428struct HomeMenuScheme { 431struct HomeMenuScheme {
diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp
index 7ef4a0ded..93925f783 100644
--- a/src/core/hle/service/set/system_settings_server.cpp
+++ b/src/core/hle/service/set/system_settings_server.cpp
@@ -17,6 +17,7 @@
17#include "core/file_sys/registered_cache.h" 17#include "core/file_sys/registered_cache.h"
18#include "core/file_sys/romfs.h" 18#include "core/file_sys/romfs.h"
19#include "core/file_sys/system_archive/system_archive.h" 19#include "core/file_sys/system_archive/system_archive.h"
20#include "core/hle/service/cmif_serialization.h"
20#include "core/hle/service/filesystem/filesystem.h" 21#include "core/hle/service/filesystem/filesystem.h"
21#include "core/hle/service/ipc_helpers.h" 22#include "core/hle/service/ipc_helpers.h"
22#include "core/hle/service/set/settings_server.h" 23#include "core/hle/service/set/settings_server.h"
@@ -91,83 +92,83 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
91 : ServiceFramework{system_, "set:sys"}, m_system{system} { 92 : ServiceFramework{system_, "set:sys"}, m_system{system} {
92 // clang-format off 93 // clang-format off
93 static const FunctionInfo functions[] = { 94 static const FunctionInfo functions[] = {
94 {0, &ISystemSettingsServer::SetLanguageCode, "SetLanguageCode"}, 95 {0, C<&ISystemSettingsServer::SetLanguageCode>, "SetLanguageCode"},
95 {1, nullptr, "SetNetworkSettings"}, 96 {1, nullptr, "SetNetworkSettings"},
96 {2, nullptr, "GetNetworkSettings"}, 97 {2, nullptr, "GetNetworkSettings"},
97 {3, &ISystemSettingsServer::GetFirmwareVersion, "GetFirmwareVersion"}, 98 {3, C<&ISystemSettingsServer::GetFirmwareVersion>, "GetFirmwareVersion"},
98 {4, &ISystemSettingsServer::GetFirmwareVersion2, "GetFirmwareVersion2"}, 99 {4, C<&ISystemSettingsServer::GetFirmwareVersion2>, "GetFirmwareVersion2"},
99 {5, nullptr, "GetFirmwareVersionDigest"}, 100 {5, nullptr, "GetFirmwareVersionDigest"},
100 {7, &ISystemSettingsServer::GetLockScreenFlag, "GetLockScreenFlag"}, 101 {7, C<&ISystemSettingsServer::GetLockScreenFlag>, "GetLockScreenFlag"},
101 {8, &ISystemSettingsServer::SetLockScreenFlag, "SetLockScreenFlag"}, 102 {8, C<&ISystemSettingsServer::SetLockScreenFlag>, "SetLockScreenFlag"},
102 {9, nullptr, "GetBacklightSettings"}, 103 {9, nullptr, "GetBacklightSettings"},
103 {10, nullptr, "SetBacklightSettings"}, 104 {10, nullptr, "SetBacklightSettings"},
104 {11, nullptr, "SetBluetoothDevicesSettings"}, 105 {11, nullptr, "SetBluetoothDevicesSettings"},
105 {12, nullptr, "GetBluetoothDevicesSettings"}, 106 {12, nullptr, "GetBluetoothDevicesSettings"},
106 {13, &ISystemSettingsServer::GetExternalSteadyClockSourceId, "GetExternalSteadyClockSourceId"}, 107 {13, C<&ISystemSettingsServer::GetExternalSteadyClockSourceId>, "GetExternalSteadyClockSourceId"},
107 {14, &ISystemSettingsServer::SetExternalSteadyClockSourceId, "SetExternalSteadyClockSourceId"}, 108 {14, C<&ISystemSettingsServer::SetExternalSteadyClockSourceId>, "SetExternalSteadyClockSourceId"},
108 {15, &ISystemSettingsServer::GetUserSystemClockContext, "GetUserSystemClockContext"}, 109 {15, C<&ISystemSettingsServer::GetUserSystemClockContext>, "GetUserSystemClockContext"},
109 {16, &ISystemSettingsServer::SetUserSystemClockContext, "SetUserSystemClockContext"}, 110 {16, C<&ISystemSettingsServer::SetUserSystemClockContext>, "SetUserSystemClockContext"},
110 {17, &ISystemSettingsServer::GetAccountSettings, "GetAccountSettings"}, 111 {17, C<&ISystemSettingsServer::GetAccountSettings>, "GetAccountSettings"},
111 {18, &ISystemSettingsServer::SetAccountSettings, "SetAccountSettings"}, 112 {18, C<&ISystemSettingsServer::SetAccountSettings>, "SetAccountSettings"},
112 {19, nullptr, "GetAudioVolume"}, 113 {19, nullptr, "GetAudioVolume"},
113 {20, nullptr, "SetAudioVolume"}, 114 {20, nullptr, "SetAudioVolume"},
114 {21, &ISystemSettingsServer::GetEulaVersions, "GetEulaVersions"}, 115 {21, C<&ISystemSettingsServer::GetEulaVersions>, "GetEulaVersions"},
115 {22, &ISystemSettingsServer::SetEulaVersions, "SetEulaVersions"}, 116 {22, C<&ISystemSettingsServer::SetEulaVersions>, "SetEulaVersions"},
116 {23, &ISystemSettingsServer::GetColorSetId, "GetColorSetId"}, 117 {23, C<&ISystemSettingsServer::GetColorSetId>, "GetColorSetId"},
117 {24, &ISystemSettingsServer::SetColorSetId, "SetColorSetId"}, 118 {24, C<&ISystemSettingsServer::SetColorSetId>, "SetColorSetId"},
118 {25, nullptr, "GetConsoleInformationUploadFlag"}, 119 {25, nullptr, "GetConsoleInformationUploadFlag"},
119 {26, nullptr, "SetConsoleInformationUploadFlag"}, 120 {26, nullptr, "SetConsoleInformationUploadFlag"},
120 {27, nullptr, "GetAutomaticApplicationDownloadFlag"}, 121 {27, nullptr, "GetAutomaticApplicationDownloadFlag"},
121 {28, nullptr, "SetAutomaticApplicationDownloadFlag"}, 122 {28, nullptr, "SetAutomaticApplicationDownloadFlag"},
122 {29, &ISystemSettingsServer::GetNotificationSettings, "GetNotificationSettings"}, 123 {29, C<&ISystemSettingsServer::GetNotificationSettings>, "GetNotificationSettings"},
123 {30, &ISystemSettingsServer::SetNotificationSettings, "SetNotificationSettings"}, 124 {30, C<&ISystemSettingsServer::SetNotificationSettings>, "SetNotificationSettings"},
124 {31, &ISystemSettingsServer::GetAccountNotificationSettings, "GetAccountNotificationSettings"}, 125 {31, C<&ISystemSettingsServer::GetAccountNotificationSettings>, "GetAccountNotificationSettings"},
125 {32, &ISystemSettingsServer::SetAccountNotificationSettings, "SetAccountNotificationSettings"}, 126 {32, C<&ISystemSettingsServer::SetAccountNotificationSettings>, "SetAccountNotificationSettings"},
126 {35, &ISystemSettingsServer::GetVibrationMasterVolume, "GetVibrationMasterVolume"}, 127 {35, C<&ISystemSettingsServer::GetVibrationMasterVolume>, "GetVibrationMasterVolume"},
127 {36, &ISystemSettingsServer::SetVibrationMasterVolume, "SetVibrationMasterVolume"}, 128 {36, C<&ISystemSettingsServer::SetVibrationMasterVolume>, "SetVibrationMasterVolume"},
128 {37, &ISystemSettingsServer::GetSettingsItemValueSize, "GetSettingsItemValueSize"}, 129 {37, C<&ISystemSettingsServer::GetSettingsItemValueSize>, "GetSettingsItemValueSize"},
129 {38, &ISystemSettingsServer::GetSettingsItemValue, "GetSettingsItemValue"}, 130 {38, C<&ISystemSettingsServer::GetSettingsItemValue>, "GetSettingsItemValue"},
130 {39, &ISystemSettingsServer::GetTvSettings, "GetTvSettings"}, 131 {39, C<&ISystemSettingsServer::GetTvSettings>, "GetTvSettings"},
131 {40, &ISystemSettingsServer::SetTvSettings, "SetTvSettings"}, 132 {40, C<&ISystemSettingsServer::SetTvSettings>, "SetTvSettings"},
132 {41, nullptr, "GetEdid"}, 133 {41, nullptr, "GetEdid"},
133 {42, nullptr, "SetEdid"}, 134 {42, nullptr, "SetEdid"},
134 {43, &ISystemSettingsServer::GetAudioOutputMode, "GetAudioOutputMode"}, 135 {43, C<&ISystemSettingsServer::GetAudioOutputMode>, "GetAudioOutputMode"},
135 {44, &ISystemSettingsServer::SetAudioOutputMode, "SetAudioOutputMode"}, 136 {44, C<&ISystemSettingsServer::SetAudioOutputMode>, "SetAudioOutputMode"},
136 {45, &ISystemSettingsServer::GetSpeakerAutoMuteFlag , "GetSpeakerAutoMuteFlag"}, 137 {45, C<&ISystemSettingsServer::GetSpeakerAutoMuteFlag> , "GetSpeakerAutoMuteFlag"},
137 {46, &ISystemSettingsServer::SetSpeakerAutoMuteFlag , "SetSpeakerAutoMuteFlag"}, 138 {46, C<&ISystemSettingsServer::SetSpeakerAutoMuteFlag> , "SetSpeakerAutoMuteFlag"},
138 {47, &ISystemSettingsServer::GetQuestFlag, "GetQuestFlag"}, 139 {47, C<&ISystemSettingsServer::GetQuestFlag>, "GetQuestFlag"},
139 {48, &ISystemSettingsServer::SetQuestFlag, "SetQuestFlag"}, 140 {48, C<&ISystemSettingsServer::SetQuestFlag>, "SetQuestFlag"},
140 {49, nullptr, "GetDataDeletionSettings"}, 141 {49, nullptr, "GetDataDeletionSettings"},
141 {50, nullptr, "SetDataDeletionSettings"}, 142 {50, nullptr, "SetDataDeletionSettings"},
142 {51, nullptr, "GetInitialSystemAppletProgramId"}, 143 {51, nullptr, "GetInitialSystemAppletProgramId"},
143 {52, nullptr, "GetOverlayDispProgramId"}, 144 {52, nullptr, "GetOverlayDispProgramId"},
144 {53, &ISystemSettingsServer::GetDeviceTimeZoneLocationName, "GetDeviceTimeZoneLocationName"}, 145 {53, C<&ISystemSettingsServer::GetDeviceTimeZoneLocationName>, "GetDeviceTimeZoneLocationName"},
145 {54, &ISystemSettingsServer::SetDeviceTimeZoneLocationName, "SetDeviceTimeZoneLocationName"}, 146 {54, C<&ISystemSettingsServer::SetDeviceTimeZoneLocationName>, "SetDeviceTimeZoneLocationName"},
146 {55, nullptr, "GetWirelessCertificationFileSize"}, 147 {55, nullptr, "GetWirelessCertificationFileSize"},
147 {56, nullptr, "GetWirelessCertificationFile"}, 148 {56, nullptr, "GetWirelessCertificationFile"},
148 {57, &ISystemSettingsServer::SetRegionCode, "SetRegionCode"}, 149 {57, C<&ISystemSettingsServer::SetRegionCode>, "SetRegionCode"},
149 {58, &ISystemSettingsServer::GetNetworkSystemClockContext, "GetNetworkSystemClockContext"}, 150 {58, C<&ISystemSettingsServer::GetNetworkSystemClockContext>, "GetNetworkSystemClockContext"},
150 {59, &ISystemSettingsServer::SetNetworkSystemClockContext, "SetNetworkSystemClockContext"}, 151 {59, C<&ISystemSettingsServer::SetNetworkSystemClockContext>, "SetNetworkSystemClockContext"},
151 {60, &ISystemSettingsServer::IsUserSystemClockAutomaticCorrectionEnabled, "IsUserSystemClockAutomaticCorrectionEnabled"}, 152 {60, C<&ISystemSettingsServer::IsUserSystemClockAutomaticCorrectionEnabled>, "IsUserSystemClockAutomaticCorrectionEnabled"},
152 {61, &ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionEnabled, "SetUserSystemClockAutomaticCorrectionEnabled"}, 153 {61, C<&ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionEnabled>, "SetUserSystemClockAutomaticCorrectionEnabled"},
153 {62, &ISystemSettingsServer::GetDebugModeFlag, "GetDebugModeFlag"}, 154 {62, C<&ISystemSettingsServer::GetDebugModeFlag>, "GetDebugModeFlag"},
154 {63, &ISystemSettingsServer::GetPrimaryAlbumStorage, "GetPrimaryAlbumStorage"}, 155 {63, C<&ISystemSettingsServer::GetPrimaryAlbumStorage>, "GetPrimaryAlbumStorage"},
155 {64, &ISystemSettingsServer::SetPrimaryAlbumStorage, "SetPrimaryAlbumStorage"}, 156 {64, C<&ISystemSettingsServer::SetPrimaryAlbumStorage>, "SetPrimaryAlbumStorage"},
156 {65, nullptr, "GetUsb30EnableFlag"}, 157 {65, nullptr, "GetUsb30EnableFlag"},
157 {66, nullptr, "SetUsb30EnableFlag"}, 158 {66, nullptr, "SetUsb30EnableFlag"},
158 {67, &ISystemSettingsServer::GetBatteryLot, "GetBatteryLot"}, 159 {67, C<&ISystemSettingsServer::GetBatteryLot>, "GetBatteryLot"},
159 {68, &ISystemSettingsServer::GetSerialNumber, "GetSerialNumber"}, 160 {68, C<&ISystemSettingsServer::GetSerialNumber>, "GetSerialNumber"},
160 {69, &ISystemSettingsServer::GetNfcEnableFlag, "GetNfcEnableFlag"}, 161 {69, C<&ISystemSettingsServer::GetNfcEnableFlag>, "GetNfcEnableFlag"},
161 {70, &ISystemSettingsServer::SetNfcEnableFlag, "SetNfcEnableFlag"}, 162 {70, C<&ISystemSettingsServer::SetNfcEnableFlag>, "SetNfcEnableFlag"},
162 {71, &ISystemSettingsServer::GetSleepSettings, "GetSleepSettings"}, 163 {71, C<&ISystemSettingsServer::GetSleepSettings>, "GetSleepSettings"},
163 {72, &ISystemSettingsServer::SetSleepSettings, "SetSleepSettings"}, 164 {72, C<&ISystemSettingsServer::SetSleepSettings>, "SetSleepSettings"},
164 {73, &ISystemSettingsServer::GetWirelessLanEnableFlag, "GetWirelessLanEnableFlag"}, 165 {73, C<&ISystemSettingsServer::GetWirelessLanEnableFlag>, "GetWirelessLanEnableFlag"},
165 {74, &ISystemSettingsServer::SetWirelessLanEnableFlag, "SetWirelessLanEnableFlag"}, 166 {74, C<&ISystemSettingsServer::SetWirelessLanEnableFlag>, "SetWirelessLanEnableFlag"},
166 {75, &ISystemSettingsServer::GetInitialLaunchSettings, "GetInitialLaunchSettings"}, 167 {75, C<&ISystemSettingsServer::GetInitialLaunchSettings>, "GetInitialLaunchSettings"},
167 {76, &ISystemSettingsServer::SetInitialLaunchSettings, "SetInitialLaunchSettings"}, 168 {76, C<&ISystemSettingsServer::SetInitialLaunchSettings>, "SetInitialLaunchSettings"},
168 {77, &ISystemSettingsServer::GetDeviceNickName, "GetDeviceNickName"}, 169 {77, C<&ISystemSettingsServer::GetDeviceNickName>, "GetDeviceNickName"},
169 {78, &ISystemSettingsServer::SetDeviceNickName, "SetDeviceNickName"}, 170 {78, C<&ISystemSettingsServer::SetDeviceNickName>, "SetDeviceNickName"},
170 {79, &ISystemSettingsServer::GetProductModel, "GetProductModel"}, 171 {79, C<&ISystemSettingsServer::GetProductModel>, "GetProductModel"},
171 {80, nullptr, "GetLdnChannel"}, 172 {80, nullptr, "GetLdnChannel"},
172 {81, nullptr, "SetLdnChannel"}, 173 {81, nullptr, "SetLdnChannel"},
173 {82, nullptr, "AcquireTelemetryDirtyFlagEventHandle"}, 174 {82, nullptr, "AcquireTelemetryDirtyFlagEventHandle"},
@@ -176,25 +177,25 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
176 {85, nullptr, "SetPtmBatteryLot"}, 177 {85, nullptr, "SetPtmBatteryLot"},
177 {86, nullptr, "GetPtmFuelGaugeParameter"}, 178 {86, nullptr, "GetPtmFuelGaugeParameter"},
178 {87, nullptr, "SetPtmFuelGaugeParameter"}, 179 {87, nullptr, "SetPtmFuelGaugeParameter"},
179 {88, &ISystemSettingsServer::GetBluetoothEnableFlag, "GetBluetoothEnableFlag"}, 180 {88, C<&ISystemSettingsServer::GetBluetoothEnableFlag>, "GetBluetoothEnableFlag"},
180 {89, &ISystemSettingsServer::SetBluetoothEnableFlag, "SetBluetoothEnableFlag"}, 181 {89, C<&ISystemSettingsServer::SetBluetoothEnableFlag>, "SetBluetoothEnableFlag"},
181 {90, &ISystemSettingsServer::GetMiiAuthorId, "GetMiiAuthorId"}, 182 {90, C<&ISystemSettingsServer::GetMiiAuthorId>, "GetMiiAuthorId"},
182 {91, nullptr, "SetShutdownRtcValue"}, 183 {91, nullptr, "SetShutdownRtcValue"},
183 {92, nullptr, "GetShutdownRtcValue"}, 184 {92, nullptr, "GetShutdownRtcValue"},
184 {93, nullptr, "AcquireFatalDirtyFlagEventHandle"}, 185 {93, nullptr, "AcquireFatalDirtyFlagEventHandle"},
185 {94, nullptr, "GetFatalDirtyFlags"}, 186 {94, nullptr, "GetFatalDirtyFlags"},
186 {95, &ISystemSettingsServer::GetAutoUpdateEnableFlag, "GetAutoUpdateEnableFlag"}, 187 {95, C<&ISystemSettingsServer::GetAutoUpdateEnableFlag>, "GetAutoUpdateEnableFlag"},
187 {96, &ISystemSettingsServer::SetAutoUpdateEnableFlag, "SetAutoUpdateEnableFlag"}, 188 {96, C<&ISystemSettingsServer::SetAutoUpdateEnableFlag>, "SetAutoUpdateEnableFlag"},
188 {97, nullptr, "GetNxControllerSettings"}, 189 {97, nullptr, "GetNxControllerSettings"},
189 {98, nullptr, "SetNxControllerSettings"}, 190 {98, nullptr, "SetNxControllerSettings"},
190 {99, &ISystemSettingsServer::GetBatteryPercentageFlag, "GetBatteryPercentageFlag"}, 191 {99, C<&ISystemSettingsServer::GetBatteryPercentageFlag>, "GetBatteryPercentageFlag"},
191 {100, &ISystemSettingsServer::SetBatteryPercentageFlag, "SetBatteryPercentageFlag"}, 192 {100, C<&ISystemSettingsServer::SetBatteryPercentageFlag>, "SetBatteryPercentageFlag"},
192 {101, nullptr, "GetExternalRtcResetFlag"}, 193 {101, nullptr, "GetExternalRtcResetFlag"},
193 {102, nullptr, "SetExternalRtcResetFlag"}, 194 {102, nullptr, "SetExternalRtcResetFlag"},
194 {103, nullptr, "GetUsbFullKeyEnableFlag"}, 195 {103, nullptr, "GetUsbFullKeyEnableFlag"},
195 {104, nullptr, "SetUsbFullKeyEnableFlag"}, 196 {104, nullptr, "SetUsbFullKeyEnableFlag"},
196 {105, &ISystemSettingsServer::SetExternalSteadyClockInternalOffset, "SetExternalSteadyClockInternalOffset"}, 197 {105, C<&ISystemSettingsServer::SetExternalSteadyClockInternalOffset>, "SetExternalSteadyClockInternalOffset"},
197 {106, &ISystemSettingsServer::GetExternalSteadyClockInternalOffset, "GetExternalSteadyClockInternalOffset"}, 198 {106, C<&ISystemSettingsServer::GetExternalSteadyClockInternalOffset>, "GetExternalSteadyClockInternalOffset"},
198 {107, nullptr, "GetBacklightSettingsEx"}, 199 {107, nullptr, "GetBacklightSettingsEx"},
199 {108, nullptr, "SetBacklightSettingsEx"}, 200 {108, nullptr, "SetBacklightSettingsEx"},
200 {109, nullptr, "GetHeadphoneVolumeWarningCount"}, 201 {109, nullptr, "GetHeadphoneVolumeWarningCount"},
@@ -208,14 +209,14 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
208 {117, nullptr, "GetHeadphoneVolumeUpdateFlag"}, 209 {117, nullptr, "GetHeadphoneVolumeUpdateFlag"},
209 {118, nullptr, "SetHeadphoneVolumeUpdateFlag"}, 210 {118, nullptr, "SetHeadphoneVolumeUpdateFlag"},
210 {119, nullptr, "NeedsToUpdateHeadphoneVolume"}, 211 {119, nullptr, "NeedsToUpdateHeadphoneVolume"},
211 {120, &ISystemSettingsServer::GetPushNotificationActivityModeOnSleep, "GetPushNotificationActivityModeOnSleep"}, 212 {120, C<&ISystemSettingsServer::GetPushNotificationActivityModeOnSleep>, "GetPushNotificationActivityModeOnSleep"},
212 {121, &ISystemSettingsServer::SetPushNotificationActivityModeOnSleep, "SetPushNotificationActivityModeOnSleep"}, 213 {121, C<&ISystemSettingsServer::SetPushNotificationActivityModeOnSleep>, "SetPushNotificationActivityModeOnSleep"},
213 {122, nullptr, "GetServiceDiscoveryControlSettings"}, 214 {122, nullptr, "GetServiceDiscoveryControlSettings"},
214 {123, nullptr, "SetServiceDiscoveryControlSettings"}, 215 {123, nullptr, "SetServiceDiscoveryControlSettings"},
215 {124, &ISystemSettingsServer::GetErrorReportSharePermission, "GetErrorReportSharePermission"}, 216 {124, C<&ISystemSettingsServer::GetErrorReportSharePermission>, "GetErrorReportSharePermission"},
216 {125, &ISystemSettingsServer::SetErrorReportSharePermission, "SetErrorReportSharePermission"}, 217 {125, C<&ISystemSettingsServer::SetErrorReportSharePermission>, "SetErrorReportSharePermission"},
217 {126, &ISystemSettingsServer::GetAppletLaunchFlags, "GetAppletLaunchFlags"}, 218 {126, C<&ISystemSettingsServer::GetAppletLaunchFlags>, "GetAppletLaunchFlags"},
218 {127, &ISystemSettingsServer::SetAppletLaunchFlags, "SetAppletLaunchFlags"}, 219 {127, C<&ISystemSettingsServer::SetAppletLaunchFlags>, "SetAppletLaunchFlags"},
219 {128, nullptr, "GetConsoleSixAxisSensorAccelerationBias"}, 220 {128, nullptr, "GetConsoleSixAxisSensorAccelerationBias"},
220 {129, nullptr, "SetConsoleSixAxisSensorAccelerationBias"}, 221 {129, nullptr, "SetConsoleSixAxisSensorAccelerationBias"},
221 {130, nullptr, "GetConsoleSixAxisSensorAngularVelocityBias"}, 222 {130, nullptr, "GetConsoleSixAxisSensorAngularVelocityBias"},
@@ -224,8 +225,8 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
224 {133, nullptr, "SetConsoleSixAxisSensorAccelerationGain"}, 225 {133, nullptr, "SetConsoleSixAxisSensorAccelerationGain"},
225 {134, nullptr, "GetConsoleSixAxisSensorAngularVelocityGain"}, 226 {134, nullptr, "GetConsoleSixAxisSensorAngularVelocityGain"},
226 {135, nullptr, "SetConsoleSixAxisSensorAngularVelocityGain"}, 227 {135, nullptr, "SetConsoleSixAxisSensorAngularVelocityGain"},
227 {136, &ISystemSettingsServer::GetKeyboardLayout, "GetKeyboardLayout"}, 228 {136, C<&ISystemSettingsServer::GetKeyboardLayout>, "GetKeyboardLayout"},
228 {137, &ISystemSettingsServer::SetKeyboardLayout, "SetKeyboardLayout"}, 229 {137, C<&ISystemSettingsServer::SetKeyboardLayout>, "SetKeyboardLayout"},
229 {138, nullptr, "GetWebInspectorFlag"}, 230 {138, nullptr, "GetWebInspectorFlag"},
230 {139, nullptr, "GetAllowedSslHosts"}, 231 {139, nullptr, "GetAllowedSslHosts"},
231 {140, nullptr, "GetHostFsMountPoint"}, 232 {140, nullptr, "GetHostFsMountPoint"},
@@ -238,10 +239,10 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
238 {147, nullptr, "GetConsoleSixAxisSensorAngularAcceleration"}, 239 {147, nullptr, "GetConsoleSixAxisSensorAngularAcceleration"},
239 {148, nullptr, "SetConsoleSixAxisSensorAngularAcceleration"}, 240 {148, nullptr, "SetConsoleSixAxisSensorAngularAcceleration"},
240 {149, nullptr, "GetRebootlessSystemUpdateVersion"}, 241 {149, nullptr, "GetRebootlessSystemUpdateVersion"},
241 {150, &ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime, "GetDeviceTimeZoneLocationUpdatedTime"}, 242 {150, C<&ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime>, "GetDeviceTimeZoneLocationUpdatedTime"},
242 {151, &ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime, "SetDeviceTimeZoneLocationUpdatedTime"}, 243 {151, C<&ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime>, "SetDeviceTimeZoneLocationUpdatedTime"},
243 {152, &ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime, "GetUserSystemClockAutomaticCorrectionUpdatedTime"}, 244 {152, C<&ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime>, "GetUserSystemClockAutomaticCorrectionUpdatedTime"},
244 {153, &ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime, "SetUserSystemClockAutomaticCorrectionUpdatedTime"}, 245 {153, C<&ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime>, "SetUserSystemClockAutomaticCorrectionUpdatedTime"},
245 {154, nullptr, "GetAccountOnlineStorageSettings"}, 246 {154, nullptr, "GetAccountOnlineStorageSettings"},
246 {155, nullptr, "SetAccountOnlineStorageSettings"}, 247 {155, nullptr, "SetAccountOnlineStorageSettings"},
247 {156, nullptr, "GetPctlReadyFlag"}, 248 {156, nullptr, "GetPctlReadyFlag"},
@@ -258,11 +259,11 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
258 {167, nullptr, "SetUsb30DeviceEnableFlag"}, 259 {167, nullptr, "SetUsb30DeviceEnableFlag"},
259 {168, nullptr, "GetThemeId"}, 260 {168, nullptr, "GetThemeId"},
260 {169, nullptr, "SetThemeId"}, 261 {169, nullptr, "SetThemeId"},
261 {170, &ISystemSettingsServer::GetChineseTraditionalInputMethod, "GetChineseTraditionalInputMethod"}, 262 {170, C<&ISystemSettingsServer::GetChineseTraditionalInputMethod>, "GetChineseTraditionalInputMethod"},
262 {171, nullptr, "SetChineseTraditionalInputMethod"}, 263 {171, nullptr, "SetChineseTraditionalInputMethod"},
263 {172, nullptr, "GetPtmCycleCountReliability"}, 264 {172, nullptr, "GetPtmCycleCountReliability"},
264 {173, nullptr, "SetPtmCycleCountReliability"}, 265 {173, nullptr, "SetPtmCycleCountReliability"},
265 {174, &ISystemSettingsServer::GetHomeMenuScheme, "GetHomeMenuScheme"}, 266 {174, C<&ISystemSettingsServer::GetHomeMenuScheme>, "GetHomeMenuScheme"},
266 {175, nullptr, "GetThemeSettings"}, 267 {175, nullptr, "GetThemeSettings"},
267 {176, nullptr, "SetThemeSettings"}, 268 {176, nullptr, "SetThemeSettings"},
268 {177, nullptr, "GetThemeKey"}, 269 {177, nullptr, "GetThemeKey"},
@@ -273,10 +274,10 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
273 {182, nullptr, "SetT"}, 274 {182, nullptr, "SetT"},
274 {183, nullptr, "GetPlatformRegion"}, 275 {183, nullptr, "GetPlatformRegion"},
275 {184, nullptr, "SetPlatformRegion"}, 276 {184, nullptr, "SetPlatformRegion"},
276 {185, &ISystemSettingsServer::GetHomeMenuSchemeModel, "GetHomeMenuSchemeModel"}, 277 {185, C<&ISystemSettingsServer::GetHomeMenuSchemeModel>, "GetHomeMenuSchemeModel"},
277 {186, nullptr, "GetMemoryUsageRateFlag"}, 278 {186, nullptr, "GetMemoryUsageRateFlag"},
278 {187, &ISystemSettingsServer::GetTouchScreenMode, "GetTouchScreenMode"}, 279 {187, C<&ISystemSettingsServer::GetTouchScreenMode>, "GetTouchScreenMode"},
279 {188, &ISystemSettingsServer::SetTouchScreenMode, "SetTouchScreenMode"}, 280 {188, C<&ISystemSettingsServer::SetTouchScreenMode>, "SetTouchScreenMode"},
280 {189, nullptr, "GetButtonConfigSettingsFull"}, 281 {189, nullptr, "GetButtonConfigSettingsFull"},
281 {190, nullptr, "SetButtonConfigSettingsFull"}, 282 {190, nullptr, "SetButtonConfigSettingsFull"},
282 {191, nullptr, "GetButtonConfigSettingsEmbedded"}, 283 {191, nullptr, "GetButtonConfigSettingsEmbedded"},
@@ -289,10 +290,10 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
289 {198, nullptr, "SetButtonConfigRegisteredSettingsEmbedded"}, 290 {198, nullptr, "SetButtonConfigRegisteredSettingsEmbedded"},
290 {199, nullptr, "GetButtonConfigRegisteredSettings"}, 291 {199, nullptr, "GetButtonConfigRegisteredSettings"},
291 {200, nullptr, "SetButtonConfigRegisteredSettings"}, 292 {200, nullptr, "SetButtonConfigRegisteredSettings"},
292 {201, &ISystemSettingsServer::GetFieldTestingFlag, "GetFieldTestingFlag"}, 293 {201, C<&ISystemSettingsServer::GetFieldTestingFlag>, "GetFieldTestingFlag"},
293 {202, nullptr, "SetFieldTestingFlag"}, 294 {202, nullptr, "SetFieldTestingFlag"},
294 {203, &ISystemSettingsServer::GetPanelCrcMode, "GetPanelCrcMode"}, 295 {203, C<&ISystemSettingsServer::GetPanelCrcMode>, "GetPanelCrcMode"},
295 {204, &ISystemSettingsServer::SetPanelCrcMode, "SetPanelCrcMode"}, 296 {204, C<&ISystemSettingsServer::SetPanelCrcMode>, "SetPanelCrcMode"},
296 {205, nullptr, "GetNxControllerSettingsEx"}, 297 {205, nullptr, "GetNxControllerSettingsEx"},
297 {206, nullptr, "SetNxControllerSettingsEx"}, 298 {206, nullptr, "SetNxControllerSettingsEx"},
298 {207, nullptr, "GetHearingProtectionSafeguardFlag"}, 299 {207, nullptr, "GetHearingProtectionSafeguardFlag"},
@@ -422,178 +423,134 @@ bool ISystemSettingsServer::StoreSettingsFile(std::filesystem::path& path, auto&
422 return true; 423 return true;
423} 424}
424 425
425void ISystemSettingsServer::SetLanguageCode(HLERequestContext& ctx) { 426Result ISystemSettingsServer::SetLanguageCode(LanguageCode language_code) {
426 IPC::RequestParser rp{ctx}; 427 LOG_INFO(Service_SET, "called, language_code={}", language_code);
427 m_system_settings.language_code = rp.PopEnum<LanguageCode>();
428 SetSaveNeeded();
429
430 LOG_INFO(Service_SET, "called, language_code={}", m_system_settings.language_code);
431 428
432 IPC::ResponseBuilder rb{ctx, 2}; 429 m_system_settings.language_code = language_code;
433 rb.Push(ResultSuccess); 430 SetSaveNeeded();
431 R_SUCCEED();
434} 432}
435 433
436void ISystemSettingsServer::GetFirmwareVersion(HLERequestContext& ctx) { 434Result ISystemSettingsServer::GetFirmwareVersion(
435 OutLargeData<FirmwareVersionFormat, BufferAttr_HipcPointer> out_firmware_data) {
437 LOG_DEBUG(Service_SET, "called"); 436 LOG_DEBUG(Service_SET, "called");
438 437
439 FirmwareVersionFormat firmware_data{}; 438 R_RETURN(GetFirmwareVersionImpl(*out_firmware_data, system, GetFirmwareVersionType::Version1));
440 const auto result =
441 GetFirmwareVersionImpl(firmware_data, system, GetFirmwareVersionType::Version1);
442
443 if (result.IsSuccess()) {
444 ctx.WriteBuffer(firmware_data);
445 }
446
447 IPC::ResponseBuilder rb{ctx, 2};
448 rb.Push(result);
449} 439}
450 440
451void ISystemSettingsServer::GetFirmwareVersion2(HLERequestContext& ctx) { 441Result ISystemSettingsServer::GetFirmwareVersion2(
442 OutLargeData<FirmwareVersionFormat, BufferAttr_HipcPointer> out_firmware_data) {
452 LOG_DEBUG(Service_SET, "called"); 443 LOG_DEBUG(Service_SET, "called");
453 444
454 FirmwareVersionFormat firmware_data{}; 445 R_RETURN(GetFirmwareVersionImpl(*out_firmware_data, system, GetFirmwareVersionType::Version2));
455 const auto result =
456 GetFirmwareVersionImpl(firmware_data, system, GetFirmwareVersionType::Version2);
457
458 if (result.IsSuccess()) {
459 ctx.WriteBuffer(firmware_data);
460 }
461
462 IPC::ResponseBuilder rb{ctx, 2};
463 rb.Push(result);
464} 446}
465 447
466void ISystemSettingsServer::GetExternalSteadyClockSourceId(HLERequestContext& ctx) { 448Result ISystemSettingsServer::GetLockScreenFlag(Out<bool> out_lock_screen_flag) {
467 LOG_INFO(Service_SET, "called"); 449 LOG_INFO(Service_SET, "called, lock_screen_flag={}", m_system_settings.lock_screen_flag);
468
469 Common::UUID id{};
470 const auto res = GetExternalSteadyClockSourceId(id);
471 450
472 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Common::UUID) / sizeof(u32)}; 451 *out_lock_screen_flag = m_system_settings.lock_screen_flag;
473 rb.Push(res); 452 R_SUCCEED();
474 rb.PushRaw(id);
475} 453}
476 454
477void ISystemSettingsServer::SetExternalSteadyClockSourceId(HLERequestContext& ctx) { 455Result ISystemSettingsServer::SetLockScreenFlag(bool lock_screen_flag) {
478 LOG_INFO(Service_SET, "called"); 456 LOG_INFO(Service_SET, "called, lock_screen_flag={}", lock_screen_flag);
479 457
480 IPC::RequestParser rp{ctx}; 458 m_system_settings.lock_screen_flag = lock_screen_flag;
481 const auto id{rp.PopRaw<Common::UUID>()}; 459 SetSaveNeeded();
460 R_SUCCEED();
461}
482 462
483 const auto res = SetExternalSteadyClockSourceId(id); 463Result ISystemSettingsServer::GetExternalSteadyClockSourceId(
464 Out<Common::UUID> out_clock_source_id) {
465 LOG_INFO(Service_SET, "called, clock_source_id={}",
466 m_private_settings.external_clock_source_id.FormattedString());
484 467
485 IPC::ResponseBuilder rb{ctx, 2}; 468 *out_clock_source_id = m_private_settings.external_clock_source_id;
486 rb.Push(res); 469 R_SUCCEED();
487} 470}
488 471
489void ISystemSettingsServer::GetUserSystemClockContext(HLERequestContext& ctx) { 472Result ISystemSettingsServer::SetExternalSteadyClockSourceId(const Common::UUID& clock_source_id) {
490 LOG_INFO(Service_SET, "called"); 473 LOG_INFO(Service_SET, "called, clock_source_id={}", clock_source_id.FormattedString());
491
492 Service::PSC::Time::SystemClockContext context{};
493 const auto res = GetUserSystemClockContext(context);
494 474
495 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::SystemClockContext) / sizeof(u32)}; 475 m_private_settings.external_clock_source_id = clock_source_id;
496 rb.Push(res); 476 SetSaveNeeded();
497 rb.PushRaw(context); 477 R_SUCCEED();
498} 478}
499 479
500void ISystemSettingsServer::SetUserSystemClockContext(HLERequestContext& ctx) { 480Result ISystemSettingsServer::GetUserSystemClockContext(
481 Out<Service::PSC::Time::SystemClockContext> out_clock_context) {
501 LOG_INFO(Service_SET, "called"); 482 LOG_INFO(Service_SET, "called");
502 483
503 IPC::RequestParser rp{ctx}; 484 *out_clock_context = m_system_settings.user_system_clock_context;
504 const auto context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()}; 485 R_SUCCEED();
505
506 const auto res = SetUserSystemClockContext(context);
507
508 IPC::ResponseBuilder rb{ctx, 2};
509 rb.Push(res);
510} 486}
511 487
512void ISystemSettingsServer::GetLockScreenFlag(HLERequestContext& ctx) { 488Result ISystemSettingsServer::SetUserSystemClockContext(
513 LOG_INFO(Service_SET, "called, lock_screen_flag={}", m_system_settings.lock_screen_flag); 489 const Service::PSC::Time::SystemClockContext& clock_context) {
514 490 LOG_INFO(Service_SET, "called");
515 IPC::ResponseBuilder rb{ctx, 3};
516 rb.Push(ResultSuccess);
517 rb.Push(m_system_settings.lock_screen_flag);
518}
519 491
520void ISystemSettingsServer::SetLockScreenFlag(HLERequestContext& ctx) { 492 m_system_settings.user_system_clock_context = clock_context;
521 IPC::RequestParser rp{ctx};
522 m_system_settings.lock_screen_flag = rp.Pop<bool>();
523 SetSaveNeeded(); 493 SetSaveNeeded();
524 494 R_SUCCEED();
525 LOG_INFO(Service_SET, "called, lock_screen_flag={}", m_system_settings.lock_screen_flag);
526
527 IPC::ResponseBuilder rb{ctx, 2};
528 rb.Push(ResultSuccess);
529} 495}
530 496
531void ISystemSettingsServer::GetAccountSettings(HLERequestContext& ctx) { 497Result ISystemSettingsServer::GetAccountSettings(Out<AccountSettings> out_account_settings) {
532 LOG_INFO(Service_SET, "called"); 498 LOG_INFO(Service_SET, "called, account_settings_flags={}",
499 m_system_settings.account_settings.flags);
533 500
534 IPC::ResponseBuilder rb{ctx, 3}; 501 *out_account_settings = m_system_settings.account_settings;
535 rb.Push(ResultSuccess); 502 R_SUCCEED();
536 rb.PushRaw(m_system_settings.account_settings);
537} 503}
538 504
539void ISystemSettingsServer::SetAccountSettings(HLERequestContext& ctx) { 505Result ISystemSettingsServer::SetAccountSettings(AccountSettings account_settings) {
540 IPC::RequestParser rp{ctx}; 506 LOG_INFO(Service_SET, "called, account_settings_flags={}", account_settings.flags);
541 m_system_settings.account_settings = rp.PopRaw<AccountSettings>();
542 SetSaveNeeded();
543
544 LOG_INFO(Service_SET, "called, account_settings_flags={}",
545 m_system_settings.account_settings.flags);
546 507
547 IPC::ResponseBuilder rb{ctx, 2}; 508 m_system_settings.account_settings = account_settings;
548 rb.Push(ResultSuccess); 509 SetSaveNeeded();
510 R_SUCCEED();
549} 511}
550 512
551void ISystemSettingsServer::GetEulaVersions(HLERequestContext& ctx) { 513Result ISystemSettingsServer::GetEulaVersions(
514 Out<s32> out_count, OutArray<EulaVersion, BufferAttr_HipcMapAlias> out_eula_versions) {
552 LOG_INFO(Service_SET, "called, elements={}", m_system_settings.eula_version_count); 515 LOG_INFO(Service_SET, "called, elements={}", m_system_settings.eula_version_count);
553 516
554 ctx.WriteBuffer(m_system_settings.eula_versions); 517 *out_count =
555 518 std::min(m_system_settings.eula_version_count, static_cast<s32>(out_eula_versions.size()));
556 IPC::ResponseBuilder rb{ctx, 3}; 519 memcpy(out_eula_versions.data(), m_system_settings.eula_versions.data(),
557 rb.Push(ResultSuccess); 520 static_cast<std::size_t>(*out_count) * sizeof(EulaVersion));
558 rb.Push(m_system_settings.eula_version_count); 521 R_SUCCEED();
559} 522}
560 523
561void ISystemSettingsServer::SetEulaVersions(HLERequestContext& ctx) { 524Result ISystemSettingsServer::SetEulaVersions(
562 const auto elements = ctx.GetReadBufferNumElements<EulaVersion>(); 525 InArray<EulaVersion, BufferAttr_HipcMapAlias> eula_versions) {
563 const auto buffer_data = ctx.ReadBuffer(); 526 LOG_INFO(Service_SET, "called, elements={}", eula_versions.size());
564 527
565 LOG_INFO(Service_SET, "called, elements={}", elements); 528 ASSERT(eula_versions.size() <= m_system_settings.eula_versions.size());
566 ASSERT(elements <= m_system_settings.eula_versions.size());
567 529
568 m_system_settings.eula_version_count = static_cast<u32>(elements); 530 m_system_settings.eula_version_count = static_cast<s32>(eula_versions.size());
569 std::memcpy(&m_system_settings.eula_versions, buffer_data.data(), 531 std::memcpy(m_system_settings.eula_versions.data(), eula_versions.data(),
570 sizeof(EulaVersion) * elements); 532 eula_versions.size() * sizeof(EulaVersion));
571 SetSaveNeeded(); 533 SetSaveNeeded();
572 534 R_SUCCEED();
573 IPC::ResponseBuilder rb{ctx, 2};
574 rb.Push(ResultSuccess);
575} 535}
576 536
577void ISystemSettingsServer::GetColorSetId(HLERequestContext& ctx) { 537Result ISystemSettingsServer::GetColorSetId(Out<ColorSet> out_color_set_id) {
578 LOG_DEBUG(Service_SET, "called, color_set=", m_system_settings.color_set_id); 538 LOG_DEBUG(Service_SET, "called, color_set=", m_system_settings.color_set_id);
579 539
580 IPC::ResponseBuilder rb{ctx, 3}; 540 *out_color_set_id = m_system_settings.color_set_id;
581 rb.Push(ResultSuccess); 541 R_SUCCEED();
582 rb.PushEnum(m_system_settings.color_set_id);
583} 542}
584 543
585void ISystemSettingsServer::SetColorSetId(HLERequestContext& ctx) { 544Result ISystemSettingsServer::SetColorSetId(ColorSet color_set_id) {
586 IPC::RequestParser rp{ctx}; 545 LOG_DEBUG(Service_SET, "called, color_set={}", color_set_id);
587 m_system_settings.color_set_id = rp.PopEnum<ColorSet>();
588 SetSaveNeeded();
589
590 LOG_DEBUG(Service_SET, "called, color_set={}", m_system_settings.color_set_id);
591 546
592 IPC::ResponseBuilder rb{ctx, 2}; 547 m_system_settings.color_set_id = color_set_id;
593 rb.Push(ResultSuccess); 548 SetSaveNeeded();
549 R_SUCCEED();
594} 550}
595 551
596void ISystemSettingsServer::GetNotificationSettings(HLERequestContext& ctx) { 552Result ISystemSettingsServer::GetNotificationSettings(
553 Out<NotificationSettings> out_notification_settings) {
597 LOG_INFO(Service_SET, "called, flags={}, volume={}, head_time={}:{}, tailt_time={}:{}", 554 LOG_INFO(Service_SET, "called, flags={}, volume={}, head_time={}:{}, tailt_time={}:{}",
598 m_system_settings.notification_settings.flags.raw, 555 m_system_settings.notification_settings.flags.raw,
599 m_system_settings.notification_settings.volume, 556 m_system_settings.notification_settings.volume,
@@ -602,77 +559,67 @@ void ISystemSettingsServer::GetNotificationSettings(HLERequestContext& ctx) {
602 m_system_settings.notification_settings.stop_time.hour, 559 m_system_settings.notification_settings.stop_time.hour,
603 m_system_settings.notification_settings.stop_time.minute); 560 m_system_settings.notification_settings.stop_time.minute);
604 561
605 IPC::ResponseBuilder rb{ctx, 8}; 562 *out_notification_settings = m_system_settings.notification_settings;
606 rb.Push(ResultSuccess); 563 R_SUCCEED();
607 rb.PushRaw(m_system_settings.notification_settings);
608} 564}
609 565
610void ISystemSettingsServer::SetNotificationSettings(HLERequestContext& ctx) { 566Result ISystemSettingsServer::SetNotificationSettings(
611 IPC::RequestParser rp{ctx}; 567 const NotificationSettings& notification_settings) {
612 m_system_settings.notification_settings = rp.PopRaw<NotificationSettings>();
613 SetSaveNeeded();
614
615 LOG_INFO(Service_SET, "called, flags={}, volume={}, head_time={}:{}, tailt_time={}:{}", 568 LOG_INFO(Service_SET, "called, flags={}, volume={}, head_time={}:{}, tailt_time={}:{}",
616 m_system_settings.notification_settings.flags.raw, 569 notification_settings.flags.raw, notification_settings.volume,
617 m_system_settings.notification_settings.volume, 570 notification_settings.start_time.hour, notification_settings.start_time.minute,
618 m_system_settings.notification_settings.start_time.hour, 571 notification_settings.stop_time.hour, notification_settings.stop_time.minute);
619 m_system_settings.notification_settings.start_time.minute,
620 m_system_settings.notification_settings.stop_time.hour,
621 m_system_settings.notification_settings.stop_time.minute);
622 572
623 IPC::ResponseBuilder rb{ctx, 2}; 573 m_system_settings.notification_settings = notification_settings;
624 rb.Push(ResultSuccess); 574 SetSaveNeeded();
575 R_SUCCEED();
625} 576}
626 577
627void ISystemSettingsServer::GetAccountNotificationSettings(HLERequestContext& ctx) { 578Result ISystemSettingsServer::GetAccountNotificationSettings(
579 Out<s32> out_count, OutArray<AccountNotificationSettings, BufferAttr_HipcMapAlias>
580 out_account_notification_settings) {
628 LOG_INFO(Service_SET, "called, elements={}", 581 LOG_INFO(Service_SET, "called, elements={}",
629 m_system_settings.account_notification_settings_count); 582 m_system_settings.account_notification_settings_count);
630 583
631 ctx.WriteBuffer(m_system_settings.account_notification_settings); 584 *out_count = std::min(m_system_settings.account_notification_settings_count,
585 static_cast<s32>(out_account_notification_settings.size()));
586 memcpy(out_account_notification_settings.data(),
587 m_system_settings.account_notification_settings.data(),
588 static_cast<std::size_t>(*out_count) * sizeof(AccountNotificationSettings));
632 589
633 IPC::ResponseBuilder rb{ctx, 3}; 590 R_SUCCEED();
634 rb.Push(ResultSuccess);
635 rb.Push(m_system_settings.account_notification_settings_count);
636} 591}
637 592
638void ISystemSettingsServer::SetAccountNotificationSettings(HLERequestContext& ctx) { 593Result ISystemSettingsServer::SetAccountNotificationSettings(
639 const auto elements = ctx.GetReadBufferNumElements<AccountNotificationSettings>(); 594 InArray<AccountNotificationSettings, BufferAttr_HipcMapAlias> account_notification_settings) {
640 const auto buffer_data = ctx.ReadBuffer(); 595 LOG_INFO(Service_SET, "called, elements={}", account_notification_settings.size());
641
642 LOG_INFO(Service_SET, "called, elements={}", elements);
643 596
644 ASSERT(elements <= m_system_settings.account_notification_settings.size()); 597 ASSERT(account_notification_settings.size() <=
598 m_system_settings.account_notification_settings.size());
645 599
646 m_system_settings.account_notification_settings_count = static_cast<u32>(elements); 600 m_system_settings.account_notification_settings_count =
647 std::memcpy(&m_system_settings.account_notification_settings, buffer_data.data(), 601 static_cast<s32>(account_notification_settings.size());
648 elements * sizeof(AccountNotificationSettings)); 602 std::memcpy(m_system_settings.account_notification_settings.data(),
603 account_notification_settings.data(),
604 account_notification_settings.size() * sizeof(AccountNotificationSettings));
649 SetSaveNeeded(); 605 SetSaveNeeded();
650 606 R_SUCCEED();
651 IPC::ResponseBuilder rb{ctx, 2};
652 rb.Push(ResultSuccess);
653} 607}
654 608
655void ISystemSettingsServer::GetVibrationMasterVolume(HLERequestContext& ctx) { 609Result ISystemSettingsServer::GetVibrationMasterVolume(Out<f32> vibration_master_volume) {
656 f32 vibration_master_volume = {}; 610 LOG_INFO(Service_SET, "called, vibration_master_volume={}",
657 const auto result = GetVibrationMasterVolume(vibration_master_volume); 611 m_system_settings.vibration_master_volume);
658 612
659 LOG_INFO(Service_SET, "called, master_volume={}", vibration_master_volume); 613 *vibration_master_volume = m_system_settings.vibration_master_volume;
660 614 R_SUCCEED();
661 IPC::ResponseBuilder rb{ctx, 3};
662 rb.Push(result);
663 rb.Push(vibration_master_volume);
664} 615}
665 616
666void ISystemSettingsServer::SetVibrationMasterVolume(HLERequestContext& ctx) { 617Result ISystemSettingsServer::SetVibrationMasterVolume(f32 vibration_master_volume) {
667 IPC::RequestParser rp{ctx}; 618 LOG_INFO(Service_SET, "called, vibration_master_volume={}", vibration_master_volume);
668 const auto vibration_master_volume = rp.PopRaw<f32>();
669
670 LOG_INFO(Service_SET, "called, elements={}", m_system_settings.vibration_master_volume);
671 619
672 const auto result = SetVibrationMasterVolume(vibration_master_volume); 620 m_system_settings.vibration_master_volume = vibration_master_volume;
673 621 SetSaveNeeded();
674 IPC::ResponseBuilder rb{ctx, 2}; 622 R_SUCCEED();
675 rb.Push(result);
676} 623}
677 624
678// FIXME: implement support for the real system_settings.ini 625// FIXME: implement support for the real system_settings.ini
@@ -734,55 +681,38 @@ static Settings GetSettings() {
734 return ret; 681 return ret;
735} 682}
736 683
737void ISystemSettingsServer::GetSettingsItemValueSize(HLERequestContext& ctx) { 684Result ISystemSettingsServer::GetSettingsItemValueSize(
738 LOG_DEBUG(Service_SET, "called"); 685 Out<u64> out_size, InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
686 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer) {
687 const std::string setting_category{Common::StringFromBuffer(*setting_category_buffer)};
688 const std::string setting_name{Common::StringFromBuffer(*setting_name_buffer)};
739 689
740 // The category of the setting. This corresponds to the top-level keys of 690 LOG_DEBUG(Service_SET, "called, category={}, name={}", setting_category, setting_name);
741 // system_settings.ini.
742 const auto setting_category_buf{ctx.ReadBuffer(0)};
743 const std::string setting_category{Common::StringFromBuffer(setting_category_buf)};
744 691
745 // The name of the setting. This corresponds to the second-level keys of 692 *out_size = 0;
746 // system_settings.ini.
747 const auto setting_name_buf{ctx.ReadBuffer(1)};
748 const std::string setting_name{Common::StringFromBuffer(setting_name_buf)};
749 693
750 auto settings{GetSettings()}; 694 auto settings{GetSettings()};
751 u64 response_size{0};
752
753 if (settings.contains(setting_category) && settings[setting_category].contains(setting_name)) { 695 if (settings.contains(setting_category) && settings[setting_category].contains(setting_name)) {
754 response_size = settings[setting_category][setting_name].size(); 696 *out_size = settings[setting_category][setting_name].size();
755 } 697 }
756 698
757 IPC::ResponseBuilder rb{ctx, 4}; 699 R_UNLESS(*out_size != 0, ResultUnknown);
758 rb.Push(response_size == 0 ? ResultUnknown : ResultSuccess); 700 R_SUCCEED();
759 rb.Push(response_size);
760} 701}
761 702
762void ISystemSettingsServer::GetSettingsItemValue(HLERequestContext& ctx) { 703Result ISystemSettingsServer::GetSettingsItemValue(
763 // The category of the setting. This corresponds to the top-level keys of 704 OutBuffer<BufferAttr_HipcMapAlias> out_data,
764 // system_settings.ini. 705 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
765 const auto setting_category_buf{ctx.ReadBuffer(0)}; 706 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer) {
766 const std::string setting_category{Common::StringFromBuffer(setting_category_buf)}; 707 const std::string setting_category{Common::StringFromBuffer(*setting_category_buffer)};
767 708 const std::string setting_name{Common::StringFromBuffer(*setting_name_buffer)};
768 // The name of the setting. This corresponds to the second-level keys of
769 // system_settings.ini.
770 const auto setting_name_buf{ctx.ReadBuffer(1)};
771 const std::string setting_name{Common::StringFromBuffer(setting_name_buf)};
772 709
773 std::vector<u8> value; 710 LOG_INFO(Service_SET, "called, category={}, name={}", setting_category, setting_name);
774 auto response = GetSettingsItemValue(value, setting_category, setting_name);
775 711
776 LOG_INFO(Service_SET, "called. category={}, name={} -- res=0x{:X}", setting_category, 712 R_RETURN(GetSettingsItemValueImpl(out_data, setting_category, setting_name));
777 setting_name, response.raw);
778
779 ctx.WriteBuffer(value.data(), value.size());
780
781 IPC::ResponseBuilder rb{ctx, 2};
782 rb.Push(response);
783} 713}
784 714
785void ISystemSettingsServer::GetTvSettings(HLERequestContext& ctx) { 715Result ISystemSettingsServer::GetTvSettings(Out<TvSettings> out_tv_settings) {
786 LOG_INFO(Service_SET, 716 LOG_INFO(Service_SET,
787 "called, flags={}, cmu_mode={}, contrast_ratio={}, hdmi_content_type={}, " 717 "called, flags={}, cmu_mode={}, contrast_ratio={}, hdmi_content_type={}, "
788 "rgb_range={}, tv_gama={}, tv_resolution={}, tv_underscan={}", 718 "rgb_range={}, tv_gama={}, tv_resolution={}, tv_underscan={}",
@@ -793,371 +723,335 @@ void ISystemSettingsServer::GetTvSettings(HLERequestContext& ctx) {
793 m_system_settings.tv_settings.tv_resolution, 723 m_system_settings.tv_settings.tv_resolution,
794 m_system_settings.tv_settings.tv_underscan); 724 m_system_settings.tv_settings.tv_underscan);
795 725
796 IPC::ResponseBuilder rb{ctx, 10}; 726 *out_tv_settings = m_system_settings.tv_settings;
797 rb.Push(ResultSuccess); 727 R_SUCCEED();
798 rb.PushRaw(m_system_settings.tv_settings);
799} 728}
800 729
801void ISystemSettingsServer::SetTvSettings(HLERequestContext& ctx) { 730Result ISystemSettingsServer::SetTvSettings(TvSettings tv_settings) {
802 IPC::RequestParser rp{ctx};
803 m_system_settings.tv_settings = rp.PopRaw<TvSettings>();
804 SetSaveNeeded();
805 731
806 LOG_INFO(Service_SET, 732 LOG_INFO(Service_SET,
807 "called, flags={}, cmu_mode={}, contrast_ratio={}, hdmi_content_type={}, " 733 "called, flags={}, cmu_mode={}, contrast_ratio={}, hdmi_content_type={}, "
808 "rgb_range={}, tv_gama={}, tv_resolution={}, tv_underscan={}", 734 "rgb_range={}, tv_gama={}, tv_resolution={}, tv_underscan={}",
809 m_system_settings.tv_settings.flags.raw, m_system_settings.tv_settings.cmu_mode, 735 tv_settings.flags.raw, tv_settings.cmu_mode, tv_settings.contrast_ratio,
810 m_system_settings.tv_settings.contrast_ratio, 736 tv_settings.hdmi_content_type, tv_settings.rgb_range, tv_settings.tv_gama,
811 m_system_settings.tv_settings.hdmi_content_type, 737 tv_settings.tv_resolution, tv_settings.tv_underscan);
812 m_system_settings.tv_settings.rgb_range, m_system_settings.tv_settings.tv_gama,
813 m_system_settings.tv_settings.tv_resolution,
814 m_system_settings.tv_settings.tv_underscan);
815 738
816 IPC::ResponseBuilder rb{ctx, 2}; 739 m_system_settings.tv_settings = tv_settings;
817 rb.Push(ResultSuccess); 740 SetSaveNeeded();
741 R_SUCCEED();
818} 742}
819 743
820void ISystemSettingsServer::GetAudioOutputMode(HLERequestContext& ctx) { 744Result ISystemSettingsServer::GetAudioOutputMode(Out<AudioOutputMode> out_output_mode,
821 IPC::RequestParser rp{ctx}; 745 AudioOutputModeTarget target) {
822 const auto target{rp.PopEnum<AudioOutputModeTarget>()}; 746 switch (target) {
823 747 case AudioOutputModeTarget::Hdmi:
824 AudioOutputMode output_mode{}; 748 *out_output_mode = m_system_settings.audio_output_mode_hdmi;
825 const auto result = GetAudioOutputMode(output_mode, target); 749 break;
826 750 case AudioOutputModeTarget::Speaker:
827 LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode); 751 *out_output_mode = m_system_settings.audio_output_mode_speaker;
752 break;
753 case AudioOutputModeTarget::Headphone:
754 *out_output_mode = m_system_settings.audio_output_mode_headphone;
755 break;
756 case AudioOutputModeTarget::Type3:
757 *out_output_mode = m_system_settings.audio_output_mode_type3;
758 break;
759 case AudioOutputModeTarget::Type4:
760 *out_output_mode = m_system_settings.audio_output_mode_type4;
761 break;
762 default:
763 LOG_ERROR(Service_SET, "Invalid audio output mode target {}", target);
764 }
828 765
829 IPC::ResponseBuilder rb{ctx, 3}; 766 LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, *out_output_mode);
830 rb.Push(result); 767 R_SUCCEED();
831 rb.PushEnum(output_mode);
832} 768}
833 769
834void ISystemSettingsServer::SetAudioOutputMode(HLERequestContext& ctx) { 770Result ISystemSettingsServer::SetAudioOutputMode(AudioOutputModeTarget target,
835 IPC::RequestParser rp{ctx}; 771 AudioOutputMode output_mode) {
836 const auto target{rp.PopEnum<AudioOutputModeTarget>()};
837 const auto output_mode{rp.PopEnum<AudioOutputMode>()};
838
839 const auto result = SetAudioOutputMode(target, output_mode);
840
841 LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode); 772 LOG_INFO(Service_SET, "called, target={}, output_mode={}", target, output_mode);
842 773
843 IPC::ResponseBuilder rb{ctx, 2}; 774 switch (target) {
844 rb.Push(result); 775 case AudioOutputModeTarget::Hdmi:
776 m_system_settings.audio_output_mode_hdmi = output_mode;
777 break;
778 case AudioOutputModeTarget::Speaker:
779 m_system_settings.audio_output_mode_speaker = output_mode;
780 break;
781 case AudioOutputModeTarget::Headphone:
782 m_system_settings.audio_output_mode_headphone = output_mode;
783 break;
784 case AudioOutputModeTarget::Type3:
785 m_system_settings.audio_output_mode_type3 = output_mode;
786 break;
787 case AudioOutputModeTarget::Type4:
788 m_system_settings.audio_output_mode_type4 = output_mode;
789 break;
790 default:
791 LOG_ERROR(Service_SET, "Invalid audio output mode target {}", target);
792 }
793
794 SetSaveNeeded();
795 R_SUCCEED();
845} 796}
846 797
847void ISystemSettingsServer::GetSpeakerAutoMuteFlag(HLERequestContext& ctx) { 798Result ISystemSettingsServer::GetSpeakerAutoMuteFlag(
799 Out<bool> out_force_mute_on_headphone_removed) {
848 LOG_INFO(Service_SET, "called, force_mute_on_headphone_removed={}", 800 LOG_INFO(Service_SET, "called, force_mute_on_headphone_removed={}",
849 m_system_settings.force_mute_on_headphone_removed); 801 m_system_settings.force_mute_on_headphone_removed);
850 802
851 IPC::ResponseBuilder rb{ctx, 3}; 803 *out_force_mute_on_headphone_removed = m_system_settings.force_mute_on_headphone_removed;
852 rb.Push(ResultSuccess); 804 R_SUCCEED();
853 rb.PushRaw(m_system_settings.force_mute_on_headphone_removed);
854} 805}
855 806
856void ISystemSettingsServer::SetSpeakerAutoMuteFlag(HLERequestContext& ctx) { 807Result ISystemSettingsServer::SetSpeakerAutoMuteFlag(bool force_mute_on_headphone_removed) {
857 IPC::RequestParser rp{ctx};
858 m_system_settings.force_mute_on_headphone_removed = rp.PopRaw<bool>();
859 SetSaveNeeded();
860
861 LOG_INFO(Service_SET, "called, force_mute_on_headphone_removed={}", 808 LOG_INFO(Service_SET, "called, force_mute_on_headphone_removed={}",
862 m_system_settings.force_mute_on_headphone_removed); 809 force_mute_on_headphone_removed);
863 810
864 IPC::ResponseBuilder rb{ctx, 2}; 811 m_system_settings.force_mute_on_headphone_removed = force_mute_on_headphone_removed;
865 rb.Push(ResultSuccess); 812 SetSaveNeeded();
813 R_SUCCEED();
866} 814}
867 815
868void ISystemSettingsServer::GetQuestFlag(HLERequestContext& ctx) { 816Result ISystemSettingsServer::GetQuestFlag(Out<QuestFlag> out_quest_flag) {
869 LOG_INFO(Service_SET, "called, quest_flag={}", m_system_settings.quest_flag); 817 LOG_INFO(Service_SET, "called, quest_flag={}", m_system_settings.quest_flag);
870 818
871 IPC::ResponseBuilder rb{ctx, 3}; 819 *out_quest_flag = m_system_settings.quest_flag;
872 rb.Push(ResultSuccess); 820 R_SUCCEED();
873 rb.PushEnum(m_system_settings.quest_flag);
874} 821}
875 822
876void ISystemSettingsServer::SetQuestFlag(HLERequestContext& ctx) { 823Result ISystemSettingsServer::SetQuestFlag(QuestFlag quest_flag) {
877 IPC::RequestParser rp{ctx}; 824 LOG_INFO(Service_SET, "called, quest_flag={}", quest_flag);
878 m_system_settings.quest_flag = rp.PopEnum<QuestFlag>();
879 SetSaveNeeded();
880 825
881 LOG_INFO(Service_SET, "called, quest_flag={}", m_system_settings.quest_flag); 826 m_system_settings.quest_flag = quest_flag;
882 827 SetSaveNeeded();
883 IPC::ResponseBuilder rb{ctx, 2}; 828 R_SUCCEED();
884 rb.Push(ResultSuccess);
885} 829}
886 830
887void ISystemSettingsServer::GetDeviceTimeZoneLocationName(HLERequestContext& ctx) { 831Result ISystemSettingsServer::GetDeviceTimeZoneLocationName(
832 Out<Service::PSC::Time::LocationName> out_name) {
888 LOG_INFO(Service_SET, "called"); 833 LOG_INFO(Service_SET, "called");
889 834
890 Service::PSC::Time::LocationName name{}; 835 *out_name = m_system_settings.device_time_zone_location_name;
891 const auto res = GetDeviceTimeZoneLocationName(name); 836 R_SUCCEED();
892
893 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::LocationName) / sizeof(u32)};
894 rb.Push(res);
895 rb.PushRaw<Service::PSC::Time::LocationName>(name);
896} 837}
897 838
898void ISystemSettingsServer::SetDeviceTimeZoneLocationName(HLERequestContext& ctx) { 839Result ISystemSettingsServer::SetDeviceTimeZoneLocationName(
840 const Service::PSC::Time::LocationName& name) {
899 LOG_INFO(Service_SET, "called"); 841 LOG_INFO(Service_SET, "called");
900 842
901 IPC::RequestParser rp{ctx}; 843 m_system_settings.device_time_zone_location_name = name;
902 auto name{rp.PopRaw<Service::PSC::Time::LocationName>()};
903
904 const auto res = SetDeviceTimeZoneLocationName(name);
905
906 IPC::ResponseBuilder rb{ctx, 2};
907 rb.Push(res);
908}
909
910void ISystemSettingsServer::SetRegionCode(HLERequestContext& ctx) {
911 IPC::RequestParser rp{ctx};
912 m_system_settings.region_code = rp.PopEnum<SystemRegionCode>();
913 SetSaveNeeded(); 844 SetSaveNeeded();
914 845 R_SUCCEED();
915 LOG_INFO(Service_SET, "called, region_code={}", m_system_settings.region_code);
916
917 IPC::ResponseBuilder rb{ctx, 2};
918 rb.Push(ResultSuccess);
919} 846}
920 847
921void ISystemSettingsServer::GetNetworkSystemClockContext(HLERequestContext& ctx) { 848Result ISystemSettingsServer::SetRegionCode(SystemRegionCode region_code) {
922 LOG_INFO(Service_SET, "called"); 849 LOG_INFO(Service_SET, "called, region_code={}", region_code);
923 850
924 Service::PSC::Time::SystemClockContext context{}; 851 m_system_settings.region_code = region_code;
925 const auto res = GetNetworkSystemClockContext(context); 852 SetSaveNeeded();
926 853 R_SUCCEED();
927 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::SystemClockContext) / sizeof(u32)};
928 rb.Push(res);
929 rb.PushRaw(context);
930} 854}
931 855
932void ISystemSettingsServer::SetNetworkSystemClockContext(HLERequestContext& ctx) { 856Result ISystemSettingsServer::GetNetworkSystemClockContext(
857 Out<Service::PSC::Time::SystemClockContext> out_context) {
933 LOG_INFO(Service_SET, "called"); 858 LOG_INFO(Service_SET, "called");
934 859
935 IPC::RequestParser rp{ctx}; 860 *out_context = m_system_settings.network_system_clock_context;
936 const auto context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()}; 861 R_SUCCEED();
937
938 const auto res = SetNetworkSystemClockContext(context);
939
940 IPC::ResponseBuilder rb{ctx, 2};
941 rb.Push(res);
942} 862}
943 863
944void ISystemSettingsServer::IsUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx) { 864Result ISystemSettingsServer::SetNetworkSystemClockContext(
865 const Service::PSC::Time::SystemClockContext& context) {
945 LOG_INFO(Service_SET, "called"); 866 LOG_INFO(Service_SET, "called");
946 867
947 bool enabled{}; 868 m_system_settings.network_system_clock_context = context;
948 const auto res = IsUserSystemClockAutomaticCorrectionEnabled(enabled); 869 SetSaveNeeded();
949 870 R_SUCCEED();
950 IPC::ResponseBuilder rb{ctx, 3};
951 rb.Push(res);
952 rb.PushRaw(enabled);
953} 871}
954 872
955void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx) { 873Result ISystemSettingsServer::IsUserSystemClockAutomaticCorrectionEnabled(
956 LOG_INFO(Service_SET, "called"); 874 Out<bool> out_automatic_correction_enabled) {
875 LOG_INFO(Service_SET, "called, out_automatic_correction_enabled={}",
876 m_system_settings.user_system_clock_automatic_correction_enabled);
957 877
958 IPC::RequestParser rp{ctx}; 878 *out_automatic_correction_enabled =
959 auto enabled{rp.Pop<bool>()}; 879 m_system_settings.user_system_clock_automatic_correction_enabled;
880 R_SUCCEED();
881}
960 882
961 const auto res = SetUserSystemClockAutomaticCorrectionEnabled(enabled); 883Result ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionEnabled(
884 bool automatic_correction_enabled) {
885 LOG_INFO(Service_SET, "called, out_automatic_correction_enabled={}",
886 automatic_correction_enabled);
962 887
963 IPC::ResponseBuilder rb{ctx, 2}; 888 m_system_settings.user_system_clock_automatic_correction_enabled = automatic_correction_enabled;
964 rb.Push(res); 889 SetSaveNeeded();
890 R_SUCCEED();
965} 891}
966 892
967void ISystemSettingsServer::GetDebugModeFlag(HLERequestContext& ctx) { 893Result ISystemSettingsServer::GetDebugModeFlag(Out<bool> is_debug_mode_enabled) {
968 bool is_debug_mode_enabled = false; 894 const auto result = GetSettingsItemValueImpl<bool>(*is_debug_mode_enabled, "settings_debug",
969 GetSettingsItemValue<bool>(is_debug_mode_enabled, "settings_debug", "is_debug_mode_enabled"); 895 "is_debug_mode_enabled");
970 896
971 LOG_DEBUG(Service_SET, "called, is_debug_mode_enabled={}", is_debug_mode_enabled); 897 LOG_DEBUG(Service_SET, "called, is_debug_mode_enabled={}", *is_debug_mode_enabled);
972 898 R_RETURN(result);
973 IPC::ResponseBuilder rb{ctx, 3};
974 rb.Push(ResultSuccess);
975 rb.Push(is_debug_mode_enabled);
976} 899}
977 900
978void ISystemSettingsServer::GetPrimaryAlbumStorage(HLERequestContext& ctx) { 901Result ISystemSettingsServer::GetPrimaryAlbumStorage(
902 Out<PrimaryAlbumStorage> out_primary_album_storage) {
979 LOG_INFO(Service_SET, "called, primary_album_storage={}", 903 LOG_INFO(Service_SET, "called, primary_album_storage={}",
980 m_system_settings.primary_album_storage); 904 m_system_settings.primary_album_storage);
981 905
982 IPC::ResponseBuilder rb{ctx, 3}; 906 *out_primary_album_storage = m_system_settings.primary_album_storage;
983 rb.Push(ResultSuccess); 907 R_SUCCEED();
984 rb.PushEnum(m_system_settings.primary_album_storage);
985} 908}
986 909
987void ISystemSettingsServer::SetPrimaryAlbumStorage(HLERequestContext& ctx) { 910Result ISystemSettingsServer::SetPrimaryAlbumStorage(PrimaryAlbumStorage primary_album_storage) {
988 IPC::RequestParser rp{ctx}; 911 LOG_INFO(Service_SET, "called, primary_album_storage={}", primary_album_storage);
989 m_system_settings.primary_album_storage = rp.PopEnum<PrimaryAlbumStorage>();
990 SetSaveNeeded();
991 912
992 LOG_INFO(Service_SET, "called, primary_album_storage={}", 913 m_system_settings.primary_album_storage = primary_album_storage;
993 m_system_settings.primary_album_storage); 914 SetSaveNeeded();
994 915 R_SUCCEED();
995 IPC::ResponseBuilder rb{ctx, 2};
996 rb.Push(ResultSuccess);
997} 916}
998 917
999void ISystemSettingsServer::GetBatteryLot(HLERequestContext& ctx) { 918Result ISystemSettingsServer::GetBatteryLot(Out<BatteryLot> out_battery_lot) {
1000 BatteryLot battery_lot = {"YUZUEMULATOR123456789"};
1001
1002 LOG_INFO(Service_SET, "called"); 919 LOG_INFO(Service_SET, "called");
1003 920
1004 IPC::ResponseBuilder rb{ctx, 8}; 921 *out_battery_lot = {"YUZU0EMULATOR14022024"};
1005 rb.Push(ResultSuccess); 922 R_SUCCEED();
1006 rb.PushRaw(battery_lot);
1007} 923}
1008 924
1009void ISystemSettingsServer::GetSerialNumber(HLERequestContext& ctx) { 925Result ISystemSettingsServer::GetSerialNumber(Out<SerialNumber> out_console_serial) {
1010 SerialNumber console_serial = {"YUZ10012345678"};
1011
1012 LOG_INFO(Service_SET, "called"); 926 LOG_INFO(Service_SET, "called");
1013 927
1014 IPC::ResponseBuilder rb{ctx, 8}; 928 *out_console_serial = {"YUZ10000000001"};
1015 rb.Push(ResultSuccess); 929 R_SUCCEED();
1016 rb.PushRaw(console_serial);
1017} 930}
1018 931
1019void ISystemSettingsServer::GetNfcEnableFlag(HLERequestContext& ctx) { 932Result ISystemSettingsServer::GetNfcEnableFlag(Out<bool> out_nfc_enable_flag) {
1020 LOG_INFO(Service_SET, "called, nfc_enable_flag={}", m_system_settings.nfc_enable_flag); 933 LOG_INFO(Service_SET, "called, nfc_enable_flag={}", m_system_settings.nfc_enable_flag);
1021 934
1022 IPC::ResponseBuilder rb{ctx, 3}; 935 *out_nfc_enable_flag = m_system_settings.nfc_enable_flag;
1023 rb.Push(ResultSuccess); 936 R_SUCCEED();
1024 rb.Push<u8>(m_system_settings.nfc_enable_flag);
1025} 937}
1026 938
1027void ISystemSettingsServer::SetNfcEnableFlag(HLERequestContext& ctx) { 939Result ISystemSettingsServer::SetNfcEnableFlag(bool nfc_enable_flag) {
1028 IPC::RequestParser rp{ctx}; 940 LOG_INFO(Service_SET, "called, nfc_enable_flag={}", nfc_enable_flag);
1029 m_system_settings.nfc_enable_flag = rp.Pop<bool>();
1030 SetSaveNeeded();
1031
1032 LOG_INFO(Service_SET, "called, nfc_enable_flag={}", m_system_settings.nfc_enable_flag);
1033 941
1034 IPC::ResponseBuilder rb{ctx, 2}; 942 m_system_settings.nfc_enable_flag = nfc_enable_flag;
1035 rb.Push(ResultSuccess); 943 SetSaveNeeded();
944 R_SUCCEED();
1036} 945}
1037 946
1038void ISystemSettingsServer::GetSleepSettings(HLERequestContext& ctx) { 947Result ISystemSettingsServer::GetSleepSettings(Out<SleepSettings> out_sleep_settings) {
1039 LOG_INFO(Service_SET, "called, flags={}, handheld_sleep_plan={}, console_sleep_plan={}", 948 LOG_INFO(Service_SET, "called, flags={}, handheld_sleep_plan={}, console_sleep_plan={}",
1040 m_system_settings.sleep_settings.flags.raw, 949 m_system_settings.sleep_settings.flags.raw,
1041 m_system_settings.sleep_settings.handheld_sleep_plan, 950 m_system_settings.sleep_settings.handheld_sleep_plan,
1042 m_system_settings.sleep_settings.console_sleep_plan); 951 m_system_settings.sleep_settings.console_sleep_plan);
1043 952
1044 IPC::ResponseBuilder rb{ctx, 5}; 953 *out_sleep_settings = m_system_settings.sleep_settings;
1045 rb.Push(ResultSuccess); 954 R_SUCCEED();
1046 rb.PushRaw(m_system_settings.sleep_settings);
1047} 955}
1048 956
1049void ISystemSettingsServer::SetSleepSettings(HLERequestContext& ctx) { 957Result ISystemSettingsServer::SetSleepSettings(SleepSettings sleep_settings) {
1050 IPC::RequestParser rp{ctx};
1051 m_system_settings.sleep_settings = rp.PopRaw<SleepSettings>();
1052 SetSaveNeeded();
1053
1054 LOG_INFO(Service_SET, "called, flags={}, handheld_sleep_plan={}, console_sleep_plan={}", 958 LOG_INFO(Service_SET, "called, flags={}, handheld_sleep_plan={}, console_sleep_plan={}",
1055 m_system_settings.sleep_settings.flags.raw, 959 sleep_settings.flags.raw, sleep_settings.handheld_sleep_plan,
1056 m_system_settings.sleep_settings.handheld_sleep_plan, 960 sleep_settings.console_sleep_plan);
1057 m_system_settings.sleep_settings.console_sleep_plan);
1058 961
1059 IPC::ResponseBuilder rb{ctx, 2}; 962 m_system_settings.sleep_settings = sleep_settings;
1060 rb.Push(ResultSuccess); 963 SetSaveNeeded();
964 R_SUCCEED();
1061} 965}
1062 966
1063void ISystemSettingsServer::GetWirelessLanEnableFlag(HLERequestContext& ctx) { 967Result ISystemSettingsServer::GetWirelessLanEnableFlag(Out<bool> out_wireless_lan_enable_flag) {
1064 LOG_INFO(Service_SET, "called, wireless_lan_enable_flag={}", 968 LOG_INFO(Service_SET, "called, wireless_lan_enable_flag={}",
1065 m_system_settings.wireless_lan_enable_flag); 969 m_system_settings.wireless_lan_enable_flag);
1066 970
1067 IPC::ResponseBuilder rb{ctx, 3}; 971 *out_wireless_lan_enable_flag = m_system_settings.wireless_lan_enable_flag;
1068 rb.Push(ResultSuccess); 972 R_SUCCEED();
1069 rb.Push(m_system_settings.wireless_lan_enable_flag);
1070} 973}
1071 974
1072void ISystemSettingsServer::SetWirelessLanEnableFlag(HLERequestContext& ctx) { 975Result ISystemSettingsServer::SetWirelessLanEnableFlag(bool wireless_lan_enable_flag) {
1073 IPC::RequestParser rp{ctx}; 976 LOG_INFO(Service_SET, "called, wireless_lan_enable_flag={}", wireless_lan_enable_flag);
1074 m_system_settings.wireless_lan_enable_flag = rp.Pop<bool>();
1075 SetSaveNeeded();
1076
1077 LOG_INFO(Service_SET, "called, wireless_lan_enable_flag={}",
1078 m_system_settings.wireless_lan_enable_flag);
1079 977
1080 IPC::ResponseBuilder rb{ctx, 2}; 978 m_system_settings.wireless_lan_enable_flag = wireless_lan_enable_flag;
1081 rb.Push(ResultSuccess); 979 SetSaveNeeded();
980 R_SUCCEED();
1082} 981}
1083 982
1084void ISystemSettingsServer::GetInitialLaunchSettings(HLERequestContext& ctx) { 983Result ISystemSettingsServer::GetInitialLaunchSettings(
984 Out<InitialLaunchSettings> out_initial_launch_settings) {
1085 LOG_INFO(Service_SET, "called, flags={}, timestamp={}", 985 LOG_INFO(Service_SET, "called, flags={}, timestamp={}",
1086 m_system_settings.initial_launch_settings_packed.flags.raw, 986 m_system_settings.initial_launch_settings_packed.flags.raw,
1087 m_system_settings.initial_launch_settings_packed.timestamp.time_point); 987 m_system_settings.initial_launch_settings_packed.timestamp.time_point);
1088 988
1089 IPC::ResponseBuilder rb{ctx, 10}; 989 *out_initial_launch_settings = {
1090 rb.Push(ResultSuccess); 990 .flags = m_system_settings.initial_launch_settings_packed.flags,
1091 rb.PushRaw(m_system_settings.initial_launch_settings_packed); 991 .timestamp = m_system_settings.initial_launch_settings_packed.timestamp,
992 };
993 R_SUCCEED();
1092} 994}
1093 995
1094void ISystemSettingsServer::SetInitialLaunchSettings(HLERequestContext& ctx) { 996Result ISystemSettingsServer::SetInitialLaunchSettings(
1095 IPC::RequestParser rp{ctx}; 997 InitialLaunchSettings initial_launch_settings) {
1096 auto initial_launch_settings = rp.PopRaw<InitialLaunchSettings>(); 998 LOG_INFO(Service_SET, "called, flags={}, timestamp={}", initial_launch_settings.flags.raw,
999 initial_launch_settings.timestamp.time_point);
1097 1000
1098 m_system_settings.initial_launch_settings_packed.flags = initial_launch_settings.flags; 1001 m_system_settings.initial_launch_settings_packed.flags = initial_launch_settings.flags;
1099 m_system_settings.initial_launch_settings_packed.timestamp = initial_launch_settings.timestamp; 1002 m_system_settings.initial_launch_settings_packed.timestamp = initial_launch_settings.timestamp;
1100 SetSaveNeeded(); 1003 SetSaveNeeded();
1101 1004 R_SUCCEED();
1102 LOG_INFO(Service_SET, "called, flags={}, timestamp={}",
1103 m_system_settings.initial_launch_settings_packed.flags.raw,
1104 m_system_settings.initial_launch_settings_packed.timestamp.time_point);
1105
1106 IPC::ResponseBuilder rb{ctx, 2};
1107 rb.Push(ResultSuccess);
1108} 1005}
1109 1006
1110void ISystemSettingsServer::GetDeviceNickName(HLERequestContext& ctx) { 1007Result ISystemSettingsServer::GetDeviceNickName(
1008 OutLargeData<std::array<u8, 0x80>, BufferAttr_HipcMapAlias> out_device_name) {
1111 LOG_DEBUG(Service_SET, "called"); 1009 LOG_DEBUG(Service_SET, "called");
1112 1010
1113 ctx.WriteBuffer(::Settings::values.device_name.GetValue()); 1011 *out_device_name = {};
1012 const auto device_name_buffer = ::Settings::values.device_name.GetValue().c_str();
1013 memcpy(out_device_name->data(), device_name_buffer,
1014 ::Settings::values.device_name.GetValue().size());
1114 1015
1115 IPC::ResponseBuilder rb{ctx, 2}; 1016 R_SUCCEED();
1116 rb.Push(ResultSuccess);
1117} 1017}
1118 1018
1119void ISystemSettingsServer::SetDeviceNickName(HLERequestContext& ctx) { 1019Result ISystemSettingsServer::SetDeviceNickName(
1120 const std::string device_name = Common::StringFromBuffer(ctx.ReadBuffer()); 1020 InLargeData<std::array<u8, 0x80>, BufferAttr_HipcMapAlias> device_name_buffer) {
1021 const std::string device_name = Common::StringFromBuffer(*device_name_buffer);
1121 1022
1122 LOG_INFO(Service_SET, "called, device_name={}", device_name); 1023 LOG_INFO(Service_SET, "called, device_name={}", device_name);
1123 1024
1124 ::Settings::values.device_name = device_name; 1025 ::Settings::values.device_name = device_name;
1125 1026 R_SUCCEED();
1126 IPC::ResponseBuilder rb{ctx, 2};
1127 rb.Push(ResultSuccess);
1128} 1027}
1129 1028
1130void ISystemSettingsServer::GetProductModel(HLERequestContext& ctx) { 1029Result ISystemSettingsServer::GetProductModel(Out<u32> out_product_model) {
1131 const u32 product_model = 1; 1030 const u32 product_model = 1;
1132 1031
1133 LOG_WARNING(Service_SET, "(STUBBED) called, product_model={}", product_model); 1032 LOG_WARNING(Service_SET, "(STUBBED) called, product_model={}", product_model);
1134 IPC::ResponseBuilder rb{ctx, 3}; 1033
1135 rb.Push(ResultSuccess); 1034 *out_product_model = product_model;
1136 rb.Push(product_model); 1035 R_SUCCEED();
1137} 1036}
1138 1037
1139void ISystemSettingsServer::GetBluetoothEnableFlag(HLERequestContext& ctx) { 1038Result ISystemSettingsServer::GetBluetoothEnableFlag(Out<bool> out_bluetooth_enable_flag) {
1140 LOG_INFO(Service_SET, "called, bluetooth_enable_flag={}", 1039 LOG_INFO(Service_SET, "called, bluetooth_enable_flag={}",
1141 m_system_settings.bluetooth_enable_flag); 1040 m_system_settings.bluetooth_enable_flag);
1142 1041
1143 IPC::ResponseBuilder rb{ctx, 3}; 1042 *out_bluetooth_enable_flag = m_system_settings.bluetooth_enable_flag;
1144 rb.Push(ResultSuccess); 1043 R_SUCCEED();
1145 rb.Push<u8>(m_system_settings.bluetooth_enable_flag);
1146} 1044}
1147 1045
1148void ISystemSettingsServer::SetBluetoothEnableFlag(HLERequestContext& ctx) { 1046Result ISystemSettingsServer::SetBluetoothEnableFlag(bool bluetooth_enable_flag) {
1149 IPC::RequestParser rp{ctx}; 1047 LOG_INFO(Service_SET, "called, bluetooth_enable_flag={}", bluetooth_enable_flag);
1150 m_system_settings.bluetooth_enable_flag = rp.Pop<bool>();
1151 SetSaveNeeded();
1152 1048
1153 LOG_INFO(Service_SET, "called, bluetooth_enable_flag={}", 1049 m_system_settings.bluetooth_enable_flag = bluetooth_enable_flag;
1154 m_system_settings.bluetooth_enable_flag); 1050 SetSaveNeeded();
1155 1051 R_SUCCEED();
1156 IPC::ResponseBuilder rb{ctx, 2};
1157 rb.Push(ResultSuccess);
1158} 1052}
1159 1053
1160void ISystemSettingsServer::GetMiiAuthorId(HLERequestContext& ctx) { 1054Result ISystemSettingsServer::GetMiiAuthorId(Out<Common::UUID> out_mii_author_id) {
1161 if (m_system_settings.mii_author_id.IsInvalid()) { 1055 if (m_system_settings.mii_author_id.IsInvalid()) {
1162 m_system_settings.mii_author_id = Common::UUID::MakeDefault(); 1056 m_system_settings.mii_author_id = Common::UUID::MakeDefault();
1163 SetSaveNeeded(); 1057 SetSaveNeeded();
@@ -1166,282 +1060,224 @@ void ISystemSettingsServer::GetMiiAuthorId(HLERequestContext& ctx) {
1166 LOG_INFO(Service_SET, "called, author_id={}", 1060 LOG_INFO(Service_SET, "called, author_id={}",
1167 m_system_settings.mii_author_id.FormattedString()); 1061 m_system_settings.mii_author_id.FormattedString());
1168 1062
1169 IPC::ResponseBuilder rb{ctx, 6}; 1063 *out_mii_author_id = m_system_settings.mii_author_id;
1170 rb.Push(ResultSuccess); 1064 R_SUCCEED();
1171 rb.PushRaw(m_system_settings.mii_author_id);
1172} 1065}
1173 1066
1174void ISystemSettingsServer::GetAutoUpdateEnableFlag(HLERequestContext& ctx) { 1067Result ISystemSettingsServer::GetAutoUpdateEnableFlag(Out<bool> out_auto_update_enable_flag) {
1175 LOG_INFO(Service_SET, "called, auto_update_flag={}", m_system_settings.auto_update_enable_flag); 1068 LOG_INFO(Service_SET, "called, auto_update_flag={}", m_system_settings.auto_update_enable_flag);
1176 1069
1177 IPC::ResponseBuilder rb{ctx, 3}; 1070 *out_auto_update_enable_flag = m_system_settings.auto_update_enable_flag;
1178 rb.Push(ResultSuccess); 1071 R_SUCCEED();
1179 rb.Push(m_system_settings.auto_update_enable_flag);
1180} 1072}
1181 1073
1182void ISystemSettingsServer::SetAutoUpdateEnableFlag(HLERequestContext& ctx) { 1074Result ISystemSettingsServer::SetAutoUpdateEnableFlag(bool auto_update_enable_flag) {
1183 IPC::RequestParser rp{ctx}; 1075 LOG_INFO(Service_SET, "called, auto_update_flag={}", auto_update_enable_flag);
1184 m_system_settings.auto_update_enable_flag = rp.Pop<bool>();
1185 SetSaveNeeded();
1186 1076
1187 LOG_INFO(Service_SET, "called, auto_update_flag={}", m_system_settings.auto_update_enable_flag); 1077 m_system_settings.auto_update_enable_flag = auto_update_enable_flag;
1188 1078 SetSaveNeeded();
1189 IPC::ResponseBuilder rb{ctx, 2}; 1079 R_SUCCEED();
1190 rb.Push(ResultSuccess);
1191} 1080}
1192 1081
1193void ISystemSettingsServer::GetBatteryPercentageFlag(HLERequestContext& ctx) { 1082Result ISystemSettingsServer::GetBatteryPercentageFlag(Out<bool> out_battery_percentage_flag) {
1194 LOG_DEBUG(Service_SET, "called, battery_percentage_flag={}", 1083 LOG_DEBUG(Service_SET, "called, battery_percentage_flag={}",
1195 m_system_settings.battery_percentage_flag); 1084 m_system_settings.battery_percentage_flag);
1196 1085
1197 IPC::ResponseBuilder rb{ctx, 3}; 1086 *out_battery_percentage_flag = m_system_settings.battery_percentage_flag;
1198 rb.Push(ResultSuccess); 1087 R_SUCCEED();
1199 rb.Push(m_system_settings.battery_percentage_flag);
1200} 1088}
1201 1089
1202void ISystemSettingsServer::SetBatteryPercentageFlag(HLERequestContext& ctx) { 1090Result ISystemSettingsServer::SetBatteryPercentageFlag(bool battery_percentage_flag) {
1203 IPC::RequestParser rp{ctx}; 1091 LOG_INFO(Service_SET, "called, battery_percentage_flag={}", battery_percentage_flag);
1204 m_system_settings.battery_percentage_flag = rp.Pop<bool>();
1205 SetSaveNeeded();
1206
1207 LOG_INFO(Service_SET, "called, battery_percentage_flag={}",
1208 m_system_settings.battery_percentage_flag);
1209 1092
1210 IPC::ResponseBuilder rb{ctx, 2}; 1093 m_system_settings.battery_percentage_flag = battery_percentage_flag;
1211 rb.Push(ResultSuccess); 1094 SetSaveNeeded();
1095 R_SUCCEED();
1212} 1096}
1213 1097
1214void ISystemSettingsServer::SetExternalSteadyClockInternalOffset(HLERequestContext& ctx) { 1098Result ISystemSettingsServer::SetExternalSteadyClockInternalOffset(s64 offset) {
1215 LOG_DEBUG(Service_SET, "called."); 1099 LOG_DEBUG(Service_SET, "called, external_steady_clock_internal_offset={}", offset);
1216
1217 IPC::RequestParser rp{ctx};
1218 auto offset{rp.Pop<s64>()};
1219
1220 const auto res = SetExternalSteadyClockInternalOffset(offset);
1221 1100
1222 IPC::ResponseBuilder rb{ctx, 2}; 1101 m_private_settings.external_steady_clock_internal_offset = offset;
1223 rb.Push(res); 1102 SetSaveNeeded();
1103 R_SUCCEED();
1224} 1104}
1225 1105
1226void ISystemSettingsServer::GetExternalSteadyClockInternalOffset(HLERequestContext& ctx) { 1106Result ISystemSettingsServer::GetExternalSteadyClockInternalOffset(Out<s64> out_offset) {
1227 LOG_DEBUG(Service_SET, "called."); 1107 LOG_DEBUG(Service_SET, "called, external_steady_clock_internal_offset={}",
1108 m_private_settings.external_steady_clock_internal_offset);
1228 1109
1229 s64 offset{}; 1110 *out_offset = m_private_settings.external_steady_clock_internal_offset;
1230 const auto res = GetExternalSteadyClockInternalOffset(offset); 1111 R_SUCCEED();
1231
1232 IPC::ResponseBuilder rb{ctx, 4};
1233 rb.Push(res);
1234 rb.Push(offset);
1235} 1112}
1236 1113
1237void ISystemSettingsServer::GetPushNotificationActivityModeOnSleep(HLERequestContext& ctx) { 1114Result ISystemSettingsServer::GetPushNotificationActivityModeOnSleep(
1115 Out<s32> out_push_notification_activity_mode_on_sleep) {
1238 LOG_INFO(Service_SET, "called, push_notification_activity_mode_on_sleep={}", 1116 LOG_INFO(Service_SET, "called, push_notification_activity_mode_on_sleep={}",
1239 m_system_settings.push_notification_activity_mode_on_sleep); 1117 m_system_settings.push_notification_activity_mode_on_sleep);
1240 1118
1241 IPC::ResponseBuilder rb{ctx, 3}; 1119 *out_push_notification_activity_mode_on_sleep =
1242 rb.Push(ResultSuccess); 1120 m_system_settings.push_notification_activity_mode_on_sleep;
1243 rb.Push(m_system_settings.push_notification_activity_mode_on_sleep); 1121 R_SUCCEED();
1244} 1122}
1245 1123
1246void ISystemSettingsServer::SetPushNotificationActivityModeOnSleep(HLERequestContext& ctx) { 1124Result ISystemSettingsServer::SetPushNotificationActivityModeOnSleep(
1247 IPC::RequestParser rp{ctx}; 1125 s32 push_notification_activity_mode_on_sleep) {
1248 m_system_settings.push_notification_activity_mode_on_sleep = rp.Pop<s32>();
1249 SetSaveNeeded();
1250
1251 LOG_INFO(Service_SET, "called, push_notification_activity_mode_on_sleep={}", 1126 LOG_INFO(Service_SET, "called, push_notification_activity_mode_on_sleep={}",
1252 m_system_settings.push_notification_activity_mode_on_sleep); 1127 push_notification_activity_mode_on_sleep);
1253 1128
1254 IPC::ResponseBuilder rb{ctx, 2}; 1129 m_system_settings.push_notification_activity_mode_on_sleep =
1255 rb.Push(ResultSuccess); 1130 push_notification_activity_mode_on_sleep;
1131 SetSaveNeeded();
1132 R_SUCCEED();
1256} 1133}
1257 1134
1258void ISystemSettingsServer::GetErrorReportSharePermission(HLERequestContext& ctx) { 1135Result ISystemSettingsServer::GetErrorReportSharePermission(
1136 Out<ErrorReportSharePermission> out_error_report_share_permission) {
1259 LOG_INFO(Service_SET, "called, error_report_share_permission={}", 1137 LOG_INFO(Service_SET, "called, error_report_share_permission={}",
1260 m_system_settings.error_report_share_permission); 1138 m_system_settings.error_report_share_permission);
1261 1139
1262 IPC::ResponseBuilder rb{ctx, 3}; 1140 *out_error_report_share_permission = m_system_settings.error_report_share_permission;
1263 rb.Push(ResultSuccess); 1141 R_SUCCEED();
1264 rb.PushEnum(m_system_settings.error_report_share_permission);
1265} 1142}
1266 1143
1267void ISystemSettingsServer::SetErrorReportSharePermission(HLERequestContext& ctx) { 1144Result ISystemSettingsServer::SetErrorReportSharePermission(
1268 IPC::RequestParser rp{ctx}; 1145 ErrorReportSharePermission error_report_share_permission) {
1269 m_system_settings.error_report_share_permission = rp.PopEnum<ErrorReportSharePermission>();
1270 SetSaveNeeded();
1271
1272 LOG_INFO(Service_SET, "called, error_report_share_permission={}", 1146 LOG_INFO(Service_SET, "called, error_report_share_permission={}",
1273 m_system_settings.error_report_share_permission); 1147 error_report_share_permission);
1274 1148
1275 IPC::ResponseBuilder rb{ctx, 2}; 1149 m_system_settings.error_report_share_permission = error_report_share_permission;
1276 rb.Push(ResultSuccess); 1150 SetSaveNeeded();
1151 R_SUCCEED();
1277} 1152}
1278 1153
1279void ISystemSettingsServer::GetAppletLaunchFlags(HLERequestContext& ctx) { 1154Result ISystemSettingsServer::GetAppletLaunchFlags(Out<u32> out_applet_launch_flag) {
1280 LOG_INFO(Service_SET, "called, applet_launch_flag={}", m_system_settings.applet_launch_flag); 1155 LOG_INFO(Service_SET, "called, applet_launch_flag={}", m_system_settings.applet_launch_flag);
1281 1156
1282 IPC::ResponseBuilder rb{ctx, 3}; 1157 *out_applet_launch_flag = m_system_settings.applet_launch_flag;
1283 rb.Push(ResultSuccess); 1158 R_SUCCEED();
1284 rb.Push(m_system_settings.applet_launch_flag);
1285} 1159}
1286 1160
1287void ISystemSettingsServer::SetAppletLaunchFlags(HLERequestContext& ctx) { 1161Result ISystemSettingsServer::SetAppletLaunchFlags(u32 applet_launch_flag) {
1288 IPC::RequestParser rp{ctx}; 1162 LOG_INFO(Service_SET, "called, applet_launch_flag={}", applet_launch_flag);
1289 m_system_settings.applet_launch_flag = rp.Pop<u32>();
1290 SetSaveNeeded();
1291
1292 LOG_INFO(Service_SET, "called, applet_launch_flag={}", m_system_settings.applet_launch_flag);
1293 1163
1294 IPC::ResponseBuilder rb{ctx, 2}; 1164 m_system_settings.applet_launch_flag = applet_launch_flag;
1295 rb.Push(ResultSuccess); 1165 SetSaveNeeded();
1166 R_SUCCEED();
1296} 1167}
1297 1168
1298void ISystemSettingsServer::GetKeyboardLayout(HLERequestContext& ctx) { 1169Result ISystemSettingsServer::GetKeyboardLayout(Out<KeyboardLayout> out_keyboard_layout) {
1299 LOG_INFO(Service_SET, "called, keyboard_layout={}", m_system_settings.keyboard_layout); 1170 LOG_INFO(Service_SET, "called, keyboard_layout={}", m_system_settings.keyboard_layout);
1300 1171
1301 IPC::ResponseBuilder rb{ctx, 3}; 1172 *out_keyboard_layout = m_system_settings.keyboard_layout;
1302 rb.Push(ResultSuccess); 1173 R_SUCCEED();
1303 rb.Push(static_cast<u32>(m_system_settings.keyboard_layout));
1304} 1174}
1305 1175
1306void ISystemSettingsServer::SetKeyboardLayout(HLERequestContext& ctx) { 1176Result ISystemSettingsServer::SetKeyboardLayout(KeyboardLayout keyboard_layout) {
1307 IPC::RequestParser rp{ctx}; 1177 LOG_INFO(Service_SET, "called, keyboard_layout={}", keyboard_layout);
1308 m_system_settings.keyboard_layout = rp.PopRaw<KeyboardLayout>();
1309 SetSaveNeeded();
1310
1311 LOG_INFO(Service_SET, "called, keyboard_layout={}", m_system_settings.keyboard_layout);
1312 1178
1313 IPC::ResponseBuilder rb{ctx, 2}; 1179 m_system_settings.keyboard_layout = keyboard_layout;
1314 rb.Push(ResultSuccess); 1180 R_SUCCEED();
1315} 1181}
1316 1182
1317void ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) { 1183Result ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(
1184 Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point) {
1318 LOG_INFO(Service_SET, "called"); 1185 LOG_INFO(Service_SET, "called");
1319 1186
1320 Service::PSC::Time::SteadyClockTimePoint time_point{}; 1187 *out_time_point = m_system_settings.device_time_zone_location_updated_time;
1321 const auto res = GetDeviceTimeZoneLocationUpdatedTime(time_point); 1188 R_SUCCEED();
1322
1323 IPC::ResponseBuilder rb{ctx, 4};
1324 rb.Push(res);
1325 rb.PushRaw<Service::PSC::Time::SteadyClockTimePoint>(time_point);
1326} 1189}
1327 1190
1328void ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) { 1191Result ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(
1192 const Service::PSC::Time::SteadyClockTimePoint& time_point) {
1329 LOG_INFO(Service_SET, "called"); 1193 LOG_INFO(Service_SET, "called");
1330 1194
1331 IPC::RequestParser rp{ctx}; 1195 m_system_settings.device_time_zone_location_updated_time = time_point;
1332 auto time_point{rp.PopRaw<Service::PSC::Time::SteadyClockTimePoint>()}; 1196 SetSaveNeeded();
1333 1197 R_SUCCEED();
1334 const auto res = SetDeviceTimeZoneLocationUpdatedTime(time_point);
1335
1336 IPC::ResponseBuilder rb{ctx, 2};
1337 rb.Push(res);
1338} 1198}
1339 1199
1340void ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime( 1200Result ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime(
1341 HLERequestContext& ctx) { 1201 Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point) {
1342 LOG_INFO(Service_SET, "called"); 1202 LOG_INFO(Service_SET, "called");
1343 1203
1344 Service::PSC::Time::SteadyClockTimePoint time_point{}; 1204 *out_time_point = m_system_settings.user_system_clock_automatic_correction_updated_time_point;
1345 const auto res = GetUserSystemClockAutomaticCorrectionUpdatedTime(time_point); 1205 R_SUCCEED();
1346
1347 IPC::ResponseBuilder rb{ctx, 4};
1348 rb.Push(res);
1349 rb.PushRaw<Service::PSC::Time::SteadyClockTimePoint>(time_point);
1350} 1206}
1351 1207
1352void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime( 1208Result ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime(
1353 HLERequestContext& ctx) { 1209 const Service::PSC::Time::SteadyClockTimePoint& out_time_point) {
1354 LOG_INFO(Service_SET, "called"); 1210 LOG_INFO(Service_SET, "called");
1355 1211
1356 IPC::RequestParser rp{ctx}; 1212 m_system_settings.user_system_clock_automatic_correction_updated_time_point = out_time_point;
1357 const auto time_point{rp.PopRaw<Service::PSC::Time::SteadyClockTimePoint>()}; 1213 SetSaveNeeded();
1358 1214 R_SUCCEED();
1359 const auto res = SetUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
1360
1361 IPC::ResponseBuilder rb{ctx, 2};
1362 rb.Push(res);
1363} 1215}
1364 1216
1365void ISystemSettingsServer::GetChineseTraditionalInputMethod(HLERequestContext& ctx) { 1217Result ISystemSettingsServer::GetChineseTraditionalInputMethod(
1218 Out<ChineseTraditionalInputMethod> out_chinese_traditional_input_method) {
1366 LOG_INFO(Service_SET, "called, chinese_traditional_input_method={}", 1219 LOG_INFO(Service_SET, "called, chinese_traditional_input_method={}",
1367 m_system_settings.chinese_traditional_input_method); 1220 m_system_settings.chinese_traditional_input_method);
1368 1221
1369 IPC::ResponseBuilder rb{ctx, 3}; 1222 *out_chinese_traditional_input_method = m_system_settings.chinese_traditional_input_method;
1370 rb.Push(ResultSuccess); 1223 R_SUCCEED();
1371 rb.PushEnum(m_system_settings.chinese_traditional_input_method);
1372} 1224}
1373 1225
1374void ISystemSettingsServer::GetHomeMenuScheme(HLERequestContext& ctx) { 1226Result ISystemSettingsServer::GetHomeMenuScheme(Out<HomeMenuScheme> out_home_menu_scheme) {
1375 LOG_DEBUG(Service_SET, "(STUBBED) called"); 1227 LOG_DEBUG(Service_SET, "(STUBBED) called");
1376 1228
1377 const HomeMenuScheme default_color = { 1229 *out_home_menu_scheme = {
1378 .main = 0xFF323232, 1230 .main = 0xFF323232,
1379 .back = 0xFF323232, 1231 .back = 0xFF323232,
1380 .sub = 0xFFFFFFFF, 1232 .sub = 0xFFFFFFFF,
1381 .bezel = 0xFFFFFFFF, 1233 .bezel = 0xFFFFFFFF,
1382 .extra = 0xFF000000, 1234 .extra = 0xFF000000,
1383 }; 1235 };
1384 1236 R_SUCCEED();
1385 IPC::ResponseBuilder rb{ctx, 2 + sizeof(HomeMenuScheme) / sizeof(u32)};
1386 rb.Push(ResultSuccess);
1387 rb.PushRaw(default_color);
1388} 1237}
1389 1238
1390void ISystemSettingsServer::GetHomeMenuSchemeModel(HLERequestContext& ctx) { 1239Result ISystemSettingsServer::GetHomeMenuSchemeModel(Out<u32> out_home_menu_scheme_model) {
1391 LOG_WARNING(Service_SET, "(STUBBED) called"); 1240 LOG_WARNING(Service_SET, "(STUBBED) called");
1392 1241
1393 IPC::ResponseBuilder rb{ctx, 3}; 1242 *out_home_menu_scheme_model = 0;
1394 rb.Push(ResultSuccess); 1243 R_SUCCEED();
1395 rb.Push(0);
1396} 1244}
1397 1245
1398void ISystemSettingsServer::GetTouchScreenMode(HLERequestContext& ctx) { 1246Result ISystemSettingsServer::GetTouchScreenMode(Out<TouchScreenMode> out_touch_screen_mode) {
1399 TouchScreenMode touch_screen_mode{}; 1247 LOG_INFO(Service_SET, "called, touch_screen_mode={}", m_system_settings.touch_screen_mode);
1400 auto res = GetTouchScreenMode(touch_screen_mode);
1401 1248
1402 LOG_INFO(Service_SET, "called, touch_screen_mode={}", touch_screen_mode); 1249 *out_touch_screen_mode = m_system_settings.touch_screen_mode;
1403 1250 R_SUCCEED();
1404 IPC::ResponseBuilder rb{ctx, 3};
1405 rb.Push(res);
1406 rb.PushEnum(touch_screen_mode);
1407} 1251}
1408 1252
1409void ISystemSettingsServer::SetTouchScreenMode(HLERequestContext& ctx) { 1253Result ISystemSettingsServer::SetTouchScreenMode(TouchScreenMode touch_screen_mode) {
1410 IPC::RequestParser rp{ctx};
1411 const auto touch_screen_mode = rp.PopEnum<TouchScreenMode>();
1412 auto res = SetTouchScreenMode(touch_screen_mode);
1413
1414 LOG_INFO(Service_SET, "called, touch_screen_mode={}", touch_screen_mode); 1254 LOG_INFO(Service_SET, "called, touch_screen_mode={}", touch_screen_mode);
1415 1255
1416 IPC::ResponseBuilder rb{ctx, 2}; 1256 m_system_settings.touch_screen_mode = touch_screen_mode;
1417 rb.Push(res); 1257 SetSaveNeeded();
1258 R_SUCCEED();
1418} 1259}
1419 1260
1420void ISystemSettingsServer::GetFieldTestingFlag(HLERequestContext& ctx) { 1261Result ISystemSettingsServer::GetFieldTestingFlag(Out<bool> out_field_testing_flag) {
1421 LOG_INFO(Service_SET, "called, field_testing_flag={}", m_system_settings.field_testing_flag); 1262 LOG_INFO(Service_SET, "called, field_testing_flag={}", m_system_settings.field_testing_flag);
1422 1263
1423 IPC::ResponseBuilder rb{ctx, 3}; 1264 *out_field_testing_flag = m_system_settings.field_testing_flag;
1424 rb.Push(ResultSuccess); 1265 R_SUCCEED();
1425 rb.Push(m_system_settings.field_testing_flag);
1426} 1266}
1427 1267
1428void ISystemSettingsServer::GetPanelCrcMode(HLERequestContext& ctx) { 1268Result ISystemSettingsServer::GetPanelCrcMode(Out<s32> out_panel_crc_mode) {
1429 LOG_INFO(Service_SET, "called, panel_crc_mode={}", m_system_settings.panel_crc_mode); 1269 LOG_INFO(Service_SET, "called, panel_crc_mode={}", m_system_settings.panel_crc_mode);
1430 1270
1431 IPC::ResponseBuilder rb{ctx, 3}; 1271 *out_panel_crc_mode = m_system_settings.panel_crc_mode;
1432 rb.Push(ResultSuccess); 1272 R_SUCCEED();
1433 rb.Push(m_system_settings.panel_crc_mode);
1434} 1273}
1435 1274
1436void ISystemSettingsServer::SetPanelCrcMode(HLERequestContext& ctx) { 1275Result ISystemSettingsServer::SetPanelCrcMode(s32 panel_crc_mode) {
1437 IPC::RequestParser rp{ctx}; 1276 LOG_INFO(Service_SET, "called, panel_crc_mode={}", panel_crc_mode);
1438 m_system_settings.panel_crc_mode = rp.PopRaw<s32>();
1439 SetSaveNeeded();
1440 1277
1441 LOG_INFO(Service_SET, "called, panel_crc_mode={}", m_system_settings.panel_crc_mode); 1278 m_system_settings.panel_crc_mode = panel_crc_mode;
1442 1279 SetSaveNeeded();
1443 IPC::ResponseBuilder rb{ctx, 2}; 1280 R_SUCCEED();
1444 rb.Push(ResultSuccess);
1445} 1281}
1446 1282
1447void ISystemSettingsServer::SetupSettings() { 1283void ISystemSettingsServer::SetupSettings() {
@@ -1513,9 +1349,9 @@ void ISystemSettingsServer::SetSaveNeeded() {
1513 m_save_needed = true; 1349 m_save_needed = true;
1514} 1350}
1515 1351
1516Result ISystemSettingsServer::GetSettingsItemValue(std::vector<u8>& out_value, 1352Result ISystemSettingsServer::GetSettingsItemValueImpl(std::vector<u8>& out_value,
1517 const std::string& category, 1353 const std::string& category,
1518 const std::string& name) { 1354 const std::string& name) {
1519 auto settings{GetSettings()}; 1355 auto settings{GetSettings()};
1520 R_UNLESS(settings.contains(category) && settings[category].contains(name), ResultUnknown); 1356 R_UNLESS(settings.contains(category) && settings[category].contains(name), ResultUnknown);
1521 1357
@@ -1523,184 +1359,4 @@ Result ISystemSettingsServer::GetSettingsItemValue(std::vector<u8>& out_value,
1523 R_SUCCEED(); 1359 R_SUCCEED();
1524} 1360}
1525 1361
1526Result ISystemSettingsServer::GetVibrationMasterVolume(f32& out_volume) const {
1527 out_volume = m_system_settings.vibration_master_volume;
1528 R_SUCCEED();
1529}
1530
1531Result ISystemSettingsServer::SetVibrationMasterVolume(f32 volume) {
1532 m_system_settings.vibration_master_volume = volume;
1533 SetSaveNeeded();
1534 R_SUCCEED();
1535}
1536
1537Result ISystemSettingsServer::GetAudioOutputMode(AudioOutputMode& out_output_mode,
1538 AudioOutputModeTarget target) const {
1539 switch (target) {
1540 case AudioOutputModeTarget::Hdmi:
1541 out_output_mode = m_system_settings.audio_output_mode_hdmi;
1542 break;
1543 case AudioOutputModeTarget::Speaker:
1544 out_output_mode = m_system_settings.audio_output_mode_speaker;
1545 break;
1546 case AudioOutputModeTarget::Headphone:
1547 out_output_mode = m_system_settings.audio_output_mode_headphone;
1548 break;
1549 case AudioOutputModeTarget::Type3:
1550 out_output_mode = m_system_settings.audio_output_mode_type3;
1551 break;
1552 case AudioOutputModeTarget::Type4:
1553 out_output_mode = m_system_settings.audio_output_mode_type4;
1554 break;
1555 default:
1556 LOG_ERROR(Service_SET, "Invalid audio output mode target {}", target);
1557 }
1558 R_SUCCEED();
1559}
1560
1561Result ISystemSettingsServer::SetAudioOutputMode(AudioOutputModeTarget target,
1562 AudioOutputMode output_mode) {
1563 switch (target) {
1564 case AudioOutputModeTarget::Hdmi:
1565 m_system_settings.audio_output_mode_hdmi = output_mode;
1566 break;
1567 case AudioOutputModeTarget::Speaker:
1568 m_system_settings.audio_output_mode_speaker = output_mode;
1569 break;
1570 case AudioOutputModeTarget::Headphone:
1571 m_system_settings.audio_output_mode_headphone = output_mode;
1572 break;
1573 case AudioOutputModeTarget::Type3:
1574 m_system_settings.audio_output_mode_type3 = output_mode;
1575 break;
1576 case AudioOutputModeTarget::Type4:
1577 m_system_settings.audio_output_mode_type4 = output_mode;
1578 break;
1579 default:
1580 LOG_ERROR(Service_SET, "Invalid audio output mode target {}", target);
1581 }
1582 SetSaveNeeded();
1583 R_SUCCEED();
1584}
1585
1586Result ISystemSettingsServer::GetSpeakerAutoMuteFlag(bool& is_auto_mute) const {
1587 is_auto_mute = m_system_settings.force_mute_on_headphone_removed;
1588 R_SUCCEED();
1589}
1590
1591Result ISystemSettingsServer::SetSpeakerAutoMuteFlag(bool is_auto_mute) {
1592 m_system_settings.force_mute_on_headphone_removed = is_auto_mute;
1593 SetSaveNeeded();
1594 R_SUCCEED();
1595}
1596
1597Result ISystemSettingsServer::GetExternalSteadyClockSourceId(Common::UUID& out_id) const {
1598 out_id = m_private_settings.external_clock_source_id;
1599 R_SUCCEED();
1600}
1601
1602Result ISystemSettingsServer::SetExternalSteadyClockSourceId(const Common::UUID& id) {
1603 m_private_settings.external_clock_source_id = id;
1604 SetSaveNeeded();
1605 R_SUCCEED();
1606}
1607
1608Result ISystemSettingsServer::GetUserSystemClockContext(
1609 Service::PSC::Time::SystemClockContext& out_context) const {
1610 out_context = m_system_settings.user_system_clock_context;
1611 R_SUCCEED();
1612}
1613
1614Result ISystemSettingsServer::SetUserSystemClockContext(
1615 const Service::PSC::Time::SystemClockContext& context) {
1616 m_system_settings.user_system_clock_context = context;
1617 SetSaveNeeded();
1618 R_SUCCEED();
1619}
1620
1621Result ISystemSettingsServer::GetDeviceTimeZoneLocationName(
1622 Service::PSC::Time::LocationName& out_name) const {
1623 out_name = m_system_settings.device_time_zone_location_name;
1624 R_SUCCEED();
1625}
1626
1627Result ISystemSettingsServer::SetDeviceTimeZoneLocationName(
1628 const Service::PSC::Time::LocationName& name) {
1629 m_system_settings.device_time_zone_location_name = name;
1630 SetSaveNeeded();
1631 R_SUCCEED();
1632}
1633
1634Result ISystemSettingsServer::GetNetworkSystemClockContext(
1635 Service::PSC::Time::SystemClockContext& out_context) const {
1636 out_context = m_system_settings.network_system_clock_context;
1637 R_SUCCEED();
1638}
1639
1640Result ISystemSettingsServer::SetNetworkSystemClockContext(
1641 const Service::PSC::Time::SystemClockContext& context) {
1642 m_system_settings.network_system_clock_context = context;
1643 SetSaveNeeded();
1644 R_SUCCEED();
1645}
1646
1647Result ISystemSettingsServer::IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled) const {
1648 out_enabled = m_system_settings.user_system_clock_automatic_correction_enabled;
1649 R_SUCCEED();
1650}
1651
1652Result ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionEnabled(bool enabled) {
1653 m_system_settings.user_system_clock_automatic_correction_enabled = enabled;
1654 SetSaveNeeded();
1655 R_SUCCEED();
1656}
1657
1658Result ISystemSettingsServer::SetExternalSteadyClockInternalOffset(s64 offset) {
1659 m_private_settings.external_steady_clock_internal_offset = offset;
1660 SetSaveNeeded();
1661 R_SUCCEED();
1662}
1663
1664Result ISystemSettingsServer::GetExternalSteadyClockInternalOffset(s64& out_offset) const {
1665 out_offset = m_private_settings.external_steady_clock_internal_offset;
1666 R_SUCCEED();
1667}
1668
1669Result ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(
1670 Service::PSC::Time::SteadyClockTimePoint& out_time_point) const {
1671 out_time_point = m_system_settings.device_time_zone_location_updated_time;
1672 R_SUCCEED();
1673}
1674
1675Result ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(
1676 const Service::PSC::Time::SteadyClockTimePoint& time_point) {
1677 m_system_settings.device_time_zone_location_updated_time = time_point;
1678 SetSaveNeeded();
1679 R_SUCCEED();
1680}
1681
1682Result ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime(
1683 Service::PSC::Time::SteadyClockTimePoint& out_time_point) const {
1684 out_time_point = m_system_settings.user_system_clock_automatic_correction_updated_time_point;
1685 R_SUCCEED();
1686}
1687
1688Result ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime(
1689 const Service::PSC::Time::SteadyClockTimePoint& out_time_point) {
1690 m_system_settings.user_system_clock_automatic_correction_updated_time_point = out_time_point;
1691 SetSaveNeeded();
1692 R_SUCCEED();
1693}
1694
1695Result ISystemSettingsServer::GetTouchScreenMode(TouchScreenMode& touch_screen_mode) const {
1696 touch_screen_mode = m_system_settings.touch_screen_mode;
1697 R_SUCCEED();
1698}
1699
1700Result ISystemSettingsServer::SetTouchScreenMode(TouchScreenMode touch_screen_mode) {
1701 m_system_settings.touch_screen_mode = touch_screen_mode;
1702 SetSaveNeeded();
1703 R_SUCCEED();
1704}
1705
1706} // namespace Service::Set 1362} // namespace Service::Set
diff --git a/src/core/hle/service/set/system_settings_server.h b/src/core/hle/service/set/system_settings_server.h
index 9a3b36f0c..46e06c8ea 100644
--- a/src/core/hle/service/set/system_settings_server.h
+++ b/src/core/hle/service/set/system_settings_server.h
@@ -11,6 +11,7 @@
11#include "common/polyfill_thread.h" 11#include "common/polyfill_thread.h"
12#include "common/uuid.h" 12#include "common/uuid.h"
13#include "core/hle/result.h" 13#include "core/hle/result.h"
14#include "core/hle/service/cmif_types.h"
14#include "core/hle/service/psc/time/common.h" 15#include "core/hle/service/psc/time/common.h"
15#include "core/hle/service/service.h" 16#include "core/hle/service/service.h"
16#include "core/hle/service/set/setting_formats/appln_settings.h" 17#include "core/hle/service/set/setting_formats/appln_settings.h"
@@ -33,13 +34,14 @@ public:
33 explicit ISystemSettingsServer(Core::System& system_); 34 explicit ISystemSettingsServer(Core::System& system_);
34 ~ISystemSettingsServer() override; 35 ~ISystemSettingsServer() override;
35 36
36 Result GetSettingsItemValue(std::vector<u8>& out_value, const std::string& category, 37 Result GetSettingsItemValueImpl(std::vector<u8>& out_value, const std::string& category,
37 const std::string& name); 38 const std::string& name);
38 39
39 template <typename T> 40 template <typename T>
40 Result GetSettingsItemValue(T& value, const std::string& category, const std::string& name) { 41 Result GetSettingsItemValueImpl(T& value, const std::string& category,
42 const std::string& name) {
41 std::vector<u8> data; 43 std::vector<u8> data;
42 const auto result = GetSettingsItemValue(data, category, name); 44 const auto result = GetSettingsItemValueImpl(data, category, name);
43 if (result.IsError()) { 45 if (result.IsError()) {
44 return result; 46 return result;
45 } 47 }
@@ -48,120 +50,114 @@ public:
48 return result; 50 return result;
49 } 51 }
50 52
51 Result GetVibrationMasterVolume(f32& out_volume) const; 53public:
52 Result SetVibrationMasterVolume(f32 volume); 54 Result SetLanguageCode(LanguageCode language_code);
53 Result GetAudioOutputMode(AudioOutputMode& out_output_mode, AudioOutputModeTarget target) const; 55 Result GetFirmwareVersion(
56 OutLargeData<FirmwareVersionFormat, BufferAttr_HipcPointer> out_firmware_data);
57 Result GetFirmwareVersion2(
58 OutLargeData<FirmwareVersionFormat, BufferAttr_HipcPointer> out_firmware_data);
59 Result GetLockScreenFlag(Out<bool> out_lock_screen_flag);
60 Result SetLockScreenFlag(bool lock_screen_flag);
61 Result GetExternalSteadyClockSourceId(Out<Common::UUID> out_clock_source_id);
62 Result SetExternalSteadyClockSourceId(const Common::UUID& clock_source_id);
63 Result GetUserSystemClockContext(Out<Service::PSC::Time::SystemClockContext> out_clock_context);
64 Result SetUserSystemClockContext(const Service::PSC::Time::SystemClockContext& clock_context);
65 Result GetAccountSettings(Out<AccountSettings> out_account_settings);
66 Result SetAccountSettings(AccountSettings account_settings);
67 Result GetEulaVersions(Out<s32> out_count,
68 OutArray<EulaVersion, BufferAttr_HipcMapAlias> out_eula_versions);
69 Result SetEulaVersions(InArray<EulaVersion, BufferAttr_HipcMapAlias> eula_versions);
70 Result GetColorSetId(Out<ColorSet> out_color_set_id);
71 Result SetColorSetId(ColorSet color_set_id);
72 Result GetNotificationSettings(Out<NotificationSettings> out_notification_settings);
73 Result SetNotificationSettings(const NotificationSettings& notification_settings);
74 Result GetAccountNotificationSettings(
75 Out<s32> out_count, OutArray<AccountNotificationSettings, BufferAttr_HipcMapAlias>
76 out_account_notification_settings);
77 Result SetAccountNotificationSettings(
78 InArray<AccountNotificationSettings, BufferAttr_HipcMapAlias>
79 account_notification_settings);
80 Result GetVibrationMasterVolume(Out<f32> vibration_master_volume);
81 Result SetVibrationMasterVolume(f32 vibration_master_volume);
82 Result GetSettingsItemValueSize(
83 Out<u64> out_size,
84 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
85 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buf);
86 Result GetSettingsItemValue(
87 OutBuffer<BufferAttr_HipcMapAlias> out_data,
88 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
89 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer);
90 Result GetTvSettings(Out<TvSettings> out_tv_settings);
91 Result SetTvSettings(TvSettings tv_settings);
92 Result GetAudioOutputMode(Out<AudioOutputMode> out_output_mode, AudioOutputModeTarget target);
54 Result SetAudioOutputMode(AudioOutputModeTarget target, AudioOutputMode output_mode); 93 Result SetAudioOutputMode(AudioOutputModeTarget target, AudioOutputMode output_mode);
55 Result GetSpeakerAutoMuteFlag(bool& is_auto_mute) const; 94 Result GetSpeakerAutoMuteFlag(Out<bool> out_force_mute_on_headphone_removed);
56 Result SetSpeakerAutoMuteFlag(bool auto_mute); 95 Result SetSpeakerAutoMuteFlag(bool force_mute_on_headphone_removed);
57 Result GetExternalSteadyClockSourceId(Common::UUID& out_id) const; 96 Result GetQuestFlag(Out<QuestFlag> out_quest_flag);
58 Result SetExternalSteadyClockSourceId(const Common::UUID& id); 97 Result SetQuestFlag(QuestFlag quest_flag);
59 Result GetUserSystemClockContext(Service::PSC::Time::SystemClockContext& out_context) const; 98 Result GetDeviceTimeZoneLocationName(Out<Service::PSC::Time::LocationName> out_name);
60 Result SetUserSystemClockContext(const Service::PSC::Time::SystemClockContext& context);
61 Result GetDeviceTimeZoneLocationName(Service::PSC::Time::LocationName& out_name) const;
62 Result SetDeviceTimeZoneLocationName(const Service::PSC::Time::LocationName& name); 99 Result SetDeviceTimeZoneLocationName(const Service::PSC::Time::LocationName& name);
63 Result GetNetworkSystemClockContext(Service::PSC::Time::SystemClockContext& out_context) const; 100 Result SetRegionCode(SystemRegionCode region_code);
101 Result GetNetworkSystemClockContext(Out<Service::PSC::Time::SystemClockContext> out_context);
64 Result SetNetworkSystemClockContext(const Service::PSC::Time::SystemClockContext& context); 102 Result SetNetworkSystemClockContext(const Service::PSC::Time::SystemClockContext& context);
65 Result IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled) const; 103 Result IsUserSystemClockAutomaticCorrectionEnabled(Out<bool> out_automatic_correction_enabled);
66 Result SetUserSystemClockAutomaticCorrectionEnabled(bool enabled); 104 Result SetUserSystemClockAutomaticCorrectionEnabled(bool automatic_correction_enabled);
105 Result GetDebugModeFlag(Out<bool> is_debug_mode_enabled);
106 Result GetPrimaryAlbumStorage(Out<PrimaryAlbumStorage> out_primary_album_storage);
107 Result SetPrimaryAlbumStorage(PrimaryAlbumStorage primary_album_storage);
108 Result GetBatteryLot(Out<BatteryLot> out_battery_lot);
109 Result GetSerialNumber(Out<SerialNumber> out_console_serial);
110 Result GetNfcEnableFlag(Out<bool> out_nfc_enable_flag);
111 Result SetNfcEnableFlag(bool nfc_enable_flag);
112 Result GetSleepSettings(Out<SleepSettings> out_sleep_settings);
113 Result SetSleepSettings(SleepSettings sleep_settings);
114 Result GetWirelessLanEnableFlag(Out<bool> out_wireless_lan_enable_flag);
115 Result SetWirelessLanEnableFlag(bool wireless_lan_enable_flag);
116 Result GetInitialLaunchSettings(Out<InitialLaunchSettings> out_initial_launch_settings);
117 Result SetInitialLaunchSettings(InitialLaunchSettings initial_launch_settings);
118 Result GetDeviceNickName(
119 OutLargeData<std::array<u8, 0x80>, BufferAttr_HipcMapAlias> out_device_name);
120 Result SetDeviceNickName(
121 InLargeData<std::array<u8, 0x80>, BufferAttr_HipcMapAlias> device_name_buffer);
122 Result GetProductModel(Out<u32> out_product_model);
123 Result GetBluetoothEnableFlag(Out<bool> out_bluetooth_enable_flag);
124 Result SetBluetoothEnableFlag(bool bluetooth_enable_flag);
125 Result GetMiiAuthorId(Out<Common::UUID> out_mii_author_id);
126 Result GetAutoUpdateEnableFlag(Out<bool> out_auto_update_enable_flag);
127 Result SetAutoUpdateEnableFlag(bool auto_update_enable_flag);
128 Result GetBatteryPercentageFlag(Out<bool> out_battery_percentage_flag);
129 Result SetBatteryPercentageFlag(bool battery_percentage_flag);
67 Result SetExternalSteadyClockInternalOffset(s64 offset); 130 Result SetExternalSteadyClockInternalOffset(s64 offset);
68 Result GetExternalSteadyClockInternalOffset(s64& out_offset) const; 131 Result GetExternalSteadyClockInternalOffset(Out<s64> out_offset);
132 Result GetPushNotificationActivityModeOnSleep(
133 Out<s32> out_push_notification_activity_mode_on_sleep);
134 Result SetPushNotificationActivityModeOnSleep(s32 push_notification_activity_mode_on_sleep);
135 Result GetErrorReportSharePermission(
136 Out<ErrorReportSharePermission> out_error_report_share_permission);
137 Result SetErrorReportSharePermission(ErrorReportSharePermission error_report_share_permission);
138 Result GetAppletLaunchFlags(Out<u32> out_applet_launch_flag);
139 Result SetAppletLaunchFlags(u32 applet_launch_flag);
140 Result GetKeyboardLayout(Out<KeyboardLayout> out_keyboard_layout);
141 Result SetKeyboardLayout(KeyboardLayout keyboard_layout);
69 Result GetDeviceTimeZoneLocationUpdatedTime( 142 Result GetDeviceTimeZoneLocationUpdatedTime(
70 Service::PSC::Time::SteadyClockTimePoint& out_time_point) const; 143 Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point);
71 Result SetDeviceTimeZoneLocationUpdatedTime( 144 Result SetDeviceTimeZoneLocationUpdatedTime(
72 const Service::PSC::Time::SteadyClockTimePoint& time_point); 145 const Service::PSC::Time::SteadyClockTimePoint& time_point);
73 Result GetUserSystemClockAutomaticCorrectionUpdatedTime( 146 Result GetUserSystemClockAutomaticCorrectionUpdatedTime(
74 Service::PSC::Time::SteadyClockTimePoint& out_time_point) const; 147 Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point);
75 Result SetUserSystemClockAutomaticCorrectionUpdatedTime( 148 Result SetUserSystemClockAutomaticCorrectionUpdatedTime(
76 const Service::PSC::Time::SteadyClockTimePoint& time_point); 149 const Service::PSC::Time::SteadyClockTimePoint& out_time_point);
77 Result GetTouchScreenMode(TouchScreenMode& touch_screen_mode) const; 150 Result GetChineseTraditionalInputMethod(
151 Out<ChineseTraditionalInputMethod> out_chinese_traditional_input_method);
152 Result GetHomeMenuScheme(Out<HomeMenuScheme> out_home_menu_scheme);
153 Result GetHomeMenuSchemeModel(Out<u32> out_home_menu_scheme_model);
154 Result GetTouchScreenMode(Out<TouchScreenMode> out_touch_screen_mode);
78 Result SetTouchScreenMode(TouchScreenMode touch_screen_mode); 155 Result SetTouchScreenMode(TouchScreenMode touch_screen_mode);
156 Result GetFieldTestingFlag(Out<bool> out_field_testing_flag);
157 Result GetPanelCrcMode(Out<s32> out_panel_crc_mode);
158 Result SetPanelCrcMode(s32 panel_crc_mode);
79 159
80private: 160private:
81 void SetLanguageCode(HLERequestContext& ctx);
82 void GetFirmwareVersion(HLERequestContext& ctx);
83 void GetFirmwareVersion2(HLERequestContext& ctx);
84 void GetLockScreenFlag(HLERequestContext& ctx);
85 void SetLockScreenFlag(HLERequestContext& ctx);
86 void GetExternalSteadyClockSourceId(HLERequestContext& ctx);
87 void SetExternalSteadyClockSourceId(HLERequestContext& ctx);
88 void GetUserSystemClockContext(HLERequestContext& ctx);
89 void SetUserSystemClockContext(HLERequestContext& ctx);
90 void GetAccountSettings(HLERequestContext& ctx);
91 void SetAccountSettings(HLERequestContext& ctx);
92 void GetEulaVersions(HLERequestContext& ctx);
93 void SetEulaVersions(HLERequestContext& ctx);
94 void GetColorSetId(HLERequestContext& ctx);
95 void SetColorSetId(HLERequestContext& ctx);
96 void GetNotificationSettings(HLERequestContext& ctx);
97 void SetNotificationSettings(HLERequestContext& ctx);
98 void GetAccountNotificationSettings(HLERequestContext& ctx);
99 void SetAccountNotificationSettings(HLERequestContext& ctx);
100 void GetVibrationMasterVolume(HLERequestContext& ctx);
101 void SetVibrationMasterVolume(HLERequestContext& ctx);
102 void GetSettingsItemValueSize(HLERequestContext& ctx);
103 void GetSettingsItemValue(HLERequestContext& ctx);
104 void GetTvSettings(HLERequestContext& ctx);
105 void SetTvSettings(HLERequestContext& ctx);
106 void GetAudioOutputMode(HLERequestContext& ctx);
107 void SetAudioOutputMode(HLERequestContext& ctx);
108 void GetSpeakerAutoMuteFlag(HLERequestContext& ctx);
109 void SetSpeakerAutoMuteFlag(HLERequestContext& ctx);
110 void GetDebugModeFlag(HLERequestContext& ctx);
111 void GetQuestFlag(HLERequestContext& ctx);
112 void SetQuestFlag(HLERequestContext& ctx);
113 void GetDeviceTimeZoneLocationName(HLERequestContext& ctx);
114 void SetDeviceTimeZoneLocationName(HLERequestContext& ctx);
115 void SetRegionCode(HLERequestContext& ctx);
116 void GetNetworkSystemClockContext(HLERequestContext& ctx);
117 void SetNetworkSystemClockContext(HLERequestContext& ctx);
118 void IsUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
119 void SetUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
120 void GetPrimaryAlbumStorage(HLERequestContext& ctx);
121 void SetPrimaryAlbumStorage(HLERequestContext& ctx);
122 void GetBatteryLot(HLERequestContext& ctx);
123 void GetSerialNumber(HLERequestContext& ctx);
124 void GetNfcEnableFlag(HLERequestContext& ctx);
125 void SetNfcEnableFlag(HLERequestContext& ctx);
126 void GetSleepSettings(HLERequestContext& ctx);
127 void SetSleepSettings(HLERequestContext& ctx);
128 void GetWirelessLanEnableFlag(HLERequestContext& ctx);
129 void SetWirelessLanEnableFlag(HLERequestContext& ctx);
130 void GetInitialLaunchSettings(HLERequestContext& ctx);
131 void SetInitialLaunchSettings(HLERequestContext& ctx);
132 void GetDeviceNickName(HLERequestContext& ctx);
133 void SetDeviceNickName(HLERequestContext& ctx);
134 void GetProductModel(HLERequestContext& ctx);
135 void GetBluetoothEnableFlag(HLERequestContext& ctx);
136 void SetBluetoothEnableFlag(HLERequestContext& ctx);
137 void GetMiiAuthorId(HLERequestContext& ctx);
138 void GetAutoUpdateEnableFlag(HLERequestContext& ctx);
139 void SetAutoUpdateEnableFlag(HLERequestContext& ctx);
140 void GetBatteryPercentageFlag(HLERequestContext& ctx);
141 void SetBatteryPercentageFlag(HLERequestContext& ctx);
142 void SetExternalSteadyClockInternalOffset(HLERequestContext& ctx);
143 void GetExternalSteadyClockInternalOffset(HLERequestContext& ctx);
144 void GetPushNotificationActivityModeOnSleep(HLERequestContext& ctx);
145 void SetPushNotificationActivityModeOnSleep(HLERequestContext& ctx);
146 void GetErrorReportSharePermission(HLERequestContext& ctx);
147 void SetErrorReportSharePermission(HLERequestContext& ctx);
148 void GetAppletLaunchFlags(HLERequestContext& ctx);
149 void SetAppletLaunchFlags(HLERequestContext& ctx);
150 void GetKeyboardLayout(HLERequestContext& ctx);
151 void SetKeyboardLayout(HLERequestContext& ctx);
152 void GetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx);
153 void SetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx);
154 void GetUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx);
155 void SetUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx);
156 void GetChineseTraditionalInputMethod(HLERequestContext& ctx);
157 void GetHomeMenuScheme(HLERequestContext& ctx);
158 void GetHomeMenuSchemeModel(HLERequestContext& ctx);
159 void GetTouchScreenMode(HLERequestContext& ctx);
160 void SetTouchScreenMode(HLERequestContext& ctx);
161 void GetFieldTestingFlag(HLERequestContext& ctx);
162 void GetPanelCrcMode(HLERequestContext& ctx);
163 void SetPanelCrcMode(HLERequestContext& ctx);
164
165 bool LoadSettingsFile(std::filesystem::path& path, auto&& default_func); 161 bool LoadSettingsFile(std::filesystem::path& path, auto&& default_func);
166 bool StoreSettingsFile(std::filesystem::path& path, auto& settings); 162 bool StoreSettingsFile(std::filesystem::path& path, auto& settings);
167 void SetupSettings(); 163 void SetupSettings();
diff --git a/src/core/hle/service/vi/application_display_service.cpp b/src/core/hle/service/vi/application_display_service.cpp
new file mode 100644
index 000000000..78229e30f
--- /dev/null
+++ b/src/core/hle/service/vi/application_display_service.cpp
@@ -0,0 +1,319 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/cmif_serialization.h"
5#include "core/hle/service/nvnflinger/nvnflinger.h"
6#include "core/hle/service/nvnflinger/parcel.h"
7#include "core/hle/service/vi/application_display_service.h"
8#include "core/hle/service/vi/hos_binder_driver.h"
9#include "core/hle/service/vi/manager_display_service.h"
10#include "core/hle/service/vi/system_display_service.h"
11#include "core/hle/service/vi/vi_results.h"
12
13namespace Service::VI {
14
15IApplicationDisplayService::IApplicationDisplayService(
16 Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
17 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server)
18 : ServiceFramework{system_, "IApplicationDisplayService"}, m_nvnflinger{nvnflinger},
19 m_hos_binder_driver_server{hos_binder_driver_server} {
20
21 // clang-format off
22 static const FunctionInfo functions[] = {
23 {100, C<&IApplicationDisplayService::GetRelayService>, "GetRelayService"},
24 {101, C<&IApplicationDisplayService::GetSystemDisplayService>, "GetSystemDisplayService"},
25 {102, C<&IApplicationDisplayService::GetManagerDisplayService>, "GetManagerDisplayService"},
26 {103, C<&IApplicationDisplayService::GetIndirectDisplayTransactionService>, "GetIndirectDisplayTransactionService"},
27 {1000, C<&IApplicationDisplayService::ListDisplays>, "ListDisplays"},
28 {1010, C<&IApplicationDisplayService::OpenDisplay>, "OpenDisplay"},
29 {1011, C<&IApplicationDisplayService::OpenDefaultDisplay>, "OpenDefaultDisplay"},
30 {1020, C<&IApplicationDisplayService::CloseDisplay>, "CloseDisplay"},
31 {1101, C<&IApplicationDisplayService::SetDisplayEnabled>, "SetDisplayEnabled"},
32 {1102, C<&IApplicationDisplayService::GetDisplayResolution>, "GetDisplayResolution"},
33 {2020, C<&IApplicationDisplayService::OpenLayer>, "OpenLayer"},
34 {2021, C<&IApplicationDisplayService::CloseLayer>, "CloseLayer"},
35 {2030, C<&IApplicationDisplayService::CreateStrayLayer>, "CreateStrayLayer"},
36 {2031, C<&IApplicationDisplayService::DestroyStrayLayer>, "DestroyStrayLayer"},
37 {2101, C<&IApplicationDisplayService::SetLayerScalingMode>, "SetLayerScalingMode"},
38 {2102, C<&IApplicationDisplayService::ConvertScalingMode>, "ConvertScalingMode"},
39 {2450, C<&IApplicationDisplayService::GetIndirectLayerImageMap>, "GetIndirectLayerImageMap"},
40 {2451, nullptr, "GetIndirectLayerImageCropMap"},
41 {2460, C<&IApplicationDisplayService::GetIndirectLayerImageRequiredMemoryInfo>, "GetIndirectLayerImageRequiredMemoryInfo"},
42 {5202, C<&IApplicationDisplayService::GetDisplayVsyncEvent>, "GetDisplayVsyncEvent"},
43 {5203, nullptr, "GetDisplayVsyncEventForDebug"},
44 };
45 // clang-format on
46
47 RegisterHandlers(functions);
48}
49
50IApplicationDisplayService::~IApplicationDisplayService() {
51 for (const auto layer_id : m_stray_layer_ids) {
52 m_nvnflinger.DestroyLayer(layer_id);
53 }
54}
55
56Result IApplicationDisplayService::GetRelayService(
57 Out<SharedPointer<IHOSBinderDriver>> out_relay_service) {
58 LOG_WARNING(Service_VI, "(STUBBED) called");
59 *out_relay_service = std::make_shared<IHOSBinderDriver>(system, m_hos_binder_driver_server);
60 R_SUCCEED();
61}
62
63Result IApplicationDisplayService::GetSystemDisplayService(
64 Out<SharedPointer<ISystemDisplayService>> out_system_display_service) {
65 LOG_WARNING(Service_VI, "(STUBBED) called");
66 *out_system_display_service = std::make_shared<ISystemDisplayService>(system, m_nvnflinger);
67 R_SUCCEED();
68}
69
70Result IApplicationDisplayService::GetManagerDisplayService(
71 Out<SharedPointer<IManagerDisplayService>> out_manager_display_service) {
72 LOG_WARNING(Service_VI, "(STUBBED) called");
73 *out_manager_display_service = std::make_shared<IManagerDisplayService>(system, m_nvnflinger);
74 R_SUCCEED();
75}
76
77Result IApplicationDisplayService::GetIndirectDisplayTransactionService(
78 Out<SharedPointer<IHOSBinderDriver>> out_indirect_display_transaction_service) {
79 LOG_WARNING(Service_VI, "(STUBBED) called");
80 *out_indirect_display_transaction_service =
81 std::make_shared<IHOSBinderDriver>(system, m_hos_binder_driver_server);
82 R_SUCCEED();
83}
84
85Result IApplicationDisplayService::OpenDisplay(Out<u64> out_display_id, DisplayName display_name) {
86 LOG_WARNING(Service_VI, "(STUBBED) called");
87
88 display_name[display_name.size() - 1] = '\0';
89 ASSERT_MSG(strcmp(display_name.data(), "Default") == 0,
90 "Non-default displays aren't supported yet");
91
92 const auto display_id = m_nvnflinger.OpenDisplay(display_name.data());
93 if (!display_id) {
94 LOG_ERROR(Service_VI, "Display not found! display_name={}", display_name.data());
95 R_THROW(VI::ResultNotFound);
96 }
97
98 *out_display_id = *display_id;
99 R_SUCCEED();
100}
101
102Result IApplicationDisplayService::OpenDefaultDisplay(Out<u64> out_display_id) {
103 LOG_DEBUG(Service_VI, "called");
104 R_RETURN(this->OpenDisplay(out_display_id, DisplayName{"Default"}));
105}
106
107Result IApplicationDisplayService::CloseDisplay(u64 display_id) {
108 LOG_DEBUG(Service_VI, "called");
109 R_SUCCEED_IF(m_nvnflinger.CloseDisplay(display_id));
110 R_THROW(ResultUnknown);
111}
112
113Result IApplicationDisplayService::SetDisplayEnabled(u32 state, u64 display_id) {
114 LOG_DEBUG(Service_VI, "called");
115
116 // This literally does nothing internally in the actual service itself,
117 // and just returns a successful result code regardless of the input.
118 R_SUCCEED();
119}
120
121Result IApplicationDisplayService::GetDisplayResolution(Out<s64> out_width, Out<s64> out_height,
122 u64 display_id) {
123 LOG_DEBUG(Service_VI, "called. display_id={}", display_id);
124
125 // This only returns the fixed values of 1280x720 and makes no distinguishing
126 // between docked and undocked dimensions.
127 *out_width = static_cast<s64>(DisplayResolution::UndockedWidth);
128 *out_height = static_cast<s64>(DisplayResolution::UndockedHeight);
129 R_SUCCEED();
130}
131
132Result IApplicationDisplayService::SetLayerScalingMode(NintendoScaleMode scale_mode, u64 layer_id) {
133 LOG_DEBUG(Service_VI, "called. scale_mode={}, unknown=0x{:016X}", scale_mode, layer_id);
134
135 if (scale_mode > NintendoScaleMode::PreserveAspectRatio) {
136 LOG_ERROR(Service_VI, "Invalid scaling mode provided.");
137 R_THROW(VI::ResultOperationFailed);
138 }
139
140 if (scale_mode != NintendoScaleMode::ScaleToWindow &&
141 scale_mode != NintendoScaleMode::PreserveAspectRatio) {
142 LOG_ERROR(Service_VI, "Unsupported scaling mode supplied.");
143 R_THROW(VI::ResultNotSupported);
144 }
145
146 R_SUCCEED();
147}
148
149Result IApplicationDisplayService::ListDisplays(
150 Out<u64> out_count, OutArray<DisplayInfo, BufferAttr_HipcMapAlias> out_displays) {
151 LOG_WARNING(Service_VI, "(STUBBED) called");
152
153 if (out_displays.size() > 0) {
154 out_displays[0] = DisplayInfo{};
155 *out_count = 1;
156 } else {
157 *out_count = 0;
158 }
159
160 R_SUCCEED();
161}
162
163Result IApplicationDisplayService::OpenLayer(Out<u64> out_size,
164 OutBuffer<BufferAttr_HipcMapAlias> out_native_window,
165 DisplayName display_name, u64 layer_id,
166 ClientAppletResourceUserId aruid) {
167 display_name[display_name.size() - 1] = '\0';
168
169 LOG_DEBUG(Service_VI, "called. layer_id={}, aruid={:#x}", layer_id, aruid.pid);
170
171 const auto display_id = m_nvnflinger.OpenDisplay(display_name.data());
172 if (!display_id) {
173 LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id);
174 R_THROW(VI::ResultNotFound);
175 }
176
177 const auto buffer_queue_id = m_nvnflinger.FindBufferQueueId(*display_id, layer_id);
178 if (!buffer_queue_id) {
179 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id);
180 R_THROW(VI::ResultNotFound);
181 }
182
183 if (!m_nvnflinger.OpenLayer(layer_id)) {
184 LOG_WARNING(Service_VI, "Tried to open layer which was already open");
185 R_THROW(VI::ResultOperationFailed);
186 }
187
188 android::OutputParcel parcel;
189 parcel.WriteInterface(NativeWindow{*buffer_queue_id});
190
191 const auto buffer = parcel.Serialize();
192 std::memcpy(out_native_window.data(), buffer.data(),
193 std::min(out_native_window.size(), buffer.size()));
194 *out_size = buffer.size();
195
196 R_SUCCEED();
197}
198
199Result IApplicationDisplayService::CloseLayer(u64 layer_id) {
200 LOG_DEBUG(Service_VI, "called. layer_id={}", layer_id);
201
202 if (!m_nvnflinger.CloseLayer(layer_id)) {
203 LOG_WARNING(Service_VI, "Tried to close layer which was not open");
204 R_THROW(VI::ResultOperationFailed);
205 }
206
207 R_SUCCEED();
208}
209
210Result IApplicationDisplayService::CreateStrayLayer(
211 Out<u64> out_layer_id, Out<u64> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_native_window,
212 u32 flags, u64 display_id) {
213 LOG_DEBUG(Service_VI, "called. flags={}, display_id={}", flags, display_id);
214
215 const auto layer_id = m_nvnflinger.CreateLayer(display_id);
216 if (!layer_id) {
217 LOG_ERROR(Service_VI, "Layer not found! display_id={}", display_id);
218 R_THROW(VI::ResultNotFound);
219 }
220
221 m_stray_layer_ids.push_back(*layer_id);
222 const auto buffer_queue_id = m_nvnflinger.FindBufferQueueId(display_id, *layer_id);
223 if (!buffer_queue_id) {
224 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id);
225 R_THROW(VI::ResultNotFound);
226 }
227
228 android::OutputParcel parcel;
229 parcel.WriteInterface(NativeWindow{*buffer_queue_id});
230
231 const auto buffer = parcel.Serialize();
232 std::memcpy(out_native_window.data(), buffer.data(),
233 std::min(out_native_window.size(), buffer.size()));
234
235 *out_layer_id = *layer_id;
236 *out_size = buffer.size();
237
238 R_SUCCEED();
239}
240
241Result IApplicationDisplayService::DestroyStrayLayer(u64 layer_id) {
242 LOG_WARNING(Service_VI, "(STUBBED) called. layer_id={}", layer_id);
243 m_nvnflinger.DestroyLayer(layer_id);
244 R_SUCCEED();
245}
246
247Result IApplicationDisplayService::GetDisplayVsyncEvent(
248 OutCopyHandle<Kernel::KReadableEvent> out_vsync_event, u64 display_id) {
249 LOG_DEBUG(Service_VI, "called. display_id={}", display_id);
250
251 const auto result = m_nvnflinger.FindVsyncEvent(out_vsync_event, display_id);
252 if (result != ResultSuccess) {
253 if (result == ResultNotFound) {
254 LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id);
255 }
256
257 R_THROW(result);
258 }
259
260 R_UNLESS(!m_vsync_event_fetched, VI::ResultPermissionDenied);
261 m_vsync_event_fetched = true;
262
263 R_SUCCEED();
264}
265
266Result IApplicationDisplayService::ConvertScalingMode(Out<ConvertedScaleMode> out_scaling_mode,
267 NintendoScaleMode mode) {
268 LOG_DEBUG(Service_VI, "called mode={}", mode);
269
270 switch (mode) {
271 case NintendoScaleMode::None:
272 *out_scaling_mode = ConvertedScaleMode::None;
273 R_SUCCEED();
274 case NintendoScaleMode::Freeze:
275 *out_scaling_mode = ConvertedScaleMode::Freeze;
276 R_SUCCEED();
277 case NintendoScaleMode::ScaleToWindow:
278 *out_scaling_mode = ConvertedScaleMode::ScaleToWindow;
279 R_SUCCEED();
280 case NintendoScaleMode::ScaleAndCrop:
281 *out_scaling_mode = ConvertedScaleMode::ScaleAndCrop;
282 R_SUCCEED();
283 case NintendoScaleMode::PreserveAspectRatio:
284 *out_scaling_mode = ConvertedScaleMode::PreserveAspectRatio;
285 R_SUCCEED();
286 default:
287 LOG_ERROR(Service_VI, "Invalid scaling mode specified, mode={}", mode);
288 R_THROW(VI::ResultOperationFailed);
289 }
290}
291
292Result IApplicationDisplayService::GetIndirectLayerImageMap(
293 Out<u64> out_size, Out<u64> out_stride,
294 OutBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias> out_buffer,
295 s64 width, s64 height, u64 indirect_layer_consumer_handle, ClientAppletResourceUserId aruid) {
296 LOG_WARNING(
297 Service_VI,
298 "(STUBBED) called, width={}, height={}, indirect_layer_consumer_handle={}, aruid={:#x}",
299 width, height, indirect_layer_consumer_handle, aruid.pid);
300 *out_size = 0;
301 *out_stride = 0;
302 R_SUCCEED();
303}
304
305Result IApplicationDisplayService::GetIndirectLayerImageRequiredMemoryInfo(Out<s64> out_size,
306 Out<s64> out_alignment,
307 s64 width, s64 height) {
308 LOG_DEBUG(Service_VI, "called width={}, height={}", width, height);
309
310 constexpr u64 base_size = 0x20000;
311 const auto texture_size = width * height * 4;
312
313 *out_alignment = 0x1000;
314 *out_size = (texture_size + base_size - 1) / base_size * base_size;
315
316 R_SUCCEED();
317}
318
319} // namespace Service::VI
diff --git a/src/core/hle/service/vi/application_display_service.h b/src/core/hle/service/vi/application_display_service.h
new file mode 100644
index 000000000..5dff4bb31
--- /dev/null
+++ b/src/core/hle/service/vi/application_display_service.h
@@ -0,0 +1,65 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/cmif_types.h"
5#include "core/hle/service/service.h"
6#include "core/hle/service/vi/vi_types.h"
7
8namespace Kernel {
9class KReadableEvent;
10}
11
12namespace Service::VI {
13
14class IHOSBinderDriver;
15class IManagerDisplayService;
16class ISystemDisplayService;
17
18class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> {
19public:
20 IApplicationDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
21 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
22 ~IApplicationDisplayService() override;
23
24private:
25 Result GetRelayService(Out<SharedPointer<IHOSBinderDriver>> out_relay_service);
26 Result GetSystemDisplayService(
27 Out<SharedPointer<ISystemDisplayService>> out_system_display_service);
28 Result GetManagerDisplayService(
29 Out<SharedPointer<IManagerDisplayService>> out_manager_display_service);
30 Result GetIndirectDisplayTransactionService(
31 Out<SharedPointer<IHOSBinderDriver>> out_indirect_display_transaction_service);
32 Result OpenDisplay(Out<u64> out_display_id, DisplayName display_name);
33 Result OpenDefaultDisplay(Out<u64> out_display_id);
34 Result CloseDisplay(u64 display_id);
35 Result SetDisplayEnabled(u32 state, u64 display_id);
36 Result GetDisplayResolution(Out<s64> out_width, Out<s64> out_height, u64 display_id);
37 Result SetLayerScalingMode(NintendoScaleMode scale_mode, u64 layer_id);
38 Result ListDisplays(Out<u64> out_count,
39 OutArray<DisplayInfo, BufferAttr_HipcMapAlias> out_displays);
40 Result OpenLayer(Out<u64> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_native_window,
41 DisplayName display_name, u64 layer_id, ClientAppletResourceUserId aruid);
42 Result CloseLayer(u64 layer_id);
43 Result CreateStrayLayer(Out<u64> out_layer_id, Out<u64> out_size,
44 OutBuffer<BufferAttr_HipcMapAlias> out_native_window, u32 flags,
45 u64 display_id);
46 Result DestroyStrayLayer(u64 layer_id);
47 Result GetDisplayVsyncEvent(OutCopyHandle<Kernel::KReadableEvent> out_vsync_event,
48 u64 display_id);
49 Result ConvertScalingMode(Out<ConvertedScaleMode> out_scaling_mode, NintendoScaleMode mode);
50 Result GetIndirectLayerImageMap(
51 Out<u64> out_size, Out<u64> out_stride,
52 OutBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias> out_buffer,
53 s64 width, s64 height, u64 indirect_layer_consumer_handle,
54 ClientAppletResourceUserId aruid);
55 Result GetIndirectLayerImageRequiredMemoryInfo(Out<s64> out_size, Out<s64> out_alignment,
56 s64 width, s64 height);
57
58private:
59 Nvnflinger::Nvnflinger& m_nvnflinger;
60 Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server;
61 std::vector<u64> m_stray_layer_ids;
62 bool m_vsync_event_fetched{false};
63};
64
65} // namespace Service::VI
diff --git a/src/core/hle/service/vi/application_root_service.cpp b/src/core/hle/service/vi/application_root_service.cpp
new file mode 100644
index 000000000..7af7f062c
--- /dev/null
+++ b/src/core/hle/service/vi/application_root_service.cpp
@@ -0,0 +1,34 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/cmif_serialization.h"
5#include "core/hle/service/vi/application_display_service.h"
6#include "core/hle/service/vi/application_root_service.h"
7#include "core/hle/service/vi/service_creator.h"
8#include "core/hle/service/vi/vi.h"
9#include "core/hle/service/vi/vi_types.h"
10
11namespace Service::VI {
12
13IApplicationRootService::IApplicationRootService(
14 Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
15 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server)
16 : ServiceFramework{system_, "vi:u"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{
17 hos_binder_driver_server} {
18 static const FunctionInfo functions[] = {
19 {0, C<&IApplicationRootService::GetDisplayService>, "GetDisplayService"},
20 {1, nullptr, "GetDisplayServiceWithProxyNameExchange"},
21 };
22 RegisterHandlers(functions);
23}
24
25IApplicationRootService::~IApplicationRootService() = default;
26
27Result IApplicationRootService::GetDisplayService(
28 Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
29 LOG_DEBUG(Service_VI, "called");
30 R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger,
31 m_hos_binder_driver_server, Permission::User, policy));
32}
33
34} // namespace Service::VI
diff --git a/src/core/hle/service/vi/application_root_service.h b/src/core/hle/service/vi/application_root_service.h
new file mode 100644
index 000000000..9dbf28cb4
--- /dev/null
+++ b/src/core/hle/service/vi/application_root_service.h
@@ -0,0 +1,39 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/service.h"
8
9namespace Core {
10class System;
11}
12
13namespace Service::Nvnflinger {
14class HosBinderDriverServer;
15class Nvnflinger;
16} // namespace Service::Nvnflinger
17
18namespace Service::VI {
19
20class IApplicationDisplayService;
21enum class Policy : u32;
22
23class IApplicationRootService final : public ServiceFramework<IApplicationRootService> {
24public:
25 explicit IApplicationRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
26 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
27 ~IApplicationRootService() override;
28
29private:
30 Result GetDisplayService(
31 Out<SharedPointer<IApplicationDisplayService>> out_application_display_service,
32 Policy policy);
33
34private:
35 Nvnflinger::Nvnflinger& m_nvnflinger;
36 Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server;
37};
38
39} // namespace Service::VI
diff --git a/src/core/hle/service/vi/hos_binder_driver.cpp b/src/core/hle/service/vi/hos_binder_driver.cpp
new file mode 100644
index 000000000..ba0317245
--- /dev/null
+++ b/src/core/hle/service/vi/hos_binder_driver.cpp
@@ -0,0 +1,53 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/cmif_serialization.h"
5#include "core/hle/service/nvnflinger/binder.h"
6#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
7#include "core/hle/service/vi/hos_binder_driver.h"
8
9namespace Service::VI {
10
11IHOSBinderDriver::IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server)
12 : ServiceFramework{system_, "IHOSBinderDriver"}, m_server(server) {
13 static const FunctionInfo functions[] = {
14 {0, C<&IHOSBinderDriver::TransactParcel>, "TransactParcel"},
15 {1, C<&IHOSBinderDriver::AdjustRefcount>, "AdjustRefcount"},
16 {2, C<&IHOSBinderDriver::GetNativeHandle>, "GetNativeHandle"},
17 {3, C<&IHOSBinderDriver::TransactParcelAuto>, "TransactParcelAuto"},
18 };
19 RegisterHandlers(functions);
20}
21
22IHOSBinderDriver::~IHOSBinderDriver() = default;
23
24Result IHOSBinderDriver::TransactParcel(s32 binder_id, android::TransactionId transaction_id,
25 InBuffer<BufferAttr_HipcMapAlias> parcel_data,
26 OutBuffer<BufferAttr_HipcMapAlias> parcel_reply,
27 u32 flags) {
28 LOG_DEBUG(Service_VI, "called. id={} transaction={}, flags={}", binder_id, transaction_id,
29 flags);
30 m_server.TryGetProducer(binder_id)->Transact(transaction_id, flags, parcel_data, parcel_reply);
31 R_SUCCEED();
32}
33
34Result IHOSBinderDriver::AdjustRefcount(s32 binder_id, s32 addval, s32 type) {
35 LOG_WARNING(Service_VI, "(STUBBED) called id={}, addval={}, type={}", binder_id, addval, type);
36 R_SUCCEED();
37}
38
39Result IHOSBinderDriver::GetNativeHandle(s32 binder_id, u32 type_id,
40 OutCopyHandle<Kernel::KReadableEvent> out_handle) {
41 LOG_WARNING(Service_VI, "(STUBBED) called id={}, type_id={}", binder_id, type_id);
42 *out_handle = &m_server.TryGetProducer(binder_id)->GetNativeHandle();
43 R_SUCCEED();
44}
45
46Result IHOSBinderDriver::TransactParcelAuto(s32 binder_id, android::TransactionId transaction_id,
47 InBuffer<BufferAttr_HipcAutoSelect> parcel_data,
48 OutBuffer<BufferAttr_HipcAutoSelect> parcel_reply,
49 u32 flags) {
50 R_RETURN(this->TransactParcel(binder_id, transaction_id, parcel_data, parcel_reply, flags));
51}
52
53} // namespace Service::VI
diff --git a/src/core/hle/service/vi/hos_binder_driver.h b/src/core/hle/service/vi/hos_binder_driver.h
new file mode 100644
index 000000000..ed6e8cdbe
--- /dev/null
+++ b/src/core/hle/service/vi/hos_binder_driver.h
@@ -0,0 +1,30 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/cmif_types.h"
5#include "core/hle/service/nvnflinger/binder.h"
6#include "core/hle/service/service.h"
7
8namespace Service::VI {
9
10class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> {
11public:
12 explicit IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server);
13 ~IHOSBinderDriver() override;
14
15private:
16 Result TransactParcel(s32 binder_id, android::TransactionId transaction_id,
17 InBuffer<BufferAttr_HipcMapAlias> parcel_data,
18 OutBuffer<BufferAttr_HipcMapAlias> parcel_reply, u32 flags);
19 Result AdjustRefcount(s32 binder_id, s32 addval, s32 type);
20 Result GetNativeHandle(s32 binder_id, u32 type_id,
21 OutCopyHandle<Kernel::KReadableEvent> out_handle);
22 Result TransactParcelAuto(s32 binder_id, android::TransactionId transaction_id,
23 InBuffer<BufferAttr_HipcAutoSelect> parcel_data,
24 OutBuffer<BufferAttr_HipcAutoSelect> parcel_reply, u32 flags);
25
26private:
27 Nvnflinger::HosBinderDriverServer& m_server;
28};
29
30} // namespace Service::VI
diff --git a/src/core/hle/service/vi/manager_display_service.cpp b/src/core/hle/service/vi/manager_display_service.cpp
new file mode 100644
index 000000000..17f2f3b8f
--- /dev/null
+++ b/src/core/hle/service/vi/manager_display_service.cpp
@@ -0,0 +1,130 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/cmif_serialization.h"
5#include "core/hle/service/nvnflinger/nvnflinger.h"
6#include "core/hle/service/vi/manager_display_service.h"
7#include "core/hle/service/vi/vi_results.h"
8
9namespace Service::VI {
10
11IManagerDisplayService::IManagerDisplayService(Core::System& system_,
12 Nvnflinger::Nvnflinger& nvnflinger)
13 : ServiceFramework{system_, "IManagerDisplayService"}, m_nvnflinger{nvnflinger} {
14 // clang-format off
15 static const FunctionInfo functions[] = {
16 {200, nullptr, "AllocateProcessHeapBlock"},
17 {201, nullptr, "FreeProcessHeapBlock"},
18 {1102, nullptr, "GetDisplayResolution"},
19 {2010, C<&IManagerDisplayService::CreateManagedLayer>, "CreateManagedLayer"},
20 {2011, nullptr, "DestroyManagedLayer"},
21 {2012, nullptr, "CreateStrayLayer"},
22 {2050, nullptr, "CreateIndirectLayer"},
23 {2051, nullptr, "DestroyIndirectLayer"},
24 {2052, nullptr, "CreateIndirectProducerEndPoint"},
25 {2053, nullptr, "DestroyIndirectProducerEndPoint"},
26 {2054, nullptr, "CreateIndirectConsumerEndPoint"},
27 {2055, nullptr, "DestroyIndirectConsumerEndPoint"},
28 {2060, nullptr, "CreateWatermarkCompositor"},
29 {2062, nullptr, "SetWatermarkText"},
30 {2063, nullptr, "SetWatermarkLayerStacks"},
31 {2300, nullptr, "AcquireLayerTexturePresentingEvent"},
32 {2301, nullptr, "ReleaseLayerTexturePresentingEvent"},
33 {2302, nullptr, "GetDisplayHotplugEvent"},
34 {2303, nullptr, "GetDisplayModeChangedEvent"},
35 {2402, nullptr, "GetDisplayHotplugState"},
36 {2501, nullptr, "GetCompositorErrorInfo"},
37 {2601, nullptr, "GetDisplayErrorEvent"},
38 {2701, nullptr, "GetDisplayFatalErrorEvent"},
39 {4201, nullptr, "SetDisplayAlpha"},
40 {4203, nullptr, "SetDisplayLayerStack"},
41 {4205, nullptr, "SetDisplayPowerState"},
42 {4206, nullptr, "SetDefaultDisplay"},
43 {4207, nullptr, "ResetDisplayPanel"},
44 {4208, nullptr, "SetDisplayFatalErrorEnabled"},
45 {4209, nullptr, "IsDisplayPanelOn"},
46 {4300, nullptr, "GetInternalPanelId"},
47 {6000, C<&IManagerDisplayService::AddToLayerStack>, "AddToLayerStack"},
48 {6001, nullptr, "RemoveFromLayerStack"},
49 {6002, C<&IManagerDisplayService::SetLayerVisibility>, "SetLayerVisibility"},
50 {6003, nullptr, "SetLayerConfig"},
51 {6004, nullptr, "AttachLayerPresentationTracer"},
52 {6005, nullptr, "DetachLayerPresentationTracer"},
53 {6006, nullptr, "StartLayerPresentationRecording"},
54 {6007, nullptr, "StopLayerPresentationRecording"},
55 {6008, nullptr, "StartLayerPresentationFenceWait"},
56 {6009, nullptr, "StopLayerPresentationFenceWait"},
57 {6010, nullptr, "GetLayerPresentationAllFencesExpiredEvent"},
58 {6011, nullptr, "EnableLayerAutoClearTransitionBuffer"},
59 {6012, nullptr, "DisableLayerAutoClearTransitionBuffer"},
60 {6013, nullptr, "SetLayerOpacity"},
61 {6014, nullptr, "AttachLayerWatermarkCompositor"},
62 {6015, nullptr, "DetachLayerWatermarkCompositor"},
63 {7000, nullptr, "SetContentVisibility"},
64 {8000, nullptr, "SetConductorLayer"},
65 {8001, nullptr, "SetTimestampTracking"},
66 {8100, nullptr, "SetIndirectProducerFlipOffset"},
67 {8200, nullptr, "CreateSharedBufferStaticStorage"},
68 {8201, nullptr, "CreateSharedBufferTransferMemory"},
69 {8202, nullptr, "DestroySharedBuffer"},
70 {8203, nullptr, "BindSharedLowLevelLayerToManagedLayer"},
71 {8204, nullptr, "BindSharedLowLevelLayerToIndirectLayer"},
72 {8207, nullptr, "UnbindSharedLowLevelLayer"},
73 {8208, nullptr, "ConnectSharedLowLevelLayerToSharedBuffer"},
74 {8209, nullptr, "DisconnectSharedLowLevelLayerFromSharedBuffer"},
75 {8210, nullptr, "CreateSharedLayer"},
76 {8211, nullptr, "DestroySharedLayer"},
77 {8216, nullptr, "AttachSharedLayerToLowLevelLayer"},
78 {8217, nullptr, "ForceDetachSharedLayerFromLowLevelLayer"},
79 {8218, nullptr, "StartDetachSharedLayerFromLowLevelLayer"},
80 {8219, nullptr, "FinishDetachSharedLayerFromLowLevelLayer"},
81 {8220, nullptr, "GetSharedLayerDetachReadyEvent"},
82 {8221, nullptr, "GetSharedLowLevelLayerSynchronizedEvent"},
83 {8222, nullptr, "CheckSharedLowLevelLayerSynchronized"},
84 {8223, nullptr, "RegisterSharedBufferImporterAruid"},
85 {8224, nullptr, "UnregisterSharedBufferImporterAruid"},
86 {8227, nullptr, "CreateSharedBufferProcessHeap"},
87 {8228, nullptr, "GetSharedLayerLayerStacks"},
88 {8229, nullptr, "SetSharedLayerLayerStacks"},
89 {8291, nullptr, "PresentDetachedSharedFrameBufferToLowLevelLayer"},
90 {8292, nullptr, "FillDetachedSharedFrameBufferColor"},
91 {8293, nullptr, "GetDetachedSharedFrameBufferImage"},
92 {8294, nullptr, "SetDetachedSharedFrameBufferImage"},
93 {8295, nullptr, "CopyDetachedSharedFrameBufferImage"},
94 {8296, nullptr, "SetDetachedSharedFrameBufferSubImage"},
95 {8297, nullptr, "GetSharedFrameBufferContentParameter"},
96 {8298, nullptr, "ExpandStartupLogoOnSharedFrameBuffer"},
97 };
98 // clang-format on
99
100 RegisterHandlers(functions);
101}
102
103IManagerDisplayService::~IManagerDisplayService() = default;
104
105Result IManagerDisplayService::CreateManagedLayer(Out<u64> out_layer_id, u32 unknown,
106 u64 display_id, AppletResourceUserId aruid) {
107 LOG_WARNING(Service_VI, "(STUBBED) called. unknown={}, display={}, aruid={}", unknown,
108 display_id, aruid.pid);
109
110 const auto layer_id = m_nvnflinger.CreateLayer(display_id);
111 if (!layer_id) {
112 LOG_ERROR(Service_VI, "Layer not found! display={}", display_id);
113 R_THROW(VI::ResultNotFound);
114 }
115
116 *out_layer_id = *layer_id;
117 R_SUCCEED();
118}
119
120Result IManagerDisplayService::AddToLayerStack(u32 stack_id, u64 layer_id) {
121 LOG_WARNING(Service_VI, "(STUBBED) called. stack_id={}, layer_id={}", stack_id, layer_id);
122 R_SUCCEED();
123}
124
125Result IManagerDisplayService::SetLayerVisibility(bool visible, u64 layer_id) {
126 LOG_WARNING(Service_VI, "(STUBBED) called, layer_id={}, visible={}", layer_id, visible);
127 R_SUCCEED();
128}
129
130} // namespace Service::VI
diff --git a/src/core/hle/service/vi/manager_display_service.h b/src/core/hle/service/vi/manager_display_service.h
new file mode 100644
index 000000000..60e646ee0
--- /dev/null
+++ b/src/core/hle/service/vi/manager_display_service.h
@@ -0,0 +1,24 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/cmif_types.h"
5#include "core/hle/service/service.h"
6
7namespace Service::VI {
8
9class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> {
10public:
11 explicit IManagerDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger);
12 ~IManagerDisplayService() override;
13
14private:
15 Result CreateManagedLayer(Out<u64> out_layer_id, u32 unknown, u64 display_id,
16 AppletResourceUserId aruid);
17 Result AddToLayerStack(u32 stack_id, u64 layer_id);
18 Result SetLayerVisibility(bool visible, u64 layer_id);
19
20private:
21 Nvnflinger::Nvnflinger& m_nvnflinger;
22};
23
24} // namespace Service::VI
diff --git a/src/core/hle/service/vi/manager_root_service.cpp b/src/core/hle/service/vi/manager_root_service.cpp
new file mode 100644
index 000000000..a7eee4f04
--- /dev/null
+++ b/src/core/hle/service/vi/manager_root_service.cpp
@@ -0,0 +1,38 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/cmif_serialization.h"
5#include "core/hle/service/vi/application_display_service.h"
6#include "core/hle/service/vi/manager_root_service.h"
7#include "core/hle/service/vi/service_creator.h"
8#include "core/hle/service/vi/vi.h"
9#include "core/hle/service/vi/vi_types.h"
10
11namespace Service::VI {
12
13IManagerRootService::IManagerRootService(
14 Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
15 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server)
16 : ServiceFramework{system_, "vi:m"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{
17 hos_binder_driver_server} {
18 static const FunctionInfo functions[] = {
19 {2, C<&IManagerRootService::GetDisplayService>, "GetDisplayService"},
20 {3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
21 {100, nullptr, "PrepareFatal"},
22 {101, nullptr, "ShowFatal"},
23 {102, nullptr, "DrawFatalRectangle"},
24 {103, nullptr, "DrawFatalText32"},
25 };
26 RegisterHandlers(functions);
27}
28
29IManagerRootService::~IManagerRootService() = default;
30
31Result IManagerRootService::GetDisplayService(
32 Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
33 LOG_DEBUG(Service_VI, "called");
34 R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger,
35 m_hos_binder_driver_server, Permission::Manager, policy));
36}
37
38} // namespace Service::VI
diff --git a/src/core/hle/service/vi/manager_root_service.h b/src/core/hle/service/vi/manager_root_service.h
new file mode 100644
index 000000000..e6cb77aeb
--- /dev/null
+++ b/src/core/hle/service/vi/manager_root_service.h
@@ -0,0 +1,38 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/service.h"
8
9namespace Core {
10class System;
11}
12
13namespace Service::Nvnflinger {
14class HosBinderDriverServer;
15class Nvnflinger;
16} // namespace Service::Nvnflinger
17
18namespace Service::VI {
19
20class IApplicationDisplayService;
21enum class Policy : u32;
22
23class IManagerRootService final : public ServiceFramework<IManagerRootService> {
24public:
25 explicit IManagerRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
26 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
27 ~IManagerRootService() override;
28
29private:
30 Result GetDisplayService(
31 Out<SharedPointer<IApplicationDisplayService>> out_application_display_service,
32 Policy policy);
33
34 Nvnflinger::Nvnflinger& m_nvnflinger;
35 Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server;
36};
37
38} // namespace Service::VI
diff --git a/src/core/hle/service/vi/service_creator.cpp b/src/core/hle/service/vi/service_creator.cpp
new file mode 100644
index 000000000..1de9d61a4
--- /dev/null
+++ b/src/core/hle/service/vi/service_creator.cpp
@@ -0,0 +1,39 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/vi/application_display_service.h"
5#include "core/hle/service/vi/service_creator.h"
6#include "core/hle/service/vi/vi_results.h"
7#include "core/hle/service/vi/vi_types.h"
8
9namespace Service::VI {
10
11static bool IsValidServiceAccess(Permission permission, Policy policy) {
12 if (permission == Permission::User) {
13 return policy == Policy::User;
14 }
15
16 if (permission == Permission::System || permission == Permission::Manager) {
17 return policy == Policy::User || policy == Policy::Compositor;
18 }
19
20 return false;
21}
22
23Result GetApplicationDisplayService(
24 std::shared_ptr<IApplicationDisplayService>* out_application_display_service,
25 Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
26 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, Permission permission,
27 Policy policy) {
28
29 if (!IsValidServiceAccess(permission, policy)) {
30 LOG_ERROR(Service_VI, "Permission denied for policy {}", policy);
31 R_THROW(ResultPermissionDenied);
32 }
33
34 *out_application_display_service =
35 std::make_shared<IApplicationDisplayService>(system, nvnflinger, hos_binder_driver_server);
36 R_SUCCEED();
37}
38
39} // namespace Service::VI
diff --git a/src/core/hle/service/vi/service_creator.h b/src/core/hle/service/vi/service_creator.h
new file mode 100644
index 000000000..8963bcd26
--- /dev/null
+++ b/src/core/hle/service/vi/service_creator.h
@@ -0,0 +1,33 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include <memory>
7
8#include "common/common_types.h"
9
10namespace Core {
11class System;
12}
13
14namespace Service::Nvnflinger {
15class HosBinderDriverServer;
16class Nvnflinger;
17} // namespace Service::Nvnflinger
18
19union Result;
20
21namespace Service::VI {
22
23class IApplicationDisplayService;
24enum class Permission;
25enum class Policy : u32;
26
27Result GetApplicationDisplayService(
28 std::shared_ptr<IApplicationDisplayService>* out_application_display_service,
29 Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
30 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, Permission permission,
31 Policy policy);
32
33} // namespace Service::VI
diff --git a/src/core/hle/service/vi/system_display_service.cpp b/src/core/hle/service/vi/system_display_service.cpp
new file mode 100644
index 000000000..1e1cfc817
--- /dev/null
+++ b/src/core/hle/service/vi/system_display_service.cpp
@@ -0,0 +1,145 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/settings.h"
5#include "core/hle/service/cmif_serialization.h"
6#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
7#include "core/hle/service/vi/system_display_service.h"
8#include "core/hle/service/vi/vi_types.h"
9
10namespace Service::VI {
11
12ISystemDisplayService::ISystemDisplayService(Core::System& system_,
13 Nvnflinger::Nvnflinger& nvnflinger)
14 : ServiceFramework{system_, "ISystemDisplayService"}, m_nvnflinger{nvnflinger} {
15 // clang-format off
16 static const FunctionInfo functions[] = {
17 {1200, nullptr, "GetZOrderCountMin"},
18 {1202, nullptr, "GetZOrderCountMax"},
19 {1203, nullptr, "GetDisplayLogicalResolution"},
20 {1204, nullptr, "SetDisplayMagnification"},
21 {2201, nullptr, "SetLayerPosition"},
22 {2203, nullptr, "SetLayerSize"},
23 {2204, nullptr, "GetLayerZ"},
24 {2205, C<&ISystemDisplayService::SetLayerZ>, "SetLayerZ"},
25 {2207, C<&ISystemDisplayService::SetLayerVisibility>, "SetLayerVisibility"},
26 {2209, nullptr, "SetLayerAlpha"},
27 {2210, nullptr, "SetLayerPositionAndSize"},
28 {2312, nullptr, "CreateStrayLayer"},
29 {2400, nullptr, "OpenIndirectLayer"},
30 {2401, nullptr, "CloseIndirectLayer"},
31 {2402, nullptr, "FlipIndirectLayer"},
32 {3000, nullptr, "ListDisplayModes"},
33 {3001, nullptr, "ListDisplayRgbRanges"},
34 {3002, nullptr, "ListDisplayContentTypes"},
35 {3200, C<&ISystemDisplayService::GetDisplayMode>, "GetDisplayMode"},
36 {3201, nullptr, "SetDisplayMode"},
37 {3202, nullptr, "GetDisplayUnderscan"},
38 {3203, nullptr, "SetDisplayUnderscan"},
39 {3204, nullptr, "GetDisplayContentType"},
40 {3205, nullptr, "SetDisplayContentType"},
41 {3206, nullptr, "GetDisplayRgbRange"},
42 {3207, nullptr, "SetDisplayRgbRange"},
43 {3208, nullptr, "GetDisplayCmuMode"},
44 {3209, nullptr, "SetDisplayCmuMode"},
45 {3210, nullptr, "GetDisplayContrastRatio"},
46 {3211, nullptr, "SetDisplayContrastRatio"},
47 {3214, nullptr, "GetDisplayGamma"},
48 {3215, nullptr, "SetDisplayGamma"},
49 {3216, nullptr, "GetDisplayCmuLuma"},
50 {3217, nullptr, "SetDisplayCmuLuma"},
51 {3218, nullptr, "SetDisplayCrcMode"},
52 {6013, nullptr, "GetLayerPresentationSubmissionTimestamps"},
53 {8225, C<&ISystemDisplayService::GetSharedBufferMemoryHandleId>, "GetSharedBufferMemoryHandleId"},
54 {8250, C<&ISystemDisplayService::OpenSharedLayer>, "OpenSharedLayer"},
55 {8251, nullptr, "CloseSharedLayer"},
56 {8252, C<&ISystemDisplayService::ConnectSharedLayer>, "ConnectSharedLayer"},
57 {8253, nullptr, "DisconnectSharedLayer"},
58 {8254, C<&ISystemDisplayService::AcquireSharedFrameBuffer>, "AcquireSharedFrameBuffer"},
59 {8255, C<&ISystemDisplayService::PresentSharedFrameBuffer>, "PresentSharedFrameBuffer"},
60 {8256, C<&ISystemDisplayService::GetSharedFrameBufferAcquirableEvent>, "GetSharedFrameBufferAcquirableEvent"},
61 {8257, nullptr, "FillSharedFrameBufferColor"},
62 {8258, nullptr, "CancelSharedFrameBuffer"},
63 {9000, nullptr, "GetDp2hdmiController"},
64 };
65 // clang-format on
66 RegisterHandlers(functions);
67}
68
69ISystemDisplayService::~ISystemDisplayService() = default;
70
71Result ISystemDisplayService::SetLayerZ(u32 z_value, u64 layer_id) {
72 LOG_WARNING(Service_VI, "(STUBBED) called. layer_id={}, z_value={}", layer_id, z_value);
73 R_SUCCEED();
74}
75
76// This function currently does nothing but return a success error code in
77// the vi library itself, so do the same thing, but log out the passed in values.
78Result ISystemDisplayService::SetLayerVisibility(bool visible, u64 layer_id) {
79 LOG_DEBUG(Service_VI, "called, layer_id={}, visible={}", layer_id, visible);
80 R_SUCCEED();
81}
82
83Result ISystemDisplayService::GetDisplayMode(Out<u32> out_width, Out<u32> out_height,
84 Out<f32> out_refresh_rate, Out<u32> out_unknown) {
85 LOG_WARNING(Service_VI, "(STUBBED) called");
86
87 if (Settings::IsDockedMode()) {
88 *out_width = static_cast<u32>(DisplayResolution::DockedWidth);
89 *out_height = static_cast<u32>(DisplayResolution::DockedHeight);
90 } else {
91 *out_width = static_cast<u32>(DisplayResolution::UndockedWidth);
92 *out_height = static_cast<u32>(DisplayResolution::UndockedHeight);
93 }
94
95 *out_refresh_rate = 60.f; // This wouldn't seem to be correct for 30 fps games.
96 *out_unknown = 0;
97
98 R_SUCCEED();
99}
100
101Result ISystemDisplayService::GetSharedBufferMemoryHandleId(
102 Out<s32> out_nvmap_handle, Out<u64> out_size,
103 OutLargeData<Nvnflinger::SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout,
104 u64 buffer_id, ClientAppletResourceUserId aruid) {
105 LOG_INFO(Service_VI, "called. buffer_id={}, aruid={:#x}", buffer_id, aruid.pid);
106
107 R_RETURN(m_nvnflinger.GetSystemBufferManager().GetSharedBufferMemoryHandleId(
108 out_size, out_nvmap_handle, out_pool_layout, buffer_id, aruid.pid));
109}
110
111Result ISystemDisplayService::OpenSharedLayer(u64 layer_id) {
112 LOG_INFO(Service_VI, "(STUBBED) called. layer_id={}", layer_id);
113 R_SUCCEED();
114}
115
116Result ISystemDisplayService::ConnectSharedLayer(u64 layer_id) {
117 LOG_INFO(Service_VI, "(STUBBED) called. layer_id={}", layer_id);
118 R_SUCCEED();
119}
120
121Result ISystemDisplayService::AcquireSharedFrameBuffer(Out<android::Fence> out_fence,
122 Out<std::array<s32, 4>> out_slots,
123 Out<s64> out_target_slot, u64 layer_id) {
124 LOG_DEBUG(Service_VI, "called");
125 R_RETURN(m_nvnflinger.GetSystemBufferManager().AcquireSharedFrameBuffer(
126 out_fence, *out_slots, out_target_slot, layer_id));
127}
128
129Result ISystemDisplayService::PresentSharedFrameBuffer(android::Fence fence,
130 Common::Rectangle<s32> crop_region,
131 u32 window_transform, s32 swap_interval,
132 u64 layer_id, s64 surface_id) {
133 LOG_DEBUG(Service_VI, "called");
134 R_RETURN(m_nvnflinger.GetSystemBufferManager().PresentSharedFrameBuffer(
135 fence, crop_region, window_transform, swap_interval, layer_id, surface_id));
136}
137
138Result ISystemDisplayService::GetSharedFrameBufferAcquirableEvent(
139 OutCopyHandle<Kernel::KReadableEvent> out_event, u64 layer_id) {
140 LOG_DEBUG(Service_VI, "called");
141 R_RETURN(m_nvnflinger.GetSystemBufferManager().GetSharedFrameBufferAcquirableEvent(out_event,
142 layer_id));
143}
144
145} // namespace Service::VI
diff --git a/src/core/hle/service/vi/system_display_service.h b/src/core/hle/service/vi/system_display_service.h
new file mode 100644
index 000000000..cfcb196fd
--- /dev/null
+++ b/src/core/hle/service/vi/system_display_service.h
@@ -0,0 +1,45 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/math_util.h"
5#include "core/hle/service/cmif_types.h"
6#include "core/hle/service/nvnflinger/ui/fence.h"
7#include "core/hle/service/service.h"
8
9namespace Service::Nvnflinger {
10struct SharedMemoryPoolLayout;
11}
12
13namespace Service::VI {
14
15class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> {
16public:
17 explicit ISystemDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger);
18 ~ISystemDisplayService() override;
19
20private:
21 Result SetLayerZ(u32 z_value, u64 layer_id);
22 Result SetLayerVisibility(bool visible, u64 layer_id);
23 Result GetDisplayMode(Out<u32> out_width, Out<u32> out_height, Out<f32> out_refresh_rate,
24 Out<u32> out_unknown);
25
26 Result GetSharedBufferMemoryHandleId(
27 Out<s32> out_nvmap_handle, Out<u64> out_size,
28 OutLargeData<Nvnflinger::SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout,
29 u64 buffer_id, ClientAppletResourceUserId aruid);
30 Result OpenSharedLayer(u64 layer_id);
31 Result ConnectSharedLayer(u64 layer_id);
32 Result GetSharedFrameBufferAcquirableEvent(OutCopyHandle<Kernel::KReadableEvent> out_event,
33 u64 layer_id);
34 Result AcquireSharedFrameBuffer(Out<android::Fence> out_fence,
35 Out<std::array<s32, 4>> out_slots, Out<s64> out_target_slot,
36 u64 layer_id);
37 Result PresentSharedFrameBuffer(android::Fence fence, Common::Rectangle<s32> crop_region,
38 u32 window_transform, s32 swap_interval, u64 layer_id,
39 s64 surface_id);
40
41private:
42 Nvnflinger::Nvnflinger& m_nvnflinger;
43};
44
45} // namespace Service::VI
diff --git a/src/core/hle/service/vi/system_root_service.cpp b/src/core/hle/service/vi/system_root_service.cpp
new file mode 100644
index 000000000..8789b4cfb
--- /dev/null
+++ b/src/core/hle/service/vi/system_root_service.cpp
@@ -0,0 +1,33 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/cmif_serialization.h"
5#include "core/hle/service/vi/application_display_service.h"
6#include "core/hle/service/vi/service_creator.h"
7#include "core/hle/service/vi/system_root_service.h"
8#include "core/hle/service/vi/vi.h"
9#include "core/hle/service/vi/vi_types.h"
10
11namespace Service::VI {
12
13ISystemRootService::ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
14 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server)
15 : ServiceFramework{system_, "vi:s"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{
16 hos_binder_driver_server} {
17 static const FunctionInfo functions[] = {
18 {1, C<&ISystemRootService::GetDisplayService>, "GetDisplayService"},
19 {3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
20 };
21 RegisterHandlers(functions);
22}
23
24ISystemRootService::~ISystemRootService() = default;
25
26Result ISystemRootService::GetDisplayService(
27 Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
28 LOG_DEBUG(Service_VI, "called");
29 R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger,
30 m_hos_binder_driver_server, Permission::System, policy));
31}
32
33} // namespace Service::VI
diff --git a/src/core/hle/service/vi/system_root_service.h b/src/core/hle/service/vi/system_root_service.h
new file mode 100644
index 000000000..2c547faa5
--- /dev/null
+++ b/src/core/hle/service/vi/system_root_service.h
@@ -0,0 +1,38 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/service.h"
8
9namespace Core {
10class System;
11}
12
13namespace Service::Nvnflinger {
14class HosBinderDriverServer;
15class Nvnflinger;
16} // namespace Service::Nvnflinger
17
18namespace Service::VI {
19
20class IApplicationDisplayService;
21enum class Policy : u32;
22
23class ISystemRootService final : public ServiceFramework<ISystemRootService> {
24public:
25 explicit ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
26 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
27 ~ISystemRootService() override;
28
29private:
30 Result GetDisplayService(
31 Out<SharedPointer<IApplicationDisplayService>> out_application_display_service,
32 Policy policy);
33
34 Nvnflinger::Nvnflinger& m_nvnflinger;
35 Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server;
36};
37
38} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index d508ed28c..304e589b7 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -1,974 +1,25 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include <algorithm>
5#include <array>
6#include <cstring>
7#include <memory>
8#include <optional>
9#include <type_traits>
10#include <utility>
11
12#include "common/alignment.h"
13#include "common/assert.h"
14#include "common/common_funcs.h"
15#include "common/logging/log.h"
16#include "common/math_util.h"
17#include "common/settings.h"
18#include "common/string_util.h"
19#include "common/swap.h"
20#include "core/core_timing.h"
21#include "core/hle/kernel/k_readable_event.h"
22#include "core/hle/kernel/k_thread.h"
23#include "core/hle/service/ipc_helpers.h"
24#include "core/hle/service/nvdrv/devices/nvmap.h"
25#include "core/hle/service/nvdrv/nvdata.h"
26#include "core/hle/service/nvdrv/nvdrv.h"
27#include "core/hle/service/nvnflinger/binder.h"
28#include "core/hle/service/nvnflinger/buffer_queue_producer.h"
29#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
30#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
31#include "core/hle/service/nvnflinger/nvnflinger.h"
32#include "core/hle/service/nvnflinger/parcel.h"
33#include "core/hle/service/server_manager.h" 4#include "core/hle/service/server_manager.h"
34#include "core/hle/service/service.h" 5#include "core/hle/service/vi/application_display_service.h"
6#include "core/hle/service/vi/application_root_service.h"
7#include "core/hle/service/vi/manager_root_service.h"
8#include "core/hle/service/vi/system_root_service.h"
35#include "core/hle/service/vi/vi.h" 9#include "core/hle/service/vi/vi.h"
36#include "core/hle/service/vi/vi_m.h"
37#include "core/hle/service/vi/vi_results.h"
38#include "core/hle/service/vi/vi_s.h"
39#include "core/hle/service/vi/vi_u.h"
40 10
41namespace Service::VI { 11namespace Service::VI {
42 12
43struct DisplayInfo {
44 /// The name of this particular display.
45 char display_name[0x40]{"Default"};
46
47 /// Whether or not the display has a limited number of layers.
48 u8 has_limited_layers{1};
49 INSERT_PADDING_BYTES(7);
50
51 /// Indicates the total amount of layers supported by the display.
52 /// @note This is only valid if has_limited_layers is set.
53 u64 max_layers{1};
54
55 /// Maximum width in pixels.
56 u64 width{1920};
57
58 /// Maximum height in pixels.
59 u64 height{1080};
60};
61static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size");
62
63class NativeWindow final {
64public:
65 constexpr explicit NativeWindow(u32 id_) : id{id_} {}
66 constexpr explicit NativeWindow(const NativeWindow& other) = default;
67
68private:
69 const u32 magic = 2;
70 const u32 process_id = 1;
71 const u64 id;
72 INSERT_PADDING_WORDS(2);
73 std::array<u8, 8> dispdrv = {'d', 'i', 's', 'p', 'd', 'r', 'v', '\0'};
74 INSERT_PADDING_WORDS(2);
75};
76static_assert(sizeof(NativeWindow) == 0x28, "NativeWindow has wrong size");
77
78class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> {
79public:
80 explicit IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server_)
81 : ServiceFramework{system_, "IHOSBinderDriver"}, server(server_) {
82 static const FunctionInfo functions[] = {
83 {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"},
84 {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"},
85 {2, &IHOSBinderDriver::GetNativeHandle, "GetNativeHandle"},
86 {3, &IHOSBinderDriver::TransactParcel, "TransactParcelAuto"},
87 };
88 RegisterHandlers(functions);
89 }
90
91private:
92 void TransactParcel(HLERequestContext& ctx) {
93 IPC::RequestParser rp{ctx};
94 const u32 id = rp.Pop<u32>();
95 const auto transaction = static_cast<android::TransactionId>(rp.Pop<u32>());
96 const u32 flags = rp.Pop<u32>();
97
98 LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id,
99 transaction, flags);
100
101 server.TryGetProducer(id)->Transact(ctx, transaction, flags);
102
103 IPC::ResponseBuilder rb{ctx, 2};
104 rb.Push(ResultSuccess);
105 }
106
107 void AdjustRefcount(HLERequestContext& ctx) {
108 IPC::RequestParser rp{ctx};
109 const u32 id = rp.Pop<u32>();
110 const s32 addval = rp.PopRaw<s32>();
111 const u32 type = rp.Pop<u32>();
112
113 LOG_WARNING(Service_VI, "(STUBBED) called id={}, addval={:08X}, type={:08X}", id, addval,
114 type);
115
116 IPC::ResponseBuilder rb{ctx, 2};
117 rb.Push(ResultSuccess);
118 }
119
120 void GetNativeHandle(HLERequestContext& ctx) {
121 IPC::RequestParser rp{ctx};
122 const u32 id = rp.Pop<u32>();
123 const u32 unknown = rp.Pop<u32>();
124
125 LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown);
126
127 IPC::ResponseBuilder rb{ctx, 2, 1};
128 rb.Push(ResultSuccess);
129 rb.PushCopyObjects(server.TryGetProducer(id)->GetNativeHandle());
130 }
131
132private:
133 Nvnflinger::HosBinderDriverServer& server;
134};
135
136class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> {
137public:
138 explicit ISystemDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_)
139 : ServiceFramework{system_, "ISystemDisplayService"}, nvnflinger{nvnflinger_} {
140 // clang-format off
141 static const FunctionInfo functions[] = {
142 {1200, nullptr, "GetZOrderCountMin"},
143 {1202, nullptr, "GetZOrderCountMax"},
144 {1203, nullptr, "GetDisplayLogicalResolution"},
145 {1204, nullptr, "SetDisplayMagnification"},
146 {2201, nullptr, "SetLayerPosition"},
147 {2203, nullptr, "SetLayerSize"},
148 {2204, nullptr, "GetLayerZ"},
149 {2205, &ISystemDisplayService::SetLayerZ, "SetLayerZ"},
150 {2207, &ISystemDisplayService::SetLayerVisibility, "SetLayerVisibility"},
151 {2209, nullptr, "SetLayerAlpha"},
152 {2210, nullptr, "SetLayerPositionAndSize"},
153 {2312, nullptr, "CreateStrayLayer"},
154 {2400, nullptr, "OpenIndirectLayer"},
155 {2401, nullptr, "CloseIndirectLayer"},
156 {2402, nullptr, "FlipIndirectLayer"},
157 {3000, nullptr, "ListDisplayModes"},
158 {3001, nullptr, "ListDisplayRgbRanges"},
159 {3002, nullptr, "ListDisplayContentTypes"},
160 {3200, &ISystemDisplayService::GetDisplayMode, "GetDisplayMode"},
161 {3201, nullptr, "SetDisplayMode"},
162 {3202, nullptr, "GetDisplayUnderscan"},
163 {3203, nullptr, "SetDisplayUnderscan"},
164 {3204, nullptr, "GetDisplayContentType"},
165 {3205, nullptr, "SetDisplayContentType"},
166 {3206, nullptr, "GetDisplayRgbRange"},
167 {3207, nullptr, "SetDisplayRgbRange"},
168 {3208, nullptr, "GetDisplayCmuMode"},
169 {3209, nullptr, "SetDisplayCmuMode"},
170 {3210, nullptr, "GetDisplayContrastRatio"},
171 {3211, nullptr, "SetDisplayContrastRatio"},
172 {3214, nullptr, "GetDisplayGamma"},
173 {3215, nullptr, "SetDisplayGamma"},
174 {3216, nullptr, "GetDisplayCmuLuma"},
175 {3217, nullptr, "SetDisplayCmuLuma"},
176 {3218, nullptr, "SetDisplayCrcMode"},
177 {6013, nullptr, "GetLayerPresentationSubmissionTimestamps"},
178 {8225, &ISystemDisplayService::GetSharedBufferMemoryHandleId, "GetSharedBufferMemoryHandleId"},
179 {8250, &ISystemDisplayService::OpenSharedLayer, "OpenSharedLayer"},
180 {8251, nullptr, "CloseSharedLayer"},
181 {8252, &ISystemDisplayService::ConnectSharedLayer, "ConnectSharedLayer"},
182 {8253, nullptr, "DisconnectSharedLayer"},
183 {8254, &ISystemDisplayService::AcquireSharedFrameBuffer, "AcquireSharedFrameBuffer"},
184 {8255, &ISystemDisplayService::PresentSharedFrameBuffer, "PresentSharedFrameBuffer"},
185 {8256, &ISystemDisplayService::GetSharedFrameBufferAcquirableEvent, "GetSharedFrameBufferAcquirableEvent"},
186 {8257, nullptr, "FillSharedFrameBufferColor"},
187 {8258, nullptr, "CancelSharedFrameBuffer"},
188 {9000, nullptr, "GetDp2hdmiController"},
189 };
190 // clang-format on
191 RegisterHandlers(functions);
192 }
193
194private:
195 void GetSharedBufferMemoryHandleId(HLERequestContext& ctx) {
196 IPC::RequestParser rp{ctx};
197 const u64 buffer_id = rp.PopRaw<u64>();
198 const u64 aruid = ctx.GetPID();
199
200 LOG_INFO(Service_VI, "called. buffer_id={:#x}, aruid={:#x}", buffer_id, aruid);
201
202 struct OutputParameters {
203 s32 nvmap_handle;
204 u64 size;
205 };
206
207 OutputParameters out{};
208 Nvnflinger::SharedMemoryPoolLayout layout{};
209 const auto result = nvnflinger.GetSystemBufferManager().GetSharedBufferMemoryHandleId(
210 &out.size, &out.nvmap_handle, &layout, buffer_id, aruid);
211
212 ctx.WriteBuffer(&layout, sizeof(layout));
213
214 IPC::ResponseBuilder rb{ctx, 6};
215 rb.Push(result);
216 rb.PushRaw(out);
217 }
218
219 void OpenSharedLayer(HLERequestContext& ctx) {
220 IPC::RequestParser rp{ctx};
221 const u64 layer_id = rp.PopRaw<u64>();
222
223 LOG_INFO(Service_VI, "(STUBBED) called. layer_id={:#x}", layer_id);
224
225 IPC::ResponseBuilder rb{ctx, 2};
226 rb.Push(ResultSuccess);
227 }
228
229 void ConnectSharedLayer(HLERequestContext& ctx) {
230 IPC::RequestParser rp{ctx};
231 const u64 layer_id = rp.PopRaw<u64>();
232
233 LOG_INFO(Service_VI, "(STUBBED) called. layer_id={:#x}", layer_id);
234
235 IPC::ResponseBuilder rb{ctx, 2};
236 rb.Push(ResultSuccess);
237 }
238
239 void GetSharedFrameBufferAcquirableEvent(HLERequestContext& ctx) {
240 LOG_DEBUG(Service_VI, "called");
241
242 IPC::RequestParser rp{ctx};
243 const u64 layer_id = rp.PopRaw<u64>();
244
245 Kernel::KReadableEvent* event{};
246 const auto result = nvnflinger.GetSystemBufferManager().GetSharedFrameBufferAcquirableEvent(
247 &event, layer_id);
248
249 IPC::ResponseBuilder rb{ctx, 2, 1};
250 rb.Push(result);
251 rb.PushCopyObjects(event);
252 }
253
254 void AcquireSharedFrameBuffer(HLERequestContext& ctx) {
255 LOG_DEBUG(Service_VI, "called");
256
257 IPC::RequestParser rp{ctx};
258 const u64 layer_id = rp.PopRaw<u64>();
259
260 struct OutputParameters {
261 android::Fence fence;
262 std::array<s32, 4> slots;
263 s64 target_slot;
264 };
265 static_assert(sizeof(OutputParameters) == 0x40, "OutputParameters has wrong size");
266
267 OutputParameters out{};
268 const auto result = nvnflinger.GetSystemBufferManager().AcquireSharedFrameBuffer(
269 &out.fence, out.slots, &out.target_slot, layer_id);
270
271 IPC::ResponseBuilder rb{ctx, 18};
272 rb.Push(result);
273 rb.PushRaw(out);
274 }
275
276 void PresentSharedFrameBuffer(HLERequestContext& ctx) {
277 LOG_DEBUG(Service_VI, "called");
278
279 struct InputParameters {
280 android::Fence fence;
281 Common::Rectangle<s32> crop_region;
282 u32 window_transform;
283 s32 swap_interval;
284 u64 layer_id;
285 s64 surface_id;
286 };
287 static_assert(sizeof(InputParameters) == 0x50, "InputParameters has wrong size");
288
289 IPC::RequestParser rp{ctx};
290 auto input = rp.PopRaw<InputParameters>();
291
292 const auto result = nvnflinger.GetSystemBufferManager().PresentSharedFrameBuffer(
293 input.fence, input.crop_region, input.window_transform, input.swap_interval,
294 input.layer_id, input.surface_id);
295 IPC::ResponseBuilder rb{ctx, 2};
296 rb.Push(result);
297 }
298
299 void SetLayerZ(HLERequestContext& ctx) {
300 IPC::RequestParser rp{ctx};
301 const u64 layer_id = rp.Pop<u64>();
302 const u64 z_value = rp.Pop<u64>();
303
304 LOG_WARNING(Service_VI, "(STUBBED) called. layer_id=0x{:016X}, z_value=0x{:016X}", layer_id,
305 z_value);
306
307 IPC::ResponseBuilder rb{ctx, 2};
308 rb.Push(ResultSuccess);
309 }
310
311 // This function currently does nothing but return a success error code in
312 // the vi library itself, so do the same thing, but log out the passed in values.
313 void SetLayerVisibility(HLERequestContext& ctx) {
314 IPC::RequestParser rp{ctx};
315 const u64 layer_id = rp.Pop<u64>();
316 const bool visibility = rp.Pop<bool>();
317
318 LOG_DEBUG(Service_VI, "called, layer_id=0x{:08X}, visibility={}", layer_id, visibility);
319
320 IPC::ResponseBuilder rb{ctx, 2};
321 rb.Push(ResultSuccess);
322 }
323
324 void GetDisplayMode(HLERequestContext& ctx) {
325 LOG_WARNING(Service_VI, "(STUBBED) called");
326
327 IPC::ResponseBuilder rb{ctx, 6};
328 rb.Push(ResultSuccess);
329
330 if (Settings::IsDockedMode()) {
331 rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth));
332 rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight));
333 } else {
334 rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedWidth));
335 rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedHeight));
336 }
337
338 rb.PushRaw<float>(60.0f); // This wouldn't seem to be correct for 30 fps games.
339 rb.Push<u32>(0);
340 }
341
342private:
343 Nvnflinger::Nvnflinger& nvnflinger;
344};
345
346class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> {
347public:
348 explicit IManagerDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_)
349 : ServiceFramework{system_, "IManagerDisplayService"}, nvnflinger{nvnflinger_} {
350 // clang-format off
351 static const FunctionInfo functions[] = {
352 {200, nullptr, "AllocateProcessHeapBlock"},
353 {201, nullptr, "FreeProcessHeapBlock"},
354 {1020, &IManagerDisplayService::CloseDisplay, "CloseDisplay"},
355 {1102, nullptr, "GetDisplayResolution"},
356 {2010, &IManagerDisplayService::CreateManagedLayer, "CreateManagedLayer"},
357 {2011, nullptr, "DestroyManagedLayer"},
358 {2012, nullptr, "CreateStrayLayer"},
359 {2050, nullptr, "CreateIndirectLayer"},
360 {2051, nullptr, "DestroyIndirectLayer"},
361 {2052, nullptr, "CreateIndirectProducerEndPoint"},
362 {2053, nullptr, "DestroyIndirectProducerEndPoint"},
363 {2054, nullptr, "CreateIndirectConsumerEndPoint"},
364 {2055, nullptr, "DestroyIndirectConsumerEndPoint"},
365 {2060, nullptr, "CreateWatermarkCompositor"},
366 {2062, nullptr, "SetWatermarkText"},
367 {2063, nullptr, "SetWatermarkLayerStacks"},
368 {2300, nullptr, "AcquireLayerTexturePresentingEvent"},
369 {2301, nullptr, "ReleaseLayerTexturePresentingEvent"},
370 {2302, nullptr, "GetDisplayHotplugEvent"},
371 {2303, nullptr, "GetDisplayModeChangedEvent"},
372 {2402, nullptr, "GetDisplayHotplugState"},
373 {2501, nullptr, "GetCompositorErrorInfo"},
374 {2601, nullptr, "GetDisplayErrorEvent"},
375 {2701, nullptr, "GetDisplayFatalErrorEvent"},
376 {4201, nullptr, "SetDisplayAlpha"},
377 {4203, nullptr, "SetDisplayLayerStack"},
378 {4205, nullptr, "SetDisplayPowerState"},
379 {4206, nullptr, "SetDefaultDisplay"},
380 {4207, nullptr, "ResetDisplayPanel"},
381 {4208, nullptr, "SetDisplayFatalErrorEnabled"},
382 {4209, nullptr, "IsDisplayPanelOn"},
383 {4300, nullptr, "GetInternalPanelId"},
384 {6000, &IManagerDisplayService::AddToLayerStack, "AddToLayerStack"},
385 {6001, nullptr, "RemoveFromLayerStack"},
386 {6002, &IManagerDisplayService::SetLayerVisibility, "SetLayerVisibility"},
387 {6003, nullptr, "SetLayerConfig"},
388 {6004, nullptr, "AttachLayerPresentationTracer"},
389 {6005, nullptr, "DetachLayerPresentationTracer"},
390 {6006, nullptr, "StartLayerPresentationRecording"},
391 {6007, nullptr, "StopLayerPresentationRecording"},
392 {6008, nullptr, "StartLayerPresentationFenceWait"},
393 {6009, nullptr, "StopLayerPresentationFenceWait"},
394 {6010, nullptr, "GetLayerPresentationAllFencesExpiredEvent"},
395 {6011, nullptr, "EnableLayerAutoClearTransitionBuffer"},
396 {6012, nullptr, "DisableLayerAutoClearTransitionBuffer"},
397 {6013, nullptr, "SetLayerOpacity"},
398 {6014, nullptr, "AttachLayerWatermarkCompositor"},
399 {6015, nullptr, "DetachLayerWatermarkCompositor"},
400 {7000, nullptr, "SetContentVisibility"},
401 {8000, nullptr, "SetConductorLayer"},
402 {8001, nullptr, "SetTimestampTracking"},
403 {8100, nullptr, "SetIndirectProducerFlipOffset"},
404 {8200, nullptr, "CreateSharedBufferStaticStorage"},
405 {8201, nullptr, "CreateSharedBufferTransferMemory"},
406 {8202, nullptr, "DestroySharedBuffer"},
407 {8203, nullptr, "BindSharedLowLevelLayerToManagedLayer"},
408 {8204, nullptr, "BindSharedLowLevelLayerToIndirectLayer"},
409 {8207, nullptr, "UnbindSharedLowLevelLayer"},
410 {8208, nullptr, "ConnectSharedLowLevelLayerToSharedBuffer"},
411 {8209, nullptr, "DisconnectSharedLowLevelLayerFromSharedBuffer"},
412 {8210, nullptr, "CreateSharedLayer"},
413 {8211, nullptr, "DestroySharedLayer"},
414 {8216, nullptr, "AttachSharedLayerToLowLevelLayer"},
415 {8217, nullptr, "ForceDetachSharedLayerFromLowLevelLayer"},
416 {8218, nullptr, "StartDetachSharedLayerFromLowLevelLayer"},
417 {8219, nullptr, "FinishDetachSharedLayerFromLowLevelLayer"},
418 {8220, nullptr, "GetSharedLayerDetachReadyEvent"},
419 {8221, nullptr, "GetSharedLowLevelLayerSynchronizedEvent"},
420 {8222, nullptr, "CheckSharedLowLevelLayerSynchronized"},
421 {8223, nullptr, "RegisterSharedBufferImporterAruid"},
422 {8224, nullptr, "UnregisterSharedBufferImporterAruid"},
423 {8227, nullptr, "CreateSharedBufferProcessHeap"},
424 {8228, nullptr, "GetSharedLayerLayerStacks"},
425 {8229, nullptr, "SetSharedLayerLayerStacks"},
426 {8291, nullptr, "PresentDetachedSharedFrameBufferToLowLevelLayer"},
427 {8292, nullptr, "FillDetachedSharedFrameBufferColor"},
428 {8293, nullptr, "GetDetachedSharedFrameBufferImage"},
429 {8294, nullptr, "SetDetachedSharedFrameBufferImage"},
430 {8295, nullptr, "CopyDetachedSharedFrameBufferImage"},
431 {8296, nullptr, "SetDetachedSharedFrameBufferSubImage"},
432 {8297, nullptr, "GetSharedFrameBufferContentParameter"},
433 {8298, nullptr, "ExpandStartupLogoOnSharedFrameBuffer"},
434 };
435 // clang-format on
436
437 RegisterHandlers(functions);
438 }
439
440private:
441 void CloseDisplay(HLERequestContext& ctx) {
442 IPC::RequestParser rp{ctx};
443 const u64 display = rp.Pop<u64>();
444
445 const Result rc = nvnflinger.CloseDisplay(display) ? ResultSuccess : ResultUnknown;
446
447 IPC::ResponseBuilder rb{ctx, 2};
448 rb.Push(rc);
449 }
450
451 void CreateManagedLayer(HLERequestContext& ctx) {
452 IPC::RequestParser rp{ctx};
453 const u32 unknown = rp.Pop<u32>();
454 rp.Skip(1, false);
455 const u64 display = rp.Pop<u64>();
456 const u64 aruid = rp.Pop<u64>();
457
458 LOG_WARNING(Service_VI,
459 "(STUBBED) called. unknown=0x{:08X}, display=0x{:016X}, aruid=0x{:016X}",
460 unknown, display, aruid);
461
462 const auto layer_id = nvnflinger.CreateLayer(display);
463 if (!layer_id) {
464 LOG_ERROR(Service_VI, "Layer not found! display=0x{:016X}", display);
465 IPC::ResponseBuilder rb{ctx, 2};
466 rb.Push(ResultNotFound);
467 return;
468 }
469
470 IPC::ResponseBuilder rb{ctx, 4};
471 rb.Push(ResultSuccess);
472 rb.Push(*layer_id);
473 }
474
475 void AddToLayerStack(HLERequestContext& ctx) {
476 IPC::RequestParser rp{ctx};
477 const u32 stack = rp.Pop<u32>();
478 const u64 layer_id = rp.Pop<u64>();
479
480 LOG_WARNING(Service_VI, "(STUBBED) called. stack=0x{:08X}, layer_id=0x{:016X}", stack,
481 layer_id);
482
483 IPC::ResponseBuilder rb{ctx, 2};
484 rb.Push(ResultSuccess);
485 }
486
487 void SetLayerVisibility(HLERequestContext& ctx) {
488 IPC::RequestParser rp{ctx};
489 const u64 layer_id = rp.Pop<u64>();
490 const bool visibility = rp.Pop<bool>();
491
492 LOG_WARNING(Service_VI, "(STUBBED) called, layer_id=0x{:X}, visibility={}", layer_id,
493 visibility);
494
495 IPC::ResponseBuilder rb{ctx, 2};
496 rb.Push(ResultSuccess);
497 }
498
499 Nvnflinger::Nvnflinger& nvnflinger;
500};
501
502class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> {
503public:
504 IApplicationDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_,
505 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)
506 : ServiceFramework{system_, "IApplicationDisplayService"}, nvnflinger{nvnflinger_},
507 hos_binder_driver_server{hos_binder_driver_server_} {
508
509 static const FunctionInfo functions[] = {
510 {100, &IApplicationDisplayService::GetRelayService, "GetRelayService"},
511 {101, &IApplicationDisplayService::GetSystemDisplayService, "GetSystemDisplayService"},
512 {102, &IApplicationDisplayService::GetManagerDisplayService,
513 "GetManagerDisplayService"},
514 {103, &IApplicationDisplayService::GetIndirectDisplayTransactionService,
515 "GetIndirectDisplayTransactionService"},
516 {1000, &IApplicationDisplayService::ListDisplays, "ListDisplays"},
517 {1010, &IApplicationDisplayService::OpenDisplay, "OpenDisplay"},
518 {1011, &IApplicationDisplayService::OpenDefaultDisplay, "OpenDefaultDisplay"},
519 {1020, &IApplicationDisplayService::CloseDisplay, "CloseDisplay"},
520 {1101, &IApplicationDisplayService::SetDisplayEnabled, "SetDisplayEnabled"},
521 {1102, &IApplicationDisplayService::GetDisplayResolution, "GetDisplayResolution"},
522 {2020, &IApplicationDisplayService::OpenLayer, "OpenLayer"},
523 {2021, &IApplicationDisplayService::CloseLayer, "CloseLayer"},
524 {2030, &IApplicationDisplayService::CreateStrayLayer, "CreateStrayLayer"},
525 {2031, &IApplicationDisplayService::DestroyStrayLayer, "DestroyStrayLayer"},
526 {2101, &IApplicationDisplayService::SetLayerScalingMode, "SetLayerScalingMode"},
527 {2102, &IApplicationDisplayService::ConvertScalingMode, "ConvertScalingMode"},
528 {2450, &IApplicationDisplayService::GetIndirectLayerImageMap,
529 "GetIndirectLayerImageMap"},
530 {2451, nullptr, "GetIndirectLayerImageCropMap"},
531 {2460, &IApplicationDisplayService::GetIndirectLayerImageRequiredMemoryInfo,
532 "GetIndirectLayerImageRequiredMemoryInfo"},
533 {5202, &IApplicationDisplayService::GetDisplayVsyncEvent, "GetDisplayVsyncEvent"},
534 {5203, nullptr, "GetDisplayVsyncEventForDebug"},
535 };
536 RegisterHandlers(functions);
537 }
538
539 ~IApplicationDisplayService() {
540 for (const auto layer_id : stray_layer_ids) {
541 nvnflinger.DestroyLayer(layer_id);
542 }
543 }
544
545private:
546 enum class ConvertedScaleMode : u64 {
547 Freeze = 0,
548 ScaleToWindow = 1,
549 ScaleAndCrop = 2,
550 None = 3,
551 PreserveAspectRatio = 4,
552 };
553
554 enum class NintendoScaleMode : u32 {
555 None = 0,
556 Freeze = 1,
557 ScaleToWindow = 2,
558 ScaleAndCrop = 3,
559 PreserveAspectRatio = 4,
560 };
561
562 void GetRelayService(HLERequestContext& ctx) {
563 LOG_WARNING(Service_VI, "(STUBBED) called");
564
565 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
566 rb.Push(ResultSuccess);
567 rb.PushIpcInterface<IHOSBinderDriver>(system, hos_binder_driver_server);
568 }
569
570 void GetSystemDisplayService(HLERequestContext& ctx) {
571 LOG_WARNING(Service_VI, "(STUBBED) called");
572
573 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
574 rb.Push(ResultSuccess);
575 rb.PushIpcInterface<ISystemDisplayService>(system, nvnflinger);
576 }
577
578 void GetManagerDisplayService(HLERequestContext& ctx) {
579 LOG_WARNING(Service_VI, "(STUBBED) called");
580
581 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
582 rb.Push(ResultSuccess);
583 rb.PushIpcInterface<IManagerDisplayService>(system, nvnflinger);
584 }
585
586 void GetIndirectDisplayTransactionService(HLERequestContext& ctx) {
587 LOG_WARNING(Service_VI, "(STUBBED) called");
588
589 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
590 rb.Push(ResultSuccess);
591 rb.PushIpcInterface<IHOSBinderDriver>(system, hos_binder_driver_server);
592 }
593
594 void OpenDisplay(HLERequestContext& ctx) {
595 LOG_WARNING(Service_VI, "(STUBBED) called");
596
597 IPC::RequestParser rp{ctx};
598 const auto name_buf = rp.PopRaw<std::array<char, 0x40>>();
599
600 OpenDisplayImpl(ctx, std::string_view{name_buf.data(), name_buf.size()});
601 }
602
603 void OpenDefaultDisplay(HLERequestContext& ctx) {
604 LOG_DEBUG(Service_VI, "called");
605
606 OpenDisplayImpl(ctx, "Default");
607 }
608
609 void OpenDisplayImpl(HLERequestContext& ctx, std::string_view name) {
610 const auto trim_pos = name.find('\0');
611
612 if (trim_pos != std::string_view::npos) {
613 name.remove_suffix(name.size() - trim_pos);
614 }
615
616 ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet");
617
618 const auto display_id = nvnflinger.OpenDisplay(name);
619 if (!display_id) {
620 LOG_ERROR(Service_VI, "Display not found! display_name={}", name);
621 IPC::ResponseBuilder rb{ctx, 2};
622 rb.Push(ResultNotFound);
623 return;
624 }
625
626 IPC::ResponseBuilder rb{ctx, 4};
627 rb.Push(ResultSuccess);
628 rb.Push<u64>(*display_id);
629 }
630
631 void CloseDisplay(HLERequestContext& ctx) {
632 IPC::RequestParser rp{ctx};
633 const u64 display_id = rp.Pop<u64>();
634
635 const Result rc = nvnflinger.CloseDisplay(display_id) ? ResultSuccess : ResultUnknown;
636
637 IPC::ResponseBuilder rb{ctx, 2};
638 rb.Push(rc);
639 }
640
641 // This literally does nothing internally in the actual service itself,
642 // and just returns a successful result code regardless of the input.
643 void SetDisplayEnabled(HLERequestContext& ctx) {
644 LOG_DEBUG(Service_VI, "called.");
645
646 IPC::ResponseBuilder rb{ctx, 2};
647 rb.Push(ResultSuccess);
648 }
649
650 void GetDisplayResolution(HLERequestContext& ctx) {
651 IPC::RequestParser rp{ctx};
652 const u64 display_id = rp.Pop<u64>();
653
654 LOG_DEBUG(Service_VI, "called. display_id=0x{:016X}", display_id);
655
656 IPC::ResponseBuilder rb{ctx, 6};
657 rb.Push(ResultSuccess);
658
659 // This only returns the fixed values of 1280x720 and makes no distinguishing
660 // between docked and undocked dimensions. We take the liberty of applying
661 // the resolution scaling factor here.
662 rb.Push(static_cast<u64>(DisplayResolution::UndockedWidth));
663 rb.Push(static_cast<u64>(DisplayResolution::UndockedHeight));
664 }
665
666 void SetLayerScalingMode(HLERequestContext& ctx) {
667 IPC::RequestParser rp{ctx};
668 const auto scaling_mode = rp.PopEnum<NintendoScaleMode>();
669 const u64 unknown = rp.Pop<u64>();
670
671 LOG_DEBUG(Service_VI, "called. scaling_mode=0x{:08X}, unknown=0x{:016X}", scaling_mode,
672 unknown);
673
674 IPC::ResponseBuilder rb{ctx, 2};
675
676 if (scaling_mode > NintendoScaleMode::PreserveAspectRatio) {
677 LOG_ERROR(Service_VI, "Invalid scaling mode provided.");
678 rb.Push(ResultOperationFailed);
679 return;
680 }
681
682 if (scaling_mode != NintendoScaleMode::ScaleToWindow &&
683 scaling_mode != NintendoScaleMode::PreserveAspectRatio) {
684 LOG_ERROR(Service_VI, "Unsupported scaling mode supplied.");
685 rb.Push(ResultNotSupported);
686 return;
687 }
688
689 rb.Push(ResultSuccess);
690 }
691
692 void ListDisplays(HLERequestContext& ctx) {
693 LOG_WARNING(Service_VI, "(STUBBED) called");
694
695 const DisplayInfo display_info;
696 ctx.WriteBuffer(&display_info, sizeof(DisplayInfo));
697 IPC::ResponseBuilder rb{ctx, 4};
698 rb.Push(ResultSuccess);
699 rb.Push<u64>(1);
700 }
701
702 void OpenLayer(HLERequestContext& ctx) {
703 IPC::RequestParser rp{ctx};
704 const auto name_buf = rp.PopRaw<std::array<u8, 0x40>>();
705 const std::string display_name(Common::StringFromBuffer(name_buf));
706
707 const u64 layer_id = rp.Pop<u64>();
708 const u64 aruid = rp.Pop<u64>();
709
710 LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}, aruid=0x{:016X}", layer_id, aruid);
711
712 const auto display_id = nvnflinger.OpenDisplay(display_name);
713 if (!display_id) {
714 LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id);
715 IPC::ResponseBuilder rb{ctx, 2};
716 rb.Push(ResultNotFound);
717 return;
718 }
719
720 const auto buffer_queue_id = nvnflinger.FindBufferQueueId(*display_id, layer_id);
721 if (!buffer_queue_id) {
722 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id);
723 IPC::ResponseBuilder rb{ctx, 2};
724 rb.Push(ResultNotFound);
725 return;
726 }
727
728 if (!nvnflinger.OpenLayer(layer_id)) {
729 LOG_WARNING(Service_VI, "Tried to open layer which was already open");
730 IPC::ResponseBuilder rb{ctx, 2};
731 rb.Push(ResultOperationFailed);
732 return;
733 }
734
735 android::OutputParcel parcel;
736 parcel.WriteInterface(NativeWindow{*buffer_queue_id});
737
738 const auto buffer_size = ctx.WriteBuffer(parcel.Serialize());
739
740 IPC::ResponseBuilder rb{ctx, 4};
741 rb.Push(ResultSuccess);
742 rb.Push<u64>(buffer_size);
743 }
744
745 void CloseLayer(HLERequestContext& ctx) {
746 IPC::RequestParser rp{ctx};
747 const auto layer_id{rp.Pop<u64>()};
748
749 LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}", layer_id);
750
751 if (!nvnflinger.CloseLayer(layer_id)) {
752 LOG_WARNING(Service_VI, "Tried to close layer which was not open");
753 IPC::ResponseBuilder rb{ctx, 2};
754 rb.Push(ResultOperationFailed);
755 return;
756 }
757
758 IPC::ResponseBuilder rb{ctx, 2};
759 rb.Push(ResultSuccess);
760 }
761
762 void CreateStrayLayer(HLERequestContext& ctx) {
763 IPC::RequestParser rp{ctx};
764 const u32 flags = rp.Pop<u32>();
765 rp.Pop<u32>(); // padding
766 const u64 display_id = rp.Pop<u64>();
767
768 LOG_DEBUG(Service_VI, "called. flags=0x{:08X}, display_id=0x{:016X}", flags, display_id);
769
770 // TODO(Subv): What's the difference between a Stray and a Managed layer?
771
772 const auto layer_id = nvnflinger.CreateLayer(display_id);
773 if (!layer_id) {
774 LOG_ERROR(Service_VI, "Layer not found! display_id={}", display_id);
775 IPC::ResponseBuilder rb{ctx, 2};
776 rb.Push(ResultNotFound);
777 return;
778 }
779
780 stray_layer_ids.push_back(*layer_id);
781 const auto buffer_queue_id = nvnflinger.FindBufferQueueId(display_id, *layer_id);
782 if (!buffer_queue_id) {
783 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id);
784 IPC::ResponseBuilder rb{ctx, 2};
785 rb.Push(ResultNotFound);
786 return;
787 }
788
789 android::OutputParcel parcel;
790 parcel.WriteInterface(NativeWindow{*buffer_queue_id});
791
792 const auto buffer_size = ctx.WriteBuffer(parcel.Serialize());
793
794 IPC::ResponseBuilder rb{ctx, 6};
795 rb.Push(ResultSuccess);
796 rb.Push(*layer_id);
797 rb.Push<u64>(buffer_size);
798 }
799
800 void DestroyStrayLayer(HLERequestContext& ctx) {
801 IPC::RequestParser rp{ctx};
802 const u64 layer_id = rp.Pop<u64>();
803
804 LOG_WARNING(Service_VI, "(STUBBED) called. layer_id=0x{:016X}", layer_id);
805 nvnflinger.DestroyLayer(layer_id);
806
807 IPC::ResponseBuilder rb{ctx, 2};
808 rb.Push(ResultSuccess);
809 }
810
811 void GetDisplayVsyncEvent(HLERequestContext& ctx) {
812 IPC::RequestParser rp{ctx};
813 const u64 display_id = rp.Pop<u64>();
814
815 LOG_DEBUG(Service_VI, "called. display_id={}", display_id);
816
817 Kernel::KReadableEvent* vsync_event{};
818 const auto result = nvnflinger.FindVsyncEvent(&vsync_event, display_id);
819 if (result != ResultSuccess) {
820 if (result == ResultNotFound) {
821 LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id);
822 }
823
824 IPC::ResponseBuilder rb{ctx, 2};
825 rb.Push(result);
826 return;
827 }
828 if (vsync_event_fetched) {
829 IPC::ResponseBuilder rb{ctx, 2};
830 rb.Push(VI::ResultPermissionDenied);
831 return;
832 }
833 vsync_event_fetched = true;
834
835 IPC::ResponseBuilder rb{ctx, 2, 1};
836 rb.Push(ResultSuccess);
837 rb.PushCopyObjects(vsync_event);
838 }
839
840 void ConvertScalingMode(HLERequestContext& ctx) {
841 IPC::RequestParser rp{ctx};
842 const auto mode = rp.PopEnum<NintendoScaleMode>();
843 LOG_DEBUG(Service_VI, "called mode={}", mode);
844
845 ConvertedScaleMode converted_mode{};
846 const auto result = ConvertScalingModeImpl(&converted_mode, mode);
847
848 if (result == ResultSuccess) {
849 IPC::ResponseBuilder rb{ctx, 4};
850 rb.Push(ResultSuccess);
851 rb.PushEnum(converted_mode);
852 } else {
853 IPC::ResponseBuilder rb{ctx, 2};
854 rb.Push(result);
855 }
856 }
857
858 void GetIndirectLayerImageMap(HLERequestContext& ctx) {
859 IPC::RequestParser rp{ctx};
860 const auto width = rp.Pop<s64>();
861 const auto height = rp.Pop<s64>();
862 const auto indirect_layer_consumer_handle = rp.Pop<u64>();
863 const auto applet_resource_user_id = rp.Pop<u64>();
864
865 LOG_WARNING(Service_VI,
866 "(STUBBED) called, width={}, height={}, indirect_layer_consumer_handle={}, "
867 "applet_resource_user_id={}",
868 width, height, indirect_layer_consumer_handle, applet_resource_user_id);
869
870 std::vector<u8> out_buffer(0x46);
871 ctx.WriteBuffer(out_buffer);
872
873 // TODO: Figure out what these are
874
875 constexpr s64 unknown_result_1 = 0;
876 constexpr s64 unknown_result_2 = 0;
877
878 IPC::ResponseBuilder rb{ctx, 6};
879 rb.Push(unknown_result_1);
880 rb.Push(unknown_result_2);
881 rb.Push(ResultSuccess);
882 }
883
884 void GetIndirectLayerImageRequiredMemoryInfo(HLERequestContext& ctx) {
885 IPC::RequestParser rp{ctx};
886 const auto width = rp.Pop<u64>();
887 const auto height = rp.Pop<u64>();
888 LOG_DEBUG(Service_VI, "called width={}, height={}", width, height);
889
890 constexpr u64 base_size = 0x20000;
891 constexpr u64 alignment = 0x1000;
892 const auto texture_size = width * height * 4;
893 const auto out_size = (texture_size + base_size - 1) / base_size * base_size;
894
895 IPC::ResponseBuilder rb{ctx, 6};
896 rb.Push(ResultSuccess);
897 rb.Push(out_size);
898 rb.Push(alignment);
899 }
900
901 static Result ConvertScalingModeImpl(ConvertedScaleMode* out_scaling_mode,
902 NintendoScaleMode mode) {
903 switch (mode) {
904 case NintendoScaleMode::None:
905 *out_scaling_mode = ConvertedScaleMode::None;
906 return ResultSuccess;
907 case NintendoScaleMode::Freeze:
908 *out_scaling_mode = ConvertedScaleMode::Freeze;
909 return ResultSuccess;
910 case NintendoScaleMode::ScaleToWindow:
911 *out_scaling_mode = ConvertedScaleMode::ScaleToWindow;
912 return ResultSuccess;
913 case NintendoScaleMode::ScaleAndCrop:
914 *out_scaling_mode = ConvertedScaleMode::ScaleAndCrop;
915 return ResultSuccess;
916 case NintendoScaleMode::PreserveAspectRatio:
917 *out_scaling_mode = ConvertedScaleMode::PreserveAspectRatio;
918 return ResultSuccess;
919 default:
920 LOG_ERROR(Service_VI, "Invalid scaling mode specified, mode={}", mode);
921 return ResultOperationFailed;
922 }
923 }
924
925 Nvnflinger::Nvnflinger& nvnflinger;
926 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server;
927 std::vector<u64> stray_layer_ids;
928 bool vsync_event_fetched{false};
929};
930
931static bool IsValidServiceAccess(Permission permission, Policy policy) {
932 if (permission == Permission::User) {
933 return policy == Policy::User;
934 }
935
936 if (permission == Permission::System || permission == Permission::Manager) {
937 return policy == Policy::User || policy == Policy::Compositor;
938 }
939
940 return false;
941}
942
943void detail::GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system,
944 Nvnflinger::Nvnflinger& nvnflinger,
945 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server,
946 Permission permission) {
947 IPC::RequestParser rp{ctx};
948 const auto policy = rp.PopEnum<Policy>();
949
950 if (!IsValidServiceAccess(permission, policy)) {
951 LOG_ERROR(Service_VI, "Permission denied for policy {}", policy);
952 IPC::ResponseBuilder rb{ctx, 2};
953 rb.Push(ResultPermissionDenied);
954 return;
955 }
956
957 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
958 rb.Push(ResultSuccess);
959 rb.PushIpcInterface<IApplicationDisplayService>(system, nvnflinger, hos_binder_driver_server);
960}
961
962void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger, 13void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
963 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) { 14 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) {
964 auto server_manager = std::make_unique<ServerManager>(system); 15 auto server_manager = std::make_unique<ServerManager>(system);
965 16
17 server_manager->RegisterNamedService("vi:m", std::make_shared<IManagerRootService>(
18 system, nvnflinger, hos_binder_driver_server));
966 server_manager->RegisterNamedService( 19 server_manager->RegisterNamedService(
967 "vi:m", std::make_shared<VI_M>(system, nvnflinger, hos_binder_driver_server)); 20 "vi:s", std::make_shared<ISystemRootService>(system, nvnflinger, hos_binder_driver_server));
968 server_manager->RegisterNamedService( 21 server_manager->RegisterNamedService("vi:u", std::make_shared<IApplicationRootService>(
969 "vi:s", std::make_shared<VI_S>(system, nvnflinger, hos_binder_driver_server)); 22 system, nvnflinger, hos_binder_driver_server));
970 server_manager->RegisterNamedService(
971 "vi:u", std::make_shared<VI_U>(system, nvnflinger, hos_binder_driver_server));
972 ServerManager::RunServer(std::move(server_manager)); 23 ServerManager::RunServer(std::move(server_manager));
973} 24}
974 25
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h
index ee4bcbcfa..8e681370d 100644
--- a/src/core/hle/service/vi/vi.h
+++ b/src/core/hle/service/vi/vi.h
@@ -3,16 +3,10 @@
3 3
4#pragma once 4#pragma once
5 5
6#include "common/common_types.h"
7
8namespace Core { 6namespace Core {
9class System; 7class System;
10} 8}
11 9
12namespace Service {
13class HLERequestContext;
14}
15
16namespace Service::Nvnflinger { 10namespace Service::Nvnflinger {
17class HosBinderDriverServer; 11class HosBinderDriverServer;
18class Nvnflinger; 12class Nvnflinger;
@@ -20,34 +14,6 @@ class Nvnflinger;
20 14
21namespace Service::VI { 15namespace Service::VI {
22 16
23enum class DisplayResolution : u32 {
24 DockedWidth = 1920,
25 DockedHeight = 1080,
26 UndockedWidth = 1280,
27 UndockedHeight = 720,
28};
29
30/// Permission level for a particular VI service instance
31enum class Permission {
32 User,
33 System,
34 Manager,
35};
36
37/// A policy type that may be requested via GetDisplayService and
38/// GetDisplayServiceWithProxyNameExchange
39enum class Policy {
40 User,
41 Compositor,
42};
43
44namespace detail {
45void GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system,
46 Nvnflinger::Nvnflinger& nv_flinger,
47 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server,
48 Permission permission);
49} // namespace detail
50
51void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger, 17void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
52 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server); 18 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
53 19
diff --git a/src/core/hle/service/vi/vi_m.cpp b/src/core/hle/service/vi/vi_m.cpp
deleted file mode 100644
index 0f06dc2f3..000000000
--- a/src/core/hle/service/vi/vi_m.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/logging/log.h"
5#include "core/hle/service/vi/vi.h"
6#include "core/hle/service/vi/vi_m.h"
7
8namespace Service::VI {
9
10VI_M::VI_M(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
11 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)
12 : ServiceFramework{system_, "vi:m"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{
13 hos_binder_driver_server_} {
14 static const FunctionInfo functions[] = {
15 {2, &VI_M::GetDisplayService, "GetDisplayService"},
16 {3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
17 {100, nullptr, "PrepareFatal"},
18 {101, nullptr, "ShowFatal"},
19 {102, nullptr, "DrawFatalRectangle"},
20 {103, nullptr, "DrawFatalText32"},
21 };
22 RegisterHandlers(functions);
23}
24
25VI_M::~VI_M() = default;
26
27void VI_M::GetDisplayService(HLERequestContext& ctx) {
28 LOG_DEBUG(Service_VI, "called");
29
30 detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server,
31 Permission::Manager);
32}
33
34} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi_m.h b/src/core/hle/service/vi/vi_m.h
deleted file mode 100644
index 9ca6f3905..000000000
--- a/src/core/hle/service/vi/vi_m.h
+++ /dev/null
@@ -1,32 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/service.h"
7
8namespace Core {
9class System;
10}
11
12namespace Service::Nvnflinger {
13class HosBinderDriverServer;
14class Nvnflinger;
15} // namespace Service::Nvnflinger
16
17namespace Service::VI {
18
19class VI_M final : public ServiceFramework<VI_M> {
20public:
21 explicit VI_M(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
22 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_);
23 ~VI_M() override;
24
25private:
26 void GetDisplayService(HLERequestContext& ctx);
27
28 Nvnflinger::Nvnflinger& nv_flinger;
29 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server;
30};
31
32} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi_s.cpp b/src/core/hle/service/vi/vi_s.cpp
deleted file mode 100644
index 77f7a88ff..000000000
--- a/src/core/hle/service/vi/vi_s.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/logging/log.h"
5#include "core/hle/service/vi/vi.h"
6#include "core/hle/service/vi/vi_s.h"
7
8namespace Service::VI {
9
10VI_S::VI_S(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
11 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)
12 : ServiceFramework{system_, "vi:s"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{
13 hos_binder_driver_server_} {
14 static const FunctionInfo functions[] = {
15 {1, &VI_S::GetDisplayService, "GetDisplayService"},
16 {3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
17 };
18 RegisterHandlers(functions);
19}
20
21VI_S::~VI_S() = default;
22
23void VI_S::GetDisplayService(HLERequestContext& ctx) {
24 LOG_DEBUG(Service_VI, "called");
25
26 detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server,
27 Permission::System);
28}
29
30} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi_s.h b/src/core/hle/service/vi/vi_s.h
deleted file mode 100644
index 157839c91..000000000
--- a/src/core/hle/service/vi/vi_s.h
+++ /dev/null
@@ -1,32 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/service.h"
7
8namespace Core {
9class System;
10}
11
12namespace Service::Nvnflinger {
13class HosBinderDriverServer;
14class Nvnflinger;
15} // namespace Service::Nvnflinger
16
17namespace Service::VI {
18
19class VI_S final : public ServiceFramework<VI_S> {
20public:
21 explicit VI_S(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
22 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_);
23 ~VI_S() override;
24
25private:
26 void GetDisplayService(HLERequestContext& ctx);
27
28 Nvnflinger::Nvnflinger& nv_flinger;
29 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server;
30};
31
32} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi_types.h b/src/core/hle/service/vi/vi_types.h
new file mode 100644
index 000000000..91e4b380c
--- /dev/null
+++ b/src/core/hle/service/vi/vi_types.h
@@ -0,0 +1,84 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "common/common_funcs.h"
7
8namespace Service::VI {
9
10enum class DisplayResolution : u32 {
11 DockedWidth = 1920,
12 DockedHeight = 1080,
13 UndockedWidth = 1280,
14 UndockedHeight = 720,
15};
16
17/// Permission level for a particular VI service instance
18enum class Permission {
19 User,
20 System,
21 Manager,
22};
23
24/// A policy type that may be requested via GetDisplayService and
25/// GetDisplayServiceWithProxyNameExchange
26enum class Policy : u32 {
27 User,
28 Compositor,
29};
30
31enum class ConvertedScaleMode : u64 {
32 Freeze = 0,
33 ScaleToWindow = 1,
34 ScaleAndCrop = 2,
35 None = 3,
36 PreserveAspectRatio = 4,
37};
38
39enum class NintendoScaleMode : u32 {
40 None = 0,
41 Freeze = 1,
42 ScaleToWindow = 2,
43 ScaleAndCrop = 3,
44 PreserveAspectRatio = 4,
45};
46
47using DisplayName = std::array<char, 0x40>;
48
49struct DisplayInfo {
50 /// The name of this particular display.
51 DisplayName display_name{"Default"};
52
53 /// Whether or not the display has a limited number of layers.
54 u8 has_limited_layers{1};
55 INSERT_PADDING_BYTES(7);
56
57 /// Indicates the total amount of layers supported by the display.
58 /// @note This is only valid if has_limited_layers is set.
59 u64 max_layers{1};
60
61 /// Maximum width in pixels.
62 u64 width{1920};
63
64 /// Maximum height in pixels.
65 u64 height{1080};
66};
67static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size");
68
69class NativeWindow final {
70public:
71 constexpr explicit NativeWindow(u32 id_) : id{id_} {}
72 constexpr explicit NativeWindow(const NativeWindow& other) = default;
73
74private:
75 const u32 magic = 2;
76 const u32 process_id = 1;
77 const u64 id;
78 INSERT_PADDING_WORDS(2);
79 std::array<u8, 8> dispdrv = {'d', 'i', 's', 'p', 'd', 'r', 'v', '\0'};
80 INSERT_PADDING_WORDS(2);
81};
82static_assert(sizeof(NativeWindow) == 0x28, "NativeWindow has wrong size");
83
84} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi_u.cpp b/src/core/hle/service/vi/vi_u.cpp
deleted file mode 100644
index 59e13c86b..000000000
--- a/src/core/hle/service/vi/vi_u.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/logging/log.h"
5#include "core/hle/service/vi/vi.h"
6#include "core/hle/service/vi/vi_u.h"
7
8namespace Service::VI {
9
10VI_U::VI_U(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
11 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)
12 : ServiceFramework{system_, "vi:u"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{
13 hos_binder_driver_server_} {
14 static const FunctionInfo functions[] = {
15 {0, &VI_U::GetDisplayService, "GetDisplayService"},
16 {1, nullptr, "GetDisplayServiceWithProxyNameExchange"},
17 };
18 RegisterHandlers(functions);
19}
20
21VI_U::~VI_U() = default;
22
23void VI_U::GetDisplayService(HLERequestContext& ctx) {
24 LOG_DEBUG(Service_VI, "called");
25
26 detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server,
27 Permission::User);
28}
29
30} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi_u.h b/src/core/hle/service/vi/vi_u.h
deleted file mode 100644
index 5d9ca54c6..000000000
--- a/src/core/hle/service/vi/vi_u.h
+++ /dev/null
@@ -1,32 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/service.h"
7
8namespace Core {
9class System;
10}
11
12namespace Service::Nvnflinger {
13class HosBinderDriverServer;
14class Nvnflinger;
15} // namespace Service::Nvnflinger
16
17namespace Service::VI {
18
19class VI_U final : public ServiceFramework<VI_U> {
20public:
21 explicit VI_U(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,
22 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_);
23 ~VI_U() override;
24
25private:
26 void GetDisplayService(HLERequestContext& ctx);
27
28 Nvnflinger::Nvnflinger& nv_flinger;
29 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server;
30};
31
32} // namespace Service::VI
diff --git a/src/hid_core/resources/hid_firmware_settings.cpp b/src/hid_core/resources/hid_firmware_settings.cpp
index b32c0660a..c0a76d0eb 100644
--- a/src/hid_core/resources/hid_firmware_settings.cpp
+++ b/src/hid_core/resources/hid_firmware_settings.cpp
@@ -22,29 +22,30 @@ void HidFirmwareSettings::LoadSettings(bool reload_config) {
22 return; 22 return;
23 } 23 }
24 24
25 m_set_sys->GetSettingsItemValue<bool>(is_debug_pad_enabled, "hid_debug", "enables_debugpad"); 25 m_set_sys->GetSettingsItemValueImpl<bool>(is_debug_pad_enabled, "hid_debug",
26 m_set_sys->GetSettingsItemValue<bool>(is_device_managed, "hid_debug", "manages_devices"); 26 "enables_debugpad");
27 m_set_sys->GetSettingsItemValue<bool>(is_touch_i2c_managed, "hid_debug", 27 m_set_sys->GetSettingsItemValueImpl<bool>(is_device_managed, "hid_debug", "manages_devices");
28 "manages_touch_ic_i2c"); 28 m_set_sys->GetSettingsItemValueImpl<bool>(is_touch_i2c_managed, "hid_debug",
29 m_set_sys->GetSettingsItemValue<bool>(is_future_devices_emulated, "hid_debug", 29 "manages_touch_ic_i2c");
30 "emulate_future_device"); 30 m_set_sys->GetSettingsItemValueImpl<bool>(is_future_devices_emulated, "hid_debug",
31 m_set_sys->GetSettingsItemValue<bool>(is_mcu_hardware_error_emulated, "hid_debug", 31 "emulate_future_device");
32 "emulate_mcu_hardware_error"); 32 m_set_sys->GetSettingsItemValueImpl<bool>(is_mcu_hardware_error_emulated, "hid_debug",
33 m_set_sys->GetSettingsItemValue<bool>(is_rail_enabled, "hid_debug", "enables_rail"); 33 "emulate_mcu_hardware_error");
34 m_set_sys->GetSettingsItemValue<bool>(is_firmware_update_failure_emulated, "hid_debug", 34 m_set_sys->GetSettingsItemValueImpl<bool>(is_rail_enabled, "hid_debug", "enables_rail");
35 "emulate_firmware_update_failure"); 35 m_set_sys->GetSettingsItemValueImpl<bool>(is_firmware_update_failure_emulated, "hid_debug",
36 "emulate_firmware_update_failure");
36 is_firmware_update_failure = {}; 37 is_firmware_update_failure = {};
37 m_set_sys->GetSettingsItemValue<bool>(is_ble_disabled, "hid_debug", "ble_disabled"); 38 m_set_sys->GetSettingsItemValueImpl<bool>(is_ble_disabled, "hid_debug", "ble_disabled");
38 m_set_sys->GetSettingsItemValue<bool>(is_dscale_disabled, "hid_debug", "dscale_disabled"); 39 m_set_sys->GetSettingsItemValueImpl<bool>(is_dscale_disabled, "hid_debug", "dscale_disabled");
39 m_set_sys->GetSettingsItemValue<bool>(is_handheld_forced, "hid_debug", "force_handheld"); 40 m_set_sys->GetSettingsItemValueImpl<bool>(is_handheld_forced, "hid_debug", "force_handheld");
40 features_per_id_disabled = {}; 41 features_per_id_disabled = {};
41 m_set_sys->GetSettingsItemValue<bool>(is_touch_firmware_auto_update_disabled, "hid_debug", 42 m_set_sys->GetSettingsItemValueImpl<bool>(is_touch_firmware_auto_update_disabled, "hid_debug",
42 "touch_firmware_auto_update_disabled"); 43 "touch_firmware_auto_update_disabled");
43 44
44 bool has_rail_interface{}; 45 bool has_rail_interface{};
45 bool has_sio_mcu{}; 46 bool has_sio_mcu{};
46 m_set_sys->GetSettingsItemValue<bool>(has_rail_interface, "hid", "has_rail_interface"); 47 m_set_sys->GetSettingsItemValueImpl<bool>(has_rail_interface, "hid", "has_rail_interface");
47 m_set_sys->GetSettingsItemValue<bool>(has_sio_mcu, "hid", "has_sio_mcu"); 48 m_set_sys->GetSettingsItemValueImpl<bool>(has_sio_mcu, "hid", "has_sio_mcu");
48 platform_config.has_rail_interface.Assign(has_rail_interface); 49 platform_config.has_rail_interface.Assign(has_rail_interface);
49 platform_config.has_sio_mcu.Assign(has_sio_mcu); 50 platform_config.has_sio_mcu.Assign(has_sio_mcu);
50 51
diff --git a/src/hid_core/resources/npad/npad_vibration.cpp b/src/hid_core/resources/npad/npad_vibration.cpp
index 02b1f0290..4c103889a 100644
--- a/src/hid_core/resources/npad/npad_vibration.cpp
+++ b/src/hid_core/resources/npad/npad_vibration.cpp
@@ -15,7 +15,7 @@ Result NpadVibration::Activate() {
15 std::scoped_lock lock{mutex}; 15 std::scoped_lock lock{mutex};
16 16
17 f32 master_volume = 1.0f; 17 f32 master_volume = 1.0f;
18 m_set_sys->GetVibrationMasterVolume(master_volume); 18 m_set_sys->GetVibrationMasterVolume(&master_volume);
19 if (master_volume < 0.0f || master_volume > 1.0f) { 19 if (master_volume < 0.0f || master_volume > 1.0f) {
20 return ResultVibrationStrengthOutOfRange; 20 return ResultVibrationStrengthOutOfRange;
21 } 21 }
@@ -57,7 +57,7 @@ Result NpadVibration::GetVibrationMasterVolume(f32& out_volume) const {
57 std::scoped_lock lock{mutex}; 57 std::scoped_lock lock{mutex};
58 58
59 f32 master_volume = 1.0f; 59 f32 master_volume = 1.0f;
60 m_set_sys->GetVibrationMasterVolume(master_volume); 60 m_set_sys->GetVibrationMasterVolume(&master_volume);
61 if (master_volume < 0.0f || master_volume > 1.0f) { 61 if (master_volume < 0.0f || master_volume > 1.0f) {
62 return ResultVibrationStrengthOutOfRange; 62 return ResultVibrationStrengthOutOfRange;
63 } 63 }
@@ -77,7 +77,7 @@ Result NpadVibration::EndPermitVibrationSession() {
77 std::scoped_lock lock{mutex}; 77 std::scoped_lock lock{mutex};
78 78
79 f32 master_volume = 1.0f; 79 f32 master_volume = 1.0f;
80 m_set_sys->GetVibrationMasterVolume(master_volume); 80 m_set_sys->GetVibrationMasterVolume(&master_volume);
81 if (master_volume < 0.0f || master_volume > 1.0f) { 81 if (master_volume < 0.0f || master_volume > 1.0f) {
82 return ResultVibrationStrengthOutOfRange; 82 return ResultVibrationStrengthOutOfRange;
83 } 83 }
diff --git a/src/hid_core/resources/touch_screen/touch_screen_resource.cpp b/src/hid_core/resources/touch_screen/touch_screen_resource.cpp
index c39321915..79ddaa4df 100644
--- a/src/hid_core/resources/touch_screen/touch_screen_resource.cpp
+++ b/src/hid_core/resources/touch_screen/touch_screen_resource.cpp
@@ -48,7 +48,7 @@ Result TouchResource::ActivateTouch() {
48 } 48 }
49 49
50 Set::TouchScreenMode touch_mode{Set::TouchScreenMode::Standard}; 50 Set::TouchScreenMode touch_mode{Set::TouchScreenMode::Standard};
51 m_set_sys->GetTouchScreenMode(touch_mode); 51 m_set_sys->GetTouchScreenMode(&touch_mode);
52 default_touch_screen_mode = static_cast<Core::HID::TouchScreenModeForNx>(touch_mode); 52 default_touch_screen_mode = static_cast<Core::HID::TouchScreenModeForNx>(touch_mode);
53 53
54 global_ref_counter++; 54 global_ref_counter++;