diff options
| author | 2021-11-11 19:13:21 -0800 | |
|---|---|---|
| committer | 2022-03-24 18:13:33 -0700 | |
| commit | a87812c6a12fbb4b48c0a890ae5a181402743f69 (patch) | |
| tree | abda8bca7463d8aaf7cd173f1c2fd8e96a855b6e /src | |
| parent | hle: nvflinger: Add implementation for BufferQueueProducer class. (diff) | |
| download | yuzu-a87812c6a12fbb4b48c0a890ae5a181402743f69.tar.gz yuzu-a87812c6a12fbb4b48c0a890ae5a181402743f69.tar.xz yuzu-a87812c6a12fbb4b48c0a890ae5a181402743f69.zip | |
hle: nvflinger: Add implementation for HosBinderDriverServer service.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/hos_binder_driver_server.cpp | 36 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/hos_binder_driver_server.h | 37 |
3 files changed, 75 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 669de3091..ff8adfc55 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -553,6 +553,8 @@ add_library(core STATIC | |||
| 553 | hle/service/nvflinger/consumer_listener.h | 553 | hle/service/nvflinger/consumer_listener.h |
| 554 | hle/service/nvflinger/graphic_buffer_producer.cpp | 554 | hle/service/nvflinger/graphic_buffer_producer.cpp |
| 555 | hle/service/nvflinger/graphic_buffer_producer.h | 555 | hle/service/nvflinger/graphic_buffer_producer.h |
| 556 | hle/service/nvflinger/hos_binder_driver_server.cpp | ||
| 557 | hle/service/nvflinger/hos_binder_driver_server.h | ||
| 556 | hle/service/nvflinger/nvflinger.cpp | 558 | hle/service/nvflinger/nvflinger.cpp |
| 557 | hle/service/nvflinger/nvflinger.h | 559 | hle/service/nvflinger/nvflinger.h |
| 558 | hle/service/nvflinger/parcel.h | 560 | hle/service/nvflinger/parcel.h |
diff --git a/src/core/hle/service/nvflinger/hos_binder_driver_server.cpp b/src/core/hle/service/nvflinger/hos_binder_driver_server.cpp new file mode 100644 index 000000000..0c937d682 --- /dev/null +++ b/src/core/hle/service/nvflinger/hos_binder_driver_server.cpp | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 2 | // Copyright 2021 yuzu Emulator Project | ||
| 3 | |||
| 4 | #include <mutex> | ||
| 5 | |||
| 6 | #include "common/common_types.h" | ||
| 7 | #include "core/hle/service/nvflinger/hos_binder_driver_server.h" | ||
| 8 | |||
| 9 | namespace Service::NVFlinger { | ||
| 10 | |||
| 11 | HosBinderDriverServer::HosBinderDriverServer(Core::System& system_) | ||
| 12 | : service_context(system_, "HosBinderDriverServer") {} | ||
| 13 | |||
| 14 | HosBinderDriverServer::~HosBinderDriverServer() {} | ||
| 15 | |||
| 16 | u64 HosBinderDriverServer::RegisterProducer(std::unique_ptr<android::IBinder>&& binder) { | ||
| 17 | std::lock_guard lk{lock}; | ||
| 18 | |||
| 19 | last_id++; | ||
| 20 | |||
| 21 | producers[last_id] = std::move(binder); | ||
| 22 | |||
| 23 | return last_id; | ||
| 24 | } | ||
| 25 | |||
| 26 | android::IBinder* HosBinderDriverServer::TryGetProducer(u64 id) { | ||
| 27 | std::lock_guard lk{lock}; | ||
| 28 | |||
| 29 | if (auto search = producers.find(id); search != producers.end()) { | ||
| 30 | return search->second.get(); | ||
| 31 | } | ||
| 32 | |||
| 33 | return {}; | ||
| 34 | } | ||
| 35 | |||
| 36 | } // namespace Service::NVFlinger | ||
diff --git a/src/core/hle/service/nvflinger/hos_binder_driver_server.h b/src/core/hle/service/nvflinger/hos_binder_driver_server.h new file mode 100644 index 000000000..cbca87fa0 --- /dev/null +++ b/src/core/hle/service/nvflinger/hos_binder_driver_server.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 2 | // Copyright 2021 yuzu Emulator Project | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <memory> | ||
| 7 | #include <mutex> | ||
| 8 | #include <unordered_map> | ||
| 9 | |||
| 10 | #include "common/common_types.h" | ||
| 11 | #include "core/hle/service/kernel_helpers.h" | ||
| 12 | #include "core/hle/service/nvflinger/binder.h" | ||
| 13 | |||
| 14 | namespace Core { | ||
| 15 | class System; | ||
| 16 | } | ||
| 17 | |||
| 18 | namespace Service::NVFlinger { | ||
| 19 | |||
| 20 | class HosBinderDriverServer final { | ||
| 21 | public: | ||
| 22 | explicit HosBinderDriverServer(Core::System& system_); | ||
| 23 | ~HosBinderDriverServer(); | ||
| 24 | |||
| 25 | u64 RegisterProducer(std::unique_ptr<android::IBinder>&& binder); | ||
| 26 | |||
| 27 | android::IBinder* TryGetProducer(u64 id); | ||
| 28 | |||
| 29 | private: | ||
| 30 | KernelHelpers::ServiceContext service_context; | ||
| 31 | |||
| 32 | std::unordered_map<u64, std::unique_ptr<android::IBinder>> producers; | ||
| 33 | std::mutex lock; | ||
| 34 | u64 last_id{}; | ||
| 35 | }; | ||
| 36 | |||
| 37 | } // namespace Service::NVFlinger | ||