From b81f6f67f50f5fd5416ca5b54f1e32536c7ece7d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 11 Jul 2019 13:02:29 -0400 Subject: [PATCH 1/2] service/am: Implement SetAutoSleepDisabled Provides a basic implementation of SetAutoSleepDisabled. Until idle handling is implemented, this is about the best we can do. In the meantime, provide a rough documenting of specifics that occur when this function is called on actual hardware. --- src/core/hle/service/am/am.cpp | 22 +++++++++++++++++++++- src/core/hle/service/am/am.h | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 9fdcf2965f..3f2f5c7db3 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -266,7 +266,7 @@ ISelfController::ISelfController(std::shared_ptr nvflinger {65, nullptr, "ReportUserIsActive"}, {66, nullptr, "GetCurrentIlluminance"}, {67, nullptr, "IsIlluminanceAvailable"}, - {68, nullptr, "SetAutoSleepDisabled"}, + {68, &ISelfController::SetAutoSleepDisabled, "SetAutoSleepDisabled"}, {69, nullptr, "IsAutoSleepDisabled"}, {70, nullptr, "ReportMultimediaError"}, {71, nullptr, "GetCurrentIlluminanceEx"}, @@ -454,6 +454,26 @@ void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& c rb.Push(idle_time_detection_extension); } +void ISelfController::SetAutoSleepDisabled(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + is_auto_sleep_disabled = rp.Pop(); + + // On the system itself, if the previous state of is_auto_sleep_disabled + // differed from the current value passed in, it'd signify the internal + // window manager to update (and also increment some statistics like update counts) + // + // It'd also indicate this change to an idle handling context. + // + // However, given we're emulating this behavior, most of this can be ignored + // and it's sufficient to simply set the member variable for querying via + // IsAutoSleepDisabled(). + + LOG_DEBUG(Service_AM, "called. is_auto_sleep_disabled={}", is_auto_sleep_disabled); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); +} + void ISelfController::GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called."); diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 14b010164e..0788e2dc06 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -133,6 +133,7 @@ private: void SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx); void SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx); void GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx); + void SetAutoSleepDisabled(Kernel::HLERequestContext& ctx); void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx); void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx); @@ -142,6 +143,7 @@ private: u32 idle_time_detection_extension = 0; u64 num_fatal_sections_entered = 0; + bool is_auto_sleep_disabled = false; }; class ICommonStateGetter final : public ServiceFramework { From f4ae449f733a0939a39d9674ddc152647b924027 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 11 Jul 2019 13:32:20 -0400 Subject: [PATCH 2/2] service/am: Implement IsAutoSleepDisabled This simply queries whether or not auto-sleep facilities are disabled and has no special handling. It's a basic getter function. --- src/core/hle/service/am/am.cpp | 10 +++++++++- src/core/hle/service/am/am.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 3f2f5c7db3..a192a1f5fc 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -267,7 +267,7 @@ ISelfController::ISelfController(std::shared_ptr nvflinger {66, nullptr, "GetCurrentIlluminance"}, {67, nullptr, "IsIlluminanceAvailable"}, {68, &ISelfController::SetAutoSleepDisabled, "SetAutoSleepDisabled"}, - {69, nullptr, "IsAutoSleepDisabled"}, + {69, &ISelfController::IsAutoSleepDisabled, "IsAutoSleepDisabled"}, {70, nullptr, "ReportMultimediaError"}, {71, nullptr, "GetCurrentIlluminanceEx"}, {80, nullptr, "SetWirelessPriorityMode"}, @@ -474,6 +474,14 @@ void ISelfController::SetAutoSleepDisabled(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } +void ISelfController::IsAutoSleepDisabled(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_AM, "called."); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(RESULT_SUCCESS); + rb.Push(is_auto_sleep_disabled); +} + void ISelfController::GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called."); diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 0788e2dc06..6cb5824838 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -134,6 +134,7 @@ private: void SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx); void GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx); void SetAutoSleepDisabled(Kernel::HLERequestContext& ctx); + void IsAutoSleepDisabled(Kernel::HLERequestContext& ctx); void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx); void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx);