1
0
Fork 0
forked from suyu/suyu

Service/vi: convert services to module

This commit is contained in:
mailwl 2018-03-21 13:09:40 +03:00
parent 0b3ab30762
commit 6673ed1274
8 changed files with 158 additions and 210 deletions

View file

@ -4,10 +4,13 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <memory>
#include <boost/optional.hpp>
#include "common/alignment.h" #include "common/alignment.h"
#include "common/scope_exit.h" #include "common/scope_exit.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/event.h"
#include "core/hle/service/nvdrv/nvdrv.h" #include "core/hle/service/nvdrv/nvdrv.h"
#include "core/hle/service/nvflinger/buffer_queue.h" #include "core/hle/service/nvflinger/buffer_queue.h"
#include "core/hle/service/vi/vi.h" #include "core/hle/service/vi/vi.h"
@ -646,7 +649,13 @@ private:
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger; std::shared_ptr<NVFlinger::NVFlinger> nv_flinger;
}; };
void IApplicationDisplayService::GetRelayService(Kernel::HLERequestContext& ctx) { class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> {
public:
IApplicationDisplayService(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
~IApplicationDisplayService() = default;
private:
void GetRelayService(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called"); LOG_WARNING(Service_VI, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@ -654,7 +663,7 @@ void IApplicationDisplayService::GetRelayService(Kernel::HLERequestContext& ctx)
rb.PushIpcInterface<IHOSBinderDriver>(nv_flinger); rb.PushIpcInterface<IHOSBinderDriver>(nv_flinger);
} }
void IApplicationDisplayService::GetSystemDisplayService(Kernel::HLERequestContext& ctx) { void GetSystemDisplayService(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called"); LOG_WARNING(Service_VI, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@ -662,7 +671,7 @@ void IApplicationDisplayService::GetSystemDisplayService(Kernel::HLERequestConte
rb.PushIpcInterface<ISystemDisplayService>(); rb.PushIpcInterface<ISystemDisplayService>();
} }
void IApplicationDisplayService::GetManagerDisplayService(Kernel::HLERequestContext& ctx) { void GetManagerDisplayService(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called"); LOG_WARNING(Service_VI, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@ -670,8 +679,7 @@ void IApplicationDisplayService::GetManagerDisplayService(Kernel::HLERequestCont
rb.PushIpcInterface<IManagerDisplayService>(nv_flinger); rb.PushIpcInterface<IManagerDisplayService>(nv_flinger);
} }
void IApplicationDisplayService::GetIndirectDisplayTransactionService( void GetIndirectDisplayTransactionService(Kernel::HLERequestContext& ctx) {
Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called"); LOG_WARNING(Service_VI, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
@ -679,7 +687,7 @@ void IApplicationDisplayService::GetIndirectDisplayTransactionService(
rb.PushIpcInterface<IHOSBinderDriver>(nv_flinger); rb.PushIpcInterface<IHOSBinderDriver>(nv_flinger);
} }
void IApplicationDisplayService::OpenDisplay(Kernel::HLERequestContext& ctx) { void OpenDisplay(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called"); LOG_WARNING(Service_VI, "(STUBBED) called");
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
auto name_buf = rp.PopRaw<std::array<u8, 0x40>>(); auto name_buf = rp.PopRaw<std::array<u8, 0x40>>();
@ -694,7 +702,7 @@ void IApplicationDisplayService::OpenDisplay(Kernel::HLERequestContext& ctx) {
rb.Push<u64>(nv_flinger->OpenDisplay(name)); rb.Push<u64>(nv_flinger->OpenDisplay(name));
} }
void IApplicationDisplayService::CloseDisplay(Kernel::HLERequestContext& ctx) { void CloseDisplay(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called"); LOG_WARNING(Service_VI, "(STUBBED) called");
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
u64 display_id = rp.Pop<u64>(); u64 display_id = rp.Pop<u64>();
@ -703,7 +711,27 @@ void IApplicationDisplayService::CloseDisplay(Kernel::HLERequestContext& ctx) {
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
} }
void IApplicationDisplayService::OpenLayer(Kernel::HLERequestContext& ctx) { void SetLayerScalingMode(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called");
IPC::RequestParser rp{ctx};
u32 scaling_mode = rp.Pop<u32>();
u64 unknown = rp.Pop<u64>();
IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
rb.Push(RESULT_SUCCESS);
}
void ListDisplays(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
DisplayInfo display_info;
ctx.WriteBuffer(&display_info, sizeof(DisplayInfo));
IPC::ResponseBuilder rb = rp.MakeBuilder(4, 0, 0);
rb.Push(RESULT_SUCCESS);
rb.Push<u64>(1);
LOG_WARNING(Service_VI, "(STUBBED) called");
}
void OpenLayer(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_VI, "called"); LOG_DEBUG(Service_VI, "called");
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
auto name_buf = rp.PopRaw<std::array<u8, 0x40>>(); auto name_buf = rp.PopRaw<std::array<u8, 0x40>>();
@ -723,7 +751,7 @@ void IApplicationDisplayService::OpenLayer(Kernel::HLERequestContext& ctx) {
rb.Push<u64>(ctx.WriteBuffer(native_window.Serialize())); rb.Push<u64>(ctx.WriteBuffer(native_window.Serialize()));
} }
void IApplicationDisplayService::CreateStrayLayer(Kernel::HLERequestContext& ctx) { void CreateStrayLayer(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_VI, "called"); LOG_DEBUG(Service_VI, "called");
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
@ -743,7 +771,7 @@ void IApplicationDisplayService::CreateStrayLayer(Kernel::HLERequestContext& ctx
rb.Push<u64>(ctx.WriteBuffer(native_window.Serialize())); rb.Push<u64>(ctx.WriteBuffer(native_window.Serialize()));
} }
void IApplicationDisplayService::DestroyStrayLayer(Kernel::HLERequestContext& ctx) { void DestroyStrayLayer(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called"); LOG_WARNING(Service_VI, "(STUBBED) called");
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
@ -753,27 +781,7 @@ void IApplicationDisplayService::DestroyStrayLayer(Kernel::HLERequestContext& ct
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
} }
void IApplicationDisplayService::SetLayerScalingMode(Kernel::HLERequestContext& ctx) { void GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called");
IPC::RequestParser rp{ctx};
u32 scaling_mode = rp.Pop<u32>();
u64 unknown = rp.Pop<u64>();
IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
rb.Push(RESULT_SUCCESS);
}
void IApplicationDisplayService::ListDisplays(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
DisplayInfo display_info;
ctx.WriteBuffer(&display_info, sizeof(DisplayInfo));
IPC::ResponseBuilder rb = rp.MakeBuilder(4, 0, 0);
rb.Push(RESULT_SUCCESS);
rb.Push<u64>(1);
LOG_WARNING(Service_VI, "(STUBBED) called");
}
void IApplicationDisplayService::GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called"); LOG_WARNING(Service_VI, "(STUBBED) called");
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
u64 display_id = rp.Pop<u64>(); u64 display_id = rp.Pop<u64>();
@ -785,6 +793,9 @@ void IApplicationDisplayService::GetDisplayVsyncEvent(Kernel::HLERequestContext&
rb.PushCopyObjects(vsync_event); rb.PushCopyObjects(vsync_event);
} }
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger;
};
IApplicationDisplayService::IApplicationDisplayService( IApplicationDisplayService::IApplicationDisplayService(
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
: ServiceFramework("IApplicationDisplayService"), nv_flinger(std::move(nv_flinger)) { : ServiceFramework("IApplicationDisplayService"), nv_flinger(std::move(nv_flinger)) {
@ -806,11 +817,24 @@ IApplicationDisplayService::IApplicationDisplayService(
RegisterHandlers(functions); RegisterHandlers(functions);
} }
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name,
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
: ServiceFramework(name), module(std::move(module)), nv_flinger(std::move(nv_flinger)) {}
void Module::Interface::GetDisplayService(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushIpcInterface<IApplicationDisplayService>(nv_flinger);
}
void InstallInterfaces(SM::ServiceManager& service_manager, void InstallInterfaces(SM::ServiceManager& service_manager,
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) { std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) {
std::make_shared<VI_M>(nv_flinger)->InstallAsService(service_manager); auto module = std::make_shared<Module>();
std::make_shared<VI_S>(nv_flinger)->InstallAsService(service_manager); std::make_shared<VI_M>(module, nv_flinger)->InstallAsService(service_manager);
std::make_shared<VI_U>(nv_flinger)->InstallAsService(service_manager); std::make_shared<VI_S>(module, nv_flinger)->InstallAsService(service_manager);
std::make_shared<VI_U>(module, nv_flinger)->InstallAsService(service_manager);
} }
} // namespace VI } // namespace VI

View file

@ -4,9 +4,6 @@
#pragma once #pragma once
#include <memory>
#include <boost/optional.hpp>
#include "core/hle/kernel/event.h"
#include "core/hle/service/nvflinger/nvflinger.h" #include "core/hle/service/nvflinger/nvflinger.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
@ -17,27 +14,20 @@ struct EventType;
namespace Service { namespace Service {
namespace VI { namespace VI {
class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> { class Module final {
public: public:
IApplicationDisplayService(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger); class Interface : public ServiceFramework<Interface> {
~IApplicationDisplayService() = default; public:
Interface(std::shared_ptr<Module> module, const char* name,
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
private: void GetDisplayService(Kernel::HLERequestContext& ctx);
void GetRelayService(Kernel::HLERequestContext& ctx);
void GetSystemDisplayService(Kernel::HLERequestContext& ctx);
void GetManagerDisplayService(Kernel::HLERequestContext& ctx);
void GetIndirectDisplayTransactionService(Kernel::HLERequestContext& ctx);
void OpenDisplay(Kernel::HLERequestContext& ctx);
void CloseDisplay(Kernel::HLERequestContext& ctx);
void SetLayerScalingMode(Kernel::HLERequestContext& ctx);
void ListDisplays(Kernel::HLERequestContext& ctx);
void OpenLayer(Kernel::HLERequestContext& ctx);
void CreateStrayLayer(Kernel::HLERequestContext& ctx);
void DestroyStrayLayer(Kernel::HLERequestContext& ctx);
void GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx);
protected:
std::shared_ptr<Module> module;
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger; std::shared_ptr<NVFlinger::NVFlinger> nv_flinger;
}; };
};
/// Registers all VI services with the specified service manager. /// Registers all VI services with the specified service manager.
void InstallInterfaces(SM::ServiceManager& service_manager, void InstallInterfaces(SM::ServiceManager& service_manager,

View file

@ -2,24 +2,13 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/logging/log.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/vi/vi.h"
#include "core/hle/service/vi/vi_m.h" #include "core/hle/service/vi/vi_m.h"
namespace Service { namespace Service {
namespace VI { namespace VI {
void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) { VI_M::VI_M(std::shared_ptr<Module> module, std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
LOG_WARNING(Service_VI, "(STUBBED) called"); : Module::Interface(std::move(module), "vi:m", std::move(nv_flinger)) {
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushIpcInterface<IApplicationDisplayService>(nv_flinger);
}
VI_M::VI_M(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
: ServiceFramework("vi:m"), nv_flinger(std::move(nv_flinger)) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{2, &VI_M::GetDisplayService, "GetDisplayService"}, {2, &VI_M::GetDisplayService, "GetDisplayService"},
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, {3, nullptr, "GetDisplayServiceWithProxyNameExchange"},

View file

@ -4,25 +4,14 @@
#pragma once #pragma once
#include <memory> #include "core/hle/service/vi/vi.h"
#include "core/hle/service/service.h"
namespace Service { namespace Service {
namespace NVFlinger {
class NVFlinger;
}
namespace VI { namespace VI {
class VI_M final : public ServiceFramework<VI_M> { class VI_M final : public Module::Interface {
public: public:
VI_M(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger); explicit VI_M(std::shared_ptr<Module> module, std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
~VI_M() = default;
private:
void GetDisplayService(Kernel::HLERequestContext& ctx);
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger;
}; };
} // namespace VI } // namespace VI

View file

@ -2,24 +2,13 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/logging/log.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/vi/vi.h"
#include "core/hle/service/vi/vi_s.h" #include "core/hle/service/vi/vi_s.h"
namespace Service { namespace Service {
namespace VI { namespace VI {
void VI_S::GetDisplayService(Kernel::HLERequestContext& ctx) { VI_S::VI_S(std::shared_ptr<Module> module, std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
LOG_WARNING(Service_VI, "(STUBBED) called"); : Module::Interface(std::move(module), "vi:s", std::move(nv_flinger)) {
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushIpcInterface<IApplicationDisplayService>(nv_flinger);
}
VI_S::VI_S(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
: ServiceFramework("vi:s"), nv_flinger(std::move(nv_flinger)) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{1, &VI_S::GetDisplayService, "GetDisplayService"}, {1, &VI_S::GetDisplayService, "GetDisplayService"},
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, {3, nullptr, "GetDisplayServiceWithProxyNameExchange"},

View file

@ -4,25 +4,14 @@
#pragma once #pragma once
#include <memory> #include "core/hle/service/vi/vi.h"
#include "core/hle/service/service.h"
namespace Service { namespace Service {
namespace NVFlinger {
class NVFlinger;
}
namespace VI { namespace VI {
class VI_S final : public ServiceFramework<VI_S> { class VI_S final : public Module::Interface {
public: public:
VI_S(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger); explicit VI_S(std::shared_ptr<Module> module, std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
~VI_S() = default;
private:
void GetDisplayService(Kernel::HLERequestContext& ctx);
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger;
}; };
} // namespace VI } // namespace VI

View file

@ -2,24 +2,13 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/logging/log.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/vi/vi.h"
#include "core/hle/service/vi/vi_u.h" #include "core/hle/service/vi/vi_u.h"
namespace Service { namespace Service {
namespace VI { namespace VI {
void VI_U::GetDisplayService(Kernel::HLERequestContext& ctx) { VI_U::VI_U(std::shared_ptr<Module> module, std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
LOG_WARNING(Service_VI, "(STUBBED) called"); : Module::Interface(std::move(module), "vi:u", std::move(nv_flinger)) {
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushIpcInterface<IApplicationDisplayService>(nv_flinger);
}
VI_U::VI_U(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
: ServiceFramework("vi:u"), nv_flinger(std::move(nv_flinger)) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &VI_U::GetDisplayService, "GetDisplayService"}, {0, &VI_U::GetDisplayService, "GetDisplayService"},
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, {3, nullptr, "GetDisplayServiceWithProxyNameExchange"},

View file

@ -4,25 +4,14 @@
#pragma once #pragma once
#include <memory> #include "core/hle/service/vi/vi.h"
#include "core/hle/service/service.h"
namespace Service { namespace Service {
namespace NVFlinger {
class NVFlinger;
}
namespace VI { namespace VI {
class VI_U final : public ServiceFramework<VI_U> { class VI_U final : public Module::Interface {
public: public:
VI_U(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger); explicit VI_U(std::shared_ptr<Module> module, std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
~VI_U() = default;
private:
void GetDisplayService(Kernel::HLERequestContext& ctx);
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger;
}; };
} // namespace VI } // namespace VI