summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nvnflinger
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service/nvnflinger')
-rw-r--r--src/core/hle/service/nvnflinger/hos_binder_driver.cpp56
-rw-r--r--src/core/hle/service/nvnflinger/hos_binder_driver.h39
-rw-r--r--src/core/hle/service/nvnflinger/nvnflinger.cpp53
-rw-r--r--src/core/hle/service/nvnflinger/nvnflinger.h6
4 files changed, 123 insertions, 31 deletions
diff --git a/src/core/hle/service/nvnflinger/hos_binder_driver.cpp b/src/core/hle/service/nvnflinger/hos_binder_driver.cpp
new file mode 100644
index 000000000..e09d72047
--- /dev/null
+++ b/src/core/hle/service/nvnflinger/hos_binder_driver.cpp
@@ -0,0 +1,56 @@
+// 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.h"
+#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
+
+namespace Service::Nvnflinger {
+
+IHOSBinderDriver::IHOSBinderDriver(Core::System& system_,
+ std::shared_ptr<HosBinderDriverServer> server,
+ std::shared_ptr<Nvnflinger> surface_flinger)
+ : ServiceFramework{system_, "IHOSBinderDriver"}, m_server(server),
+ m_surface_flinger(surface_flinger) {
+ 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::Nvnflinger
diff --git a/src/core/hle/service/nvnflinger/hos_binder_driver.h b/src/core/hle/service/nvnflinger/hos_binder_driver.h
new file mode 100644
index 000000000..aa9e3121a
--- /dev/null
+++ b/src/core/hle/service/nvnflinger/hos_binder_driver.h
@@ -0,0 +1,39 @@
+// 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::Nvnflinger {
+
+class HosBinderDriverServer;
+class Nvnflinger;
+
+class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> {
+public:
+ explicit IHOSBinderDriver(Core::System& system_, std::shared_ptr<HosBinderDriverServer> server,
+ std::shared_ptr<Nvnflinger> surface_flinger);
+ ~IHOSBinderDriver() override;
+
+ std::shared_ptr<Nvnflinger> GetSurfaceFlinger() {
+ return m_surface_flinger;
+ }
+
+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:
+ const std::shared_ptr<HosBinderDriverServer> m_server;
+ const std::shared_ptr<Nvnflinger> m_surface_flinger;
+};
+
+} // namespace Service::Nvnflinger
diff --git a/src/core/hle/service/nvnflinger/nvnflinger.cpp b/src/core/hle/service/nvnflinger/nvnflinger.cpp
index 687ccc9f9..cd8062a2b 100644
--- a/src/core/hle/service/nvnflinger/nvnflinger.cpp
+++ b/src/core/hle/service/nvnflinger/nvnflinger.cpp
@@ -1,33 +1,24 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
-#include <algorithm>
-#include <optional>
-
-#include "common/assert.h"
-#include "common/logging/log.h"
#include "common/microprofile.h"
#include "common/scope_exit.h"
#include "common/settings.h"
-#include "common/thread.h"
#include "core/core.h"
#include "core/core_timing.h"
-#include "core/hle/kernel/k_readable_event.h"
#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h"
#include "core/hle/service/nvdrv/nvdrv.h"
-#include "core/hle/service/nvnflinger/buffer_item_consumer.h"
-#include "core/hle/service/nvnflinger/buffer_queue_core.h"
+#include "core/hle/service/nvdrv/nvdrv_interface.h"
#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
#include "core/hle/service/nvnflinger/hardware_composer.h"
+#include "core/hle/service/nvnflinger/hos_binder_driver.h"
#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
#include "core/hle/service/nvnflinger/nvnflinger.h"
-#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
+#include "core/hle/service/server_manager.h"
+#include "core/hle/service/sm/sm.h"
#include "core/hle/service/vi/display/vi_display.h"
#include "core/hle/service/vi/layer/vi_layer.h"
#include "core/hle/service/vi/vi_results.h"
-#include "video_core/gpu.h"
-#include "video_core/host1x/host1x.h"
-#include "video_core/host1x/syncpoint_manager.h"
namespace Service::Nvnflinger {
@@ -47,6 +38,11 @@ void Nvnflinger::SplitVSync(std::stop_token stop_token) {
while (!stop_token.stop_requested()) {
vsync_signal.Wait();
+ if (system.IsShuttingDown()) {
+ ShutdownLayers();
+ return;
+ }
+
const auto lock_guard = Lock();
if (!is_abandoned) {
@@ -65,6 +61,9 @@ Nvnflinger::Nvnflinger(Core::System& system_, HosBinderDriverServer& hos_binder_
displays.emplace_back(4, "Null", hos_binder_driver_server, service_context, system);
guard = std::make_shared<std::mutex>();
+ nvdrv = system.ServiceManager().GetService<Nvidia::NVDRV>("nvdrv:s", true)->GetModule();
+ disp_fd = nvdrv->Open("/dev/nvdisp_disp0", {});
+
// Schedule the screen composition events
multi_composition_event = Core::Timing::CreateEvent(
"ScreenComposition",
@@ -110,22 +109,12 @@ Nvnflinger::~Nvnflinger() {
void Nvnflinger::ShutdownLayers() {
// Abandon consumers.
- {
- const auto lock_guard = Lock();
- for (auto& display : displays) {
- display.Abandon();
- }
-
- is_abandoned = true;
+ const auto lock_guard = Lock();
+ for (auto& display : displays) {
+ display.Abandon();
}
- // Join the vsync thread, if it exists.
- vsync_thread = {};
-}
-
-void Nvnflinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) {
- nvdrv = std::move(instance);
- disp_fd = nvdrv->Open("/dev/nvdisp_disp0", {});
+ is_abandoned = true;
}
std::optional<u64> Nvnflinger::OpenDisplay(std::string_view name) {
@@ -332,4 +321,14 @@ FbShareBufferManager& Nvnflinger::GetSystemBufferManager() {
return *system_buffer_manager;
}
+void LoopProcess(Core::System& system) {
+ const auto binder_server = std::make_shared<HosBinderDriverServer>(system);
+ const auto surface_flinger = std::make_shared<Nvnflinger>(system, *binder_server);
+
+ auto server_manager = std::make_unique<ServerManager>(system);
+ server_manager->RegisterNamedService(
+ "dispdrv", std::make_shared<IHOSBinderDriver>(system, binder_server, surface_flinger));
+ ServerManager::RunServer(std::move(server_manager));
+}
+
} // namespace Service::Nvnflinger
diff --git a/src/core/hle/service/nvnflinger/nvnflinger.h b/src/core/hle/service/nvnflinger/nvnflinger.h
index 4cf4f069d..5ed7dc317 100644
--- a/src/core/hle/service/nvnflinger/nvnflinger.h
+++ b/src/core/hle/service/nvnflinger/nvnflinger.h
@@ -8,7 +8,6 @@
#include <mutex>
#include <optional>
#include <thread>
-#include <vector>
#include "common/common_types.h"
#include "common/polyfill_thread.h"
@@ -57,9 +56,6 @@ public:
void ShutdownLayers();
- /// Sets the NVDrv module instance to use to send buffers to the GPU.
- void SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance);
-
/// Opens the specified display and returns the ID.
///
/// If an invalid display name is provided, then an empty optional is returned.
@@ -169,4 +165,6 @@ private:
HosBinderDriverServer& hos_binder_driver_server;
};
+void LoopProcess(Core::System& system);
+
} // namespace Service::Nvnflinger