summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/vi
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2024-02-14 17:39:42 +0100
committerLiam <byteslice@airmail.cc>2024-02-18 00:01:41 +0100
commitee8eccc5fa473f2ce210eb4e242e8eca40594db7 (patch)
tree5c38fc738e52be88eddd7733e0fdeb248ef4783f /src/core/hle/service/vi
parentam: unify display layer management (diff)
downloadyuzu-ee8eccc5fa473f2ce210eb4e242e8eca40594db7.tar
yuzu-ee8eccc5fa473f2ce210eb4e242e8eca40594db7.tar.gz
yuzu-ee8eccc5fa473f2ce210eb4e242e8eca40594db7.tar.bz2
yuzu-ee8eccc5fa473f2ce210eb4e242e8eca40594db7.tar.lz
yuzu-ee8eccc5fa473f2ce210eb4e242e8eca40594db7.tar.xz
yuzu-ee8eccc5fa473f2ce210eb4e242e8eca40594db7.tar.zst
yuzu-ee8eccc5fa473f2ce210eb4e242e8eca40594db7.zip
Diffstat (limited to 'src/core/hle/service/vi')
-rw-r--r--src/core/hle/service/vi/application_display_service.cpp47
-rw-r--r--src/core/hle/service/vi/application_display_service.h18
-rw-r--r--src/core/hle/service/vi/application_root_service.cpp10
-rw-r--r--src/core/hle/service/vi/application_root_service.h10
-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.cpp9
-rw-r--r--src/core/hle/service/vi/manager_display_service.h5
-rw-r--r--src/core/hle/service/vi/manager_root_service.cpp10
-rw-r--r--src/core/hle/service/vi/manager_root_service.h10
-rw-r--r--src/core/hle/service/vi/service_creator.cpp7
-rw-r--r--src/core/hle/service/vi/service_creator.h8
-rw-r--r--src/core/hle/service/vi/system_display_service.cpp17
-rw-r--r--src/core/hle/service/vi/system_display_service.h8
-rw-r--r--src/core/hle/service/vi/system_root_service.cpp11
-rw-r--r--src/core/hle/service/vi/system_root_service.h10
-rw-r--r--src/core/hle/service/vi/vi.cpp18
-rw-r--r--src/core/hle/service/vi/vi.h8
18 files changed, 100 insertions, 189 deletions
diff --git a/src/core/hle/service/vi/application_display_service.cpp b/src/core/hle/service/vi/application_display_service.cpp
index 78229e30f..a6e04bf60 100644
--- a/src/core/hle/service/vi/application_display_service.cpp
+++ b/src/core/hle/service/vi/application_display_service.cpp
@@ -2,10 +2,10 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/cmif_serialization.h"
+#include "core/hle/service/nvnflinger/hos_binder_driver.h"
#include "core/hle/service/nvnflinger/nvnflinger.h"
#include "core/hle/service/nvnflinger/parcel.h"
#include "core/hle/service/vi/application_display_service.h"
-#include "core/hle/service/vi/hos_binder_driver.h"
#include "core/hle/service/vi/manager_display_service.h"
#include "core/hle/service/vi/system_display_service.h"
#include "core/hle/service/vi/vi_results.h"
@@ -13,10 +13,10 @@
namespace Service::VI {
IApplicationDisplayService::IApplicationDisplayService(
- Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server)
- : ServiceFramework{system_, "IApplicationDisplayService"}, m_nvnflinger{nvnflinger},
- m_hos_binder_driver_server{hos_binder_driver_server} {
+ Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service)
+ : ServiceFramework{system_, "IApplicationDisplayService"},
+ m_binder_service{std::move(binder_service)},
+ m_surface_flinger{m_binder_service->GetSurfaceFlinger()} {
// clang-format off
static const FunctionInfo functions[] = {
@@ -49,36 +49,37 @@ IApplicationDisplayService::IApplicationDisplayService(
IApplicationDisplayService::~IApplicationDisplayService() {
for (const auto layer_id : m_stray_layer_ids) {
- m_nvnflinger.DestroyLayer(layer_id);
+ m_surface_flinger->DestroyLayer(layer_id);
}
}
Result IApplicationDisplayService::GetRelayService(
- Out<SharedPointer<IHOSBinderDriver>> out_relay_service) {
+ Out<SharedPointer<Nvnflinger::IHOSBinderDriver>> out_relay_service) {
LOG_WARNING(Service_VI, "(STUBBED) called");
- *out_relay_service = std::make_shared<IHOSBinderDriver>(system, m_hos_binder_driver_server);
+ *out_relay_service = m_binder_service;
R_SUCCEED();
}
Result IApplicationDisplayService::GetSystemDisplayService(
Out<SharedPointer<ISystemDisplayService>> out_system_display_service) {
LOG_WARNING(Service_VI, "(STUBBED) called");
- *out_system_display_service = std::make_shared<ISystemDisplayService>(system, m_nvnflinger);
+ *out_system_display_service =
+ std::make_shared<ISystemDisplayService>(system, m_surface_flinger);
R_SUCCEED();
}
Result IApplicationDisplayService::GetManagerDisplayService(
Out<SharedPointer<IManagerDisplayService>> out_manager_display_service) {
LOG_WARNING(Service_VI, "(STUBBED) called");
- *out_manager_display_service = std::make_shared<IManagerDisplayService>(system, m_nvnflinger);
+ *out_manager_display_service =
+ std::make_shared<IManagerDisplayService>(system, m_surface_flinger);
R_SUCCEED();
}
Result IApplicationDisplayService::GetIndirectDisplayTransactionService(
- Out<SharedPointer<IHOSBinderDriver>> out_indirect_display_transaction_service) {
+ Out<SharedPointer<Nvnflinger::IHOSBinderDriver>> out_indirect_display_transaction_service) {
LOG_WARNING(Service_VI, "(STUBBED) called");
- *out_indirect_display_transaction_service =
- std::make_shared<IHOSBinderDriver>(system, m_hos_binder_driver_server);
+ *out_indirect_display_transaction_service = m_binder_service;
R_SUCCEED();
}
@@ -89,7 +90,7 @@ Result IApplicationDisplayService::OpenDisplay(Out<u64> out_display_id, DisplayN
ASSERT_MSG(strcmp(display_name.data(), "Default") == 0,
"Non-default displays aren't supported yet");
- const auto display_id = m_nvnflinger.OpenDisplay(display_name.data());
+ const auto display_id = m_surface_flinger->OpenDisplay(display_name.data());
if (!display_id) {
LOG_ERROR(Service_VI, "Display not found! display_name={}", display_name.data());
R_THROW(VI::ResultNotFound);
@@ -106,7 +107,7 @@ Result IApplicationDisplayService::OpenDefaultDisplay(Out<u64> out_display_id) {
Result IApplicationDisplayService::CloseDisplay(u64 display_id) {
LOG_DEBUG(Service_VI, "called");
- R_SUCCEED_IF(m_nvnflinger.CloseDisplay(display_id));
+ R_SUCCEED_IF(m_surface_flinger->CloseDisplay(display_id));
R_THROW(ResultUnknown);
}
@@ -168,19 +169,19 @@ Result IApplicationDisplayService::OpenLayer(Out<u64> out_size,
LOG_DEBUG(Service_VI, "called. layer_id={}, aruid={:#x}", layer_id, aruid.pid);
- const auto display_id = m_nvnflinger.OpenDisplay(display_name.data());
+ const auto display_id = m_surface_flinger->OpenDisplay(display_name.data());
if (!display_id) {
LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id);
R_THROW(VI::ResultNotFound);
}
- const auto buffer_queue_id = m_nvnflinger.FindBufferQueueId(*display_id, layer_id);
+ const auto buffer_queue_id = m_surface_flinger->FindBufferQueueId(*display_id, layer_id);
if (!buffer_queue_id) {
LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id);
R_THROW(VI::ResultNotFound);
}
- if (!m_nvnflinger.OpenLayer(layer_id)) {
+ if (!m_surface_flinger->OpenLayer(layer_id)) {
LOG_WARNING(Service_VI, "Tried to open layer which was already open");
R_THROW(VI::ResultOperationFailed);
}
@@ -199,7 +200,7 @@ Result IApplicationDisplayService::OpenLayer(Out<u64> out_size,
Result IApplicationDisplayService::CloseLayer(u64 layer_id) {
LOG_DEBUG(Service_VI, "called. layer_id={}", layer_id);
- if (!m_nvnflinger.CloseLayer(layer_id)) {
+ if (!m_surface_flinger->CloseLayer(layer_id)) {
LOG_WARNING(Service_VI, "Tried to close layer which was not open");
R_THROW(VI::ResultOperationFailed);
}
@@ -212,14 +213,14 @@ Result IApplicationDisplayService::CreateStrayLayer(
u32 flags, u64 display_id) {
LOG_DEBUG(Service_VI, "called. flags={}, display_id={}", flags, display_id);
- const auto layer_id = m_nvnflinger.CreateLayer(display_id);
+ const auto layer_id = m_surface_flinger->CreateLayer(display_id);
if (!layer_id) {
LOG_ERROR(Service_VI, "Layer not found! display_id={}", display_id);
R_THROW(VI::ResultNotFound);
}
m_stray_layer_ids.push_back(*layer_id);
- const auto buffer_queue_id = m_nvnflinger.FindBufferQueueId(display_id, *layer_id);
+ const auto buffer_queue_id = m_surface_flinger->FindBufferQueueId(display_id, *layer_id);
if (!buffer_queue_id) {
LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id);
R_THROW(VI::ResultNotFound);
@@ -240,7 +241,7 @@ Result IApplicationDisplayService::CreateStrayLayer(
Result IApplicationDisplayService::DestroyStrayLayer(u64 layer_id) {
LOG_WARNING(Service_VI, "(STUBBED) called. layer_id={}", layer_id);
- m_nvnflinger.DestroyLayer(layer_id);
+ m_surface_flinger->DestroyLayer(layer_id);
R_SUCCEED();
}
@@ -248,7 +249,7 @@ Result IApplicationDisplayService::GetDisplayVsyncEvent(
OutCopyHandle<Kernel::KReadableEvent> out_vsync_event, u64 display_id) {
LOG_DEBUG(Service_VI, "called. display_id={}", display_id);
- const auto result = m_nvnflinger.FindVsyncEvent(out_vsync_event, display_id);
+ const auto result = m_surface_flinger->FindVsyncEvent(out_vsync_event, display_id);
if (result != ResultSuccess) {
if (result == ResultNotFound) {
LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id);
diff --git a/src/core/hle/service/vi/application_display_service.h b/src/core/hle/service/vi/application_display_service.h
index 5dff4bb31..e56490f9f 100644
--- a/src/core/hle/service/vi/application_display_service.h
+++ b/src/core/hle/service/vi/application_display_service.h
@@ -9,26 +9,30 @@ namespace Kernel {
class KReadableEvent;
}
+namespace Service::Nvnflinger {
+class Nvnflinger;
+class IHOSBinderDriver;
+} // namespace Service::Nvnflinger
+
namespace Service::VI {
-class IHOSBinderDriver;
class IManagerDisplayService;
class ISystemDisplayService;
class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> {
public:
- IApplicationDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
+ IApplicationDisplayService(Core::System& system_,
+ std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service);
~IApplicationDisplayService() override;
private:
- Result GetRelayService(Out<SharedPointer<IHOSBinderDriver>> out_relay_service);
+ Result GetRelayService(Out<SharedPointer<Nvnflinger::IHOSBinderDriver>> out_relay_service);
Result GetSystemDisplayService(
Out<SharedPointer<ISystemDisplayService>> out_system_display_service);
Result GetManagerDisplayService(
Out<SharedPointer<IManagerDisplayService>> out_manager_display_service);
Result GetIndirectDisplayTransactionService(
- Out<SharedPointer<IHOSBinderDriver>> out_indirect_display_transaction_service);
+ Out<SharedPointer<Nvnflinger::IHOSBinderDriver>> out_indirect_display_transaction_service);
Result OpenDisplay(Out<u64> out_display_id, DisplayName display_name);
Result OpenDefaultDisplay(Out<u64> out_display_id);
Result CloseDisplay(u64 display_id);
@@ -56,8 +60,8 @@ private:
s64 width, s64 height);
private:
- Nvnflinger::Nvnflinger& m_nvnflinger;
- Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server;
+ const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
+ const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger;
std::vector<u64> m_stray_layer_ids;
bool m_vsync_event_fetched{false};
};
diff --git a/src/core/hle/service/vi/application_root_service.cpp b/src/core/hle/service/vi/application_root_service.cpp
index 7af7f062c..501fbdd6a 100644
--- a/src/core/hle/service/vi/application_root_service.cpp
+++ b/src/core/hle/service/vi/application_root_service.cpp
@@ -11,10 +11,8 @@
namespace Service::VI {
IApplicationRootService::IApplicationRootService(
- Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server)
- : ServiceFramework{system_, "vi:u"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{
- hos_binder_driver_server} {
+ Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service)
+ : ServiceFramework{system_, "vi:u"}, m_binder_service{std::move(binder_service)} {
static const FunctionInfo functions[] = {
{0, C<&IApplicationRootService::GetDisplayService>, "GetDisplayService"},
{1, nullptr, "GetDisplayServiceWithProxyNameExchange"},
@@ -27,8 +25,8 @@ IApplicationRootService::~IApplicationRootService() = default;
Result IApplicationRootService::GetDisplayService(
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
LOG_DEBUG(Service_VI, "called");
- R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger,
- m_hos_binder_driver_server, Permission::User, policy));
+ R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service,
+ Permission::User, policy));
}
} // 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
index 9dbf28cb4..d1f023e9e 100644
--- a/src/core/hle/service/vi/application_root_service.h
+++ b/src/core/hle/service/vi/application_root_service.h
@@ -11,8 +11,7 @@ class System;
}
namespace Service::Nvnflinger {
-class HosBinderDriverServer;
-class Nvnflinger;
+class IHOSBinderDriver;
} // namespace Service::Nvnflinger
namespace Service::VI {
@@ -22,8 +21,8 @@ enum class Policy : u32;
class IApplicationRootService final : public ServiceFramework<IApplicationRootService> {
public:
- explicit IApplicationRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
+ explicit IApplicationRootService(Core::System& system_,
+ std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service);
~IApplicationRootService() override;
private:
@@ -32,8 +31,7 @@ private:
Policy policy);
private:
- Nvnflinger::Nvnflinger& m_nvnflinger;
- Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server;
+ const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
};
} // 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
deleted file mode 100644
index ba0317245..000000000
--- a/src/core/hle/service/vi/hos_binder_driver.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#include "core/hle/service/cmif_serialization.h"
-#include "core/hle/service/nvnflinger/binder.h"
-#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
-#include "core/hle/service/vi/hos_binder_driver.h"
-
-namespace Service::VI {
-
-IHOSBinderDriver::IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server)
- : ServiceFramework{system_, "IHOSBinderDriver"}, m_server(server) {
- static const FunctionInfo functions[] = {
- {0, C<&IHOSBinderDriver::TransactParcel>, "TransactParcel"},
- {1, C<&IHOSBinderDriver::AdjustRefcount>, "AdjustRefcount"},
- {2, C<&IHOSBinderDriver::GetNativeHandle>, "GetNativeHandle"},
- {3, C<&IHOSBinderDriver::TransactParcelAuto>, "TransactParcelAuto"},
- };
- RegisterHandlers(functions);
-}
-
-IHOSBinderDriver::~IHOSBinderDriver() = default;
-
-Result IHOSBinderDriver::TransactParcel(s32 binder_id, android::TransactionId transaction_id,
- InBuffer<BufferAttr_HipcMapAlias> parcel_data,
- OutBuffer<BufferAttr_HipcMapAlias> parcel_reply,
- u32 flags) {
- LOG_DEBUG(Service_VI, "called. id={} transaction={}, flags={}", binder_id, transaction_id,
- flags);
- m_server.TryGetProducer(binder_id)->Transact(transaction_id, flags, parcel_data, parcel_reply);
- R_SUCCEED();
-}
-
-Result IHOSBinderDriver::AdjustRefcount(s32 binder_id, s32 addval, s32 type) {
- LOG_WARNING(Service_VI, "(STUBBED) called id={}, addval={}, type={}", binder_id, addval, type);
- R_SUCCEED();
-}
-
-Result IHOSBinderDriver::GetNativeHandle(s32 binder_id, u32 type_id,
- OutCopyHandle<Kernel::KReadableEvent> out_handle) {
- LOG_WARNING(Service_VI, "(STUBBED) called id={}, type_id={}", binder_id, type_id);
- *out_handle = &m_server.TryGetProducer(binder_id)->GetNativeHandle();
- R_SUCCEED();
-}
-
-Result IHOSBinderDriver::TransactParcelAuto(s32 binder_id, android::TransactionId transaction_id,
- InBuffer<BufferAttr_HipcAutoSelect> parcel_data,
- OutBuffer<BufferAttr_HipcAutoSelect> parcel_reply,
- u32 flags) {
- R_RETURN(this->TransactParcel(binder_id, transaction_id, parcel_data, parcel_reply, flags));
-}
-
-} // 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
deleted file mode 100644
index ed6e8cdbe..000000000
--- a/src/core/hle/service/vi/hos_binder_driver.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#include "core/hle/service/cmif_types.h"
-#include "core/hle/service/nvnflinger/binder.h"
-#include "core/hle/service/service.h"
-
-namespace Service::VI {
-
-class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> {
-public:
- explicit IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server);
- ~IHOSBinderDriver() override;
-
-private:
- Result TransactParcel(s32 binder_id, android::TransactionId transaction_id,
- InBuffer<BufferAttr_HipcMapAlias> parcel_data,
- OutBuffer<BufferAttr_HipcMapAlias> parcel_reply, u32 flags);
- Result AdjustRefcount(s32 binder_id, s32 addval, s32 type);
- Result GetNativeHandle(s32 binder_id, u32 type_id,
- OutCopyHandle<Kernel::KReadableEvent> out_handle);
- Result TransactParcelAuto(s32 binder_id, android::TransactionId transaction_id,
- InBuffer<BufferAttr_HipcAutoSelect> parcel_data,
- OutBuffer<BufferAttr_HipcAutoSelect> parcel_reply, u32 flags);
-
-private:
- Nvnflinger::HosBinderDriverServer& m_server;
-};
-
-} // 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
index 17f2f3b8f..22454ba61 100644
--- a/src/core/hle/service/vi/manager_display_service.cpp
+++ b/src/core/hle/service/vi/manager_display_service.cpp
@@ -8,9 +8,10 @@
namespace Service::VI {
-IManagerDisplayService::IManagerDisplayService(Core::System& system_,
- Nvnflinger::Nvnflinger& nvnflinger)
- : ServiceFramework{system_, "IManagerDisplayService"}, m_nvnflinger{nvnflinger} {
+IManagerDisplayService::IManagerDisplayService(
+ Core::System& system_, std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger)
+ : ServiceFramework{system_, "IManagerDisplayService"},
+ m_surface_flinger{std::move(surface_flinger)} {
// clang-format off
static const FunctionInfo functions[] = {
{200, nullptr, "AllocateProcessHeapBlock"},
@@ -107,7 +108,7 @@ Result IManagerDisplayService::CreateManagedLayer(Out<u64> out_layer_id, u32 unk
LOG_WARNING(Service_VI, "(STUBBED) called. unknown={}, display={}, aruid={}", unknown,
display_id, aruid.pid);
- const auto layer_id = m_nvnflinger.CreateLayer(display_id);
+ const auto layer_id = m_surface_flinger->CreateLayer(display_id);
if (!layer_id) {
LOG_ERROR(Service_VI, "Layer not found! display={}", display_id);
R_THROW(VI::ResultNotFound);
diff --git a/src/core/hle/service/vi/manager_display_service.h b/src/core/hle/service/vi/manager_display_service.h
index 60e646ee0..4a3d53ff8 100644
--- a/src/core/hle/service/vi/manager_display_service.h
+++ b/src/core/hle/service/vi/manager_display_service.h
@@ -8,7 +8,8 @@ namespace Service::VI {
class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> {
public:
- explicit IManagerDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger);
+ explicit IManagerDisplayService(Core::System& system_,
+ std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger);
~IManagerDisplayService() override;
private:
@@ -18,7 +19,7 @@ private:
Result SetLayerVisibility(bool visible, u64 layer_id);
private:
- Nvnflinger::Nvnflinger& m_nvnflinger;
+ const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger;
};
} // 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
index a7eee4f04..36b84909a 100644
--- a/src/core/hle/service/vi/manager_root_service.cpp
+++ b/src/core/hle/service/vi/manager_root_service.cpp
@@ -11,10 +11,8 @@
namespace Service::VI {
IManagerRootService::IManagerRootService(
- Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server)
- : ServiceFramework{system_, "vi:m"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{
- hos_binder_driver_server} {
+ Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service)
+ : ServiceFramework{system_, "vi:m"}, m_binder_service{std::move(binder_service)} {
static const FunctionInfo functions[] = {
{2, C<&IManagerRootService::GetDisplayService>, "GetDisplayService"},
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
@@ -31,8 +29,8 @@ IManagerRootService::~IManagerRootService() = default;
Result IManagerRootService::GetDisplayService(
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
LOG_DEBUG(Service_VI, "called");
- R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger,
- m_hos_binder_driver_server, Permission::Manager, policy));
+ R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service,
+ Permission::Manager, policy));
}
} // 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
index e6cb77aeb..26aa95a88 100644
--- a/src/core/hle/service/vi/manager_root_service.h
+++ b/src/core/hle/service/vi/manager_root_service.h
@@ -11,8 +11,7 @@ class System;
}
namespace Service::Nvnflinger {
-class HosBinderDriverServer;
-class Nvnflinger;
+class IHOSBinderDriver;
} // namespace Service::Nvnflinger
namespace Service::VI {
@@ -22,8 +21,8 @@ enum class Policy : u32;
class IManagerRootService final : public ServiceFramework<IManagerRootService> {
public:
- explicit IManagerRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
+ explicit IManagerRootService(Core::System& system_,
+ std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service);
~IManagerRootService() override;
private:
@@ -31,8 +30,7 @@ private:
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service,
Policy policy);
- Nvnflinger::Nvnflinger& m_nvnflinger;
- Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server;
+ const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
};
} // namespace Service::VI
diff --git a/src/core/hle/service/vi/service_creator.cpp b/src/core/hle/service/vi/service_creator.cpp
index 1de9d61a4..594e57398 100644
--- a/src/core/hle/service/vi/service_creator.cpp
+++ b/src/core/hle/service/vi/service_creator.cpp
@@ -22,9 +22,8 @@ static bool IsValidServiceAccess(Permission permission, Policy policy) {
Result GetApplicationDisplayService(
std::shared_ptr<IApplicationDisplayService>* out_application_display_service,
- Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, Permission permission,
- Policy policy) {
+ Core::System& system, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
+ Permission permission, Policy policy) {
if (!IsValidServiceAccess(permission, policy)) {
LOG_ERROR(Service_VI, "Permission denied for policy {}", policy);
@@ -32,7 +31,7 @@ Result GetApplicationDisplayService(
}
*out_application_display_service =
- std::make_shared<IApplicationDisplayService>(system, nvnflinger, hos_binder_driver_server);
+ std::make_shared<IApplicationDisplayService>(system, binder_service);
R_SUCCEED();
}
diff --git a/src/core/hle/service/vi/service_creator.h b/src/core/hle/service/vi/service_creator.h
index 8963bcd26..bdfac8a08 100644
--- a/src/core/hle/service/vi/service_creator.h
+++ b/src/core/hle/service/vi/service_creator.h
@@ -12,8 +12,7 @@ class System;
}
namespace Service::Nvnflinger {
-class HosBinderDriverServer;
-class Nvnflinger;
+class IHOSBinderDriver;
} // namespace Service::Nvnflinger
union Result;
@@ -26,8 +25,7 @@ enum class Policy : u32;
Result GetApplicationDisplayService(
std::shared_ptr<IApplicationDisplayService>* out_application_display_service,
- Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, Permission permission,
- Policy policy);
+ Core::System& system, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
+ Permission permission, Policy policy);
} // 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
index 1e1cfc817..8d6c3f04c 100644
--- a/src/core/hle/service/vi/system_display_service.cpp
+++ b/src/core/hle/service/vi/system_display_service.cpp
@@ -9,9 +9,10 @@
namespace Service::VI {
-ISystemDisplayService::ISystemDisplayService(Core::System& system_,
- Nvnflinger::Nvnflinger& nvnflinger)
- : ServiceFramework{system_, "ISystemDisplayService"}, m_nvnflinger{nvnflinger} {
+ISystemDisplayService::ISystemDisplayService(
+ Core::System& system_, std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger)
+ : ServiceFramework{system_, "ISystemDisplayService"},
+ m_surface_flinger{std::move(surface_flinger)} {
// clang-format off
static const FunctionInfo functions[] = {
{1200, nullptr, "GetZOrderCountMin"},
@@ -104,7 +105,7 @@ Result ISystemDisplayService::GetSharedBufferMemoryHandleId(
u64 buffer_id, ClientAppletResourceUserId aruid) {
LOG_INFO(Service_VI, "called. buffer_id={}, aruid={:#x}", buffer_id, aruid.pid);
- R_RETURN(m_nvnflinger.GetSystemBufferManager().GetSharedBufferMemoryHandleId(
+ R_RETURN(m_surface_flinger->GetSystemBufferManager().GetSharedBufferMemoryHandleId(
out_size, out_nvmap_handle, out_pool_layout, buffer_id, aruid.pid));
}
@@ -122,7 +123,7 @@ Result ISystemDisplayService::AcquireSharedFrameBuffer(Out<android::Fence> out_f
Out<std::array<s32, 4>> out_slots,
Out<s64> out_target_slot, u64 layer_id) {
LOG_DEBUG(Service_VI, "called");
- R_RETURN(m_nvnflinger.GetSystemBufferManager().AcquireSharedFrameBuffer(
+ R_RETURN(m_surface_flinger->GetSystemBufferManager().AcquireSharedFrameBuffer(
out_fence, *out_slots, out_target_slot, layer_id));
}
@@ -131,15 +132,15 @@ Result ISystemDisplayService::PresentSharedFrameBuffer(android::Fence fence,
u32 window_transform, s32 swap_interval,
u64 layer_id, s64 surface_id) {
LOG_DEBUG(Service_VI, "called");
- R_RETURN(m_nvnflinger.GetSystemBufferManager().PresentSharedFrameBuffer(
+ R_RETURN(m_surface_flinger->GetSystemBufferManager().PresentSharedFrameBuffer(
fence, crop_region, window_transform, swap_interval, layer_id, surface_id));
}
Result ISystemDisplayService::GetSharedFrameBufferAcquirableEvent(
OutCopyHandle<Kernel::KReadableEvent> out_event, u64 layer_id) {
LOG_DEBUG(Service_VI, "called");
- R_RETURN(m_nvnflinger.GetSystemBufferManager().GetSharedFrameBufferAcquirableEvent(out_event,
- layer_id));
+ R_RETURN(m_surface_flinger->GetSystemBufferManager().GetSharedFrameBufferAcquirableEvent(
+ out_event, layer_id));
}
} // 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
index cfcb196fd..6c3f57ad7 100644
--- a/src/core/hle/service/vi/system_display_service.h
+++ b/src/core/hle/service/vi/system_display_service.h
@@ -7,14 +7,16 @@
#include "core/hle/service/service.h"
namespace Service::Nvnflinger {
+class Nvnflinger;
struct SharedMemoryPoolLayout;
-}
+} // namespace Service::Nvnflinger
namespace Service::VI {
class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> {
public:
- explicit ISystemDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger);
+ explicit ISystemDisplayService(Core::System& system_,
+ std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger);
~ISystemDisplayService() override;
private:
@@ -39,7 +41,7 @@ private:
s64 surface_id);
private:
- Nvnflinger::Nvnflinger& m_nvnflinger;
+ const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger;
};
} // 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
index 8789b4cfb..1d435ed6b 100644
--- a/src/core/hle/service/vi/system_root_service.cpp
+++ b/src/core/hle/service/vi/system_root_service.cpp
@@ -10,10 +10,9 @@
namespace Service::VI {
-ISystemRootService::ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server)
- : ServiceFramework{system_, "vi:s"}, m_nvnflinger{nvnflinger}, m_hos_binder_driver_server{
- hos_binder_driver_server} {
+ISystemRootService::ISystemRootService(Core::System& system_,
+ std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service)
+ : ServiceFramework{system_, "vi:s"}, m_binder_service{std::move(binder_service)} {
static const FunctionInfo functions[] = {
{1, C<&ISystemRootService::GetDisplayService>, "GetDisplayService"},
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
@@ -26,8 +25,8 @@ ISystemRootService::~ISystemRootService() = default;
Result ISystemRootService::GetDisplayService(
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
LOG_DEBUG(Service_VI, "called");
- R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_nvnflinger,
- m_hos_binder_driver_server, Permission::System, policy));
+ R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service,
+ Permission::System, policy));
}
} // 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
index 2c547faa5..6f07c39fd 100644
--- a/src/core/hle/service/vi/system_root_service.h
+++ b/src/core/hle/service/vi/system_root_service.h
@@ -11,8 +11,7 @@ class System;
}
namespace Service::Nvnflinger {
-class HosBinderDriverServer;
-class Nvnflinger;
+class IHOSBinderDriver;
} // namespace Service::Nvnflinger
namespace Service::VI {
@@ -22,8 +21,8 @@ enum class Policy : u32;
class ISystemRootService final : public ServiceFramework<ISystemRootService> {
public:
- explicit ISystemRootService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
+ explicit ISystemRootService(Core::System& system_,
+ std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service);
~ISystemRootService() override;
private:
@@ -31,8 +30,7 @@ private:
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service,
Policy policy);
- Nvnflinger::Nvnflinger& m_nvnflinger;
- Nvnflinger::HosBinderDriverServer& m_hos_binder_driver_server;
+ const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
};
} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 304e589b7..d20f1fdea 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -1,7 +1,10 @@
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include "core/core.h"
+#include "core/hle/service/nvnflinger/hos_binder_driver.h"
#include "core/hle/service/server_manager.h"
+#include "core/hle/service/sm/sm.h"
#include "core/hle/service/vi/application_display_service.h"
#include "core/hle/service/vi/application_root_service.h"
#include "core/hle/service/vi/manager_root_service.h"
@@ -10,16 +13,17 @@
namespace Service::VI {
-void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) {
+void LoopProcess(Core::System& system) {
+ const auto binder_service =
+ system.ServiceManager().GetService<Nvnflinger::IHOSBinderDriver>("dispdrv", true);
auto server_manager = std::make_unique<ServerManager>(system);
- server_manager->RegisterNamedService("vi:m", std::make_shared<IManagerRootService>(
- system, nvnflinger, hos_binder_driver_server));
server_manager->RegisterNamedService(
- "vi:s", std::make_shared<ISystemRootService>(system, nvnflinger, hos_binder_driver_server));
- server_manager->RegisterNamedService("vi:u", std::make_shared<IApplicationRootService>(
- system, nvnflinger, hos_binder_driver_server));
+ "vi:m", std::make_shared<IManagerRootService>(system, binder_service));
+ server_manager->RegisterNamedService(
+ "vi:s", std::make_shared<ISystemRootService>(system, binder_service));
+ server_manager->RegisterNamedService(
+ "vi:u", std::make_shared<IApplicationRootService>(system, binder_service));
ServerManager::RunServer(std::move(server_manager));
}
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h
index 8e681370d..0c3dc175d 100644
--- a/src/core/hle/service/vi/vi.h
+++ b/src/core/hle/service/vi/vi.h
@@ -7,14 +7,8 @@ namespace Core {
class System;
}
-namespace Service::Nvnflinger {
-class HosBinderDriverServer;
-class Nvnflinger;
-} // namespace Service::Nvnflinger
-
namespace Service::VI {
-void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
- Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
+void LoopProcess(Core::System& system);
} // namespace Service::VI