From 188979b3e2ecdbfca9335f8e065714b9994d9fbe Mon Sep 17 00:00:00 2001 From: NarcolepticK Date: Wed, 27 Jun 2018 10:40:37 -0400 Subject: [PATCH 1/2] service/gsp: Migrate gsp_lcd to ServiceFramework --- src/core/hle/service/gsp/gsp.cpp | 6 +++++- src/core/hle/service/gsp/gsp.h | 1 + src/core/hle/service/gsp/gsp_lcd.cpp | 30 +++++++++++++--------------- src/core/hle/service/gsp/gsp_lcd.h | 7 ++----- src/core/hle/service/service.cpp | 1 - 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/core/hle/service/gsp/gsp.cpp b/src/core/hle/service/gsp/gsp.cpp index 65f9ec00e4..beae1c2d45 100644 --- a/src/core/hle/service/gsp/gsp.cpp +++ b/src/core/hle/service/gsp/gsp.cpp @@ -11,6 +11,7 @@ namespace Service { namespace GSP { static std::weak_ptr gsp_gpu; +static std::weak_ptr gsp_lcd; FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { auto gpu = gsp_gpu.lock(); @@ -27,8 +28,11 @@ void SignalInterrupt(InterruptId interrupt_id) { void InstallInterfaces(SM::ServiceManager& service_manager) { auto gpu = std::make_shared(); gpu->InstallAsService(service_manager); - gsp_gpu = gpu; + + auto lcd = std::make_shared(); + lcd->InstallAsService(service_manager); + gsp_lcd = lcd; } } // namespace GSP diff --git a/src/core/hle/service/gsp/gsp.h b/src/core/hle/service/gsp/gsp.h index f743090b31..c3e6cd0309 100644 --- a/src/core/hle/service/gsp/gsp.h +++ b/src/core/hle/service/gsp/gsp.h @@ -9,6 +9,7 @@ #include "common/common_types.h" #include "core/hle/result.h" #include "core/hle/service/gsp/gsp_gpu.h" +#include "core/hle/service/gsp/gsp_lcd.h" namespace Service { namespace GSP { diff --git a/src/core/hle/service/gsp/gsp_lcd.cpp b/src/core/hle/service/gsp/gsp_lcd.cpp index cd0de16378..f7188c01ba 100644 --- a/src/core/hle/service/gsp/gsp_lcd.cpp +++ b/src/core/hle/service/gsp/gsp_lcd.cpp @@ -2,28 +2,26 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/hle/ipc_helpers.h" #include "core/hle/service/gsp/gsp_lcd.h" namespace Service { namespace GSP { -const Interface::FunctionInfo FunctionTable[] = { - // clang-format off - {0x000A0080, nullptr, "SetBrightnessRaw"}, - {0x000B0080, nullptr, "SetBrightness"}, - {0x000F0000, nullptr, "PowerOnAllBacklights"}, - {0x00100000, nullptr, "PowerOffAllBacklights"}, - {0x00110040, nullptr, "PowerOnBacklight"}, - {0x00120040, nullptr, "PowerOffBacklight"}, - {0x00130040, nullptr, "SetLedForceOff"}, - {0x00140000, nullptr, "GetVendor"}, - {0x00150040, nullptr, "GetBrightness"}, - // clang-format on +GSP_LCD::GSP_LCD() : ServiceFramework("gsp::Lcd") { + static const FunctionInfo functions[] = { + {0x000A0080, nullptr, "SetBrightnessRaw"}, + {0x000B0080, nullptr, "SetBrightness"}, + {0x000F0000, nullptr, "PowerOnAllBacklights"}, + {0x00100000, nullptr, "PowerOffAllBacklights"}, + {0x00110040, nullptr, "PowerOnBacklight"}, + {0x00120040, nullptr, "PowerOffBacklight"}, + {0x00130040, nullptr, "SetLedForceOff"}, + {0x00140000, nullptr, "GetVendor"}, + {0x00150040, nullptr, "GetBrightness"}, + }; + RegisterHandlers(functions); }; -GSP_LCD::GSP_LCD() { - Register(FunctionTable); -} - } // namespace GSP } // namespace Service diff --git a/src/core/hle/service/gsp/gsp_lcd.h b/src/core/hle/service/gsp/gsp_lcd.h index e9686a5e7c..90f7e5c8b0 100644 --- a/src/core/hle/service/gsp/gsp_lcd.h +++ b/src/core/hle/service/gsp/gsp_lcd.h @@ -9,13 +9,10 @@ namespace Service { namespace GSP { -class GSP_LCD final : public Interface { +class GSP_LCD final : public ServiceFramework { public: GSP_LCD(); - - std::string GetPortName() const override { - return "gsp::Lcd"; - } + ~GSP_LCD() = default; }; } // namespace GSP diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index d0f28127d1..477f7e8e40 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -258,7 +258,6 @@ void Init(std::shared_ptr& sm) { AddService(new CSND::CSND_SND); AddService(new DSP_DSP::Interface); - AddService(new GSP::GSP_LCD); AddService(new HTTP::HTTP_C); AddService(new PM::PM_APP); AddService(new SOC::SOC_U); From d25cfbc4cc4f198507af048780a0b2a823298e4e Mon Sep 17 00:00:00 2001 From: NarcolepticK Date: Wed, 27 Jun 2018 11:05:38 -0400 Subject: [PATCH 2/2] service/gsp: Addressed comment about global state --- src/core/hle/service/gsp/gsp.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/core/hle/service/gsp/gsp.cpp b/src/core/hle/service/gsp/gsp.cpp index beae1c2d45..660a68e556 100644 --- a/src/core/hle/service/gsp/gsp.cpp +++ b/src/core/hle/service/gsp/gsp.cpp @@ -11,7 +11,6 @@ namespace Service { namespace GSP { static std::weak_ptr gsp_gpu; -static std::weak_ptr gsp_lcd; FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { auto gpu = gsp_gpu.lock(); @@ -30,9 +29,7 @@ void InstallInterfaces(SM::ServiceManager& service_manager) { gpu->InstallAsService(service_manager); gsp_gpu = gpu; - auto lcd = std::make_shared(); - lcd->InstallAsService(service_manager); - gsp_lcd = lcd; + std::make_shared()->InstallAsService(service_manager); } } // namespace GSP