hle: nvflinger: Add implementation for HosBinderDriverServer service.
This commit is contained in:
parent
56284bff6c
commit
a87812c6a1
3 changed files with 75 additions and 0 deletions
|
@ -553,6 +553,8 @@ add_library(core STATIC
|
|||
hle/service/nvflinger/consumer_listener.h
|
||||
hle/service/nvflinger/graphic_buffer_producer.cpp
|
||||
hle/service/nvflinger/graphic_buffer_producer.h
|
||||
hle/service/nvflinger/hos_binder_driver_server.cpp
|
||||
hle/service/nvflinger/hos_binder_driver_server.h
|
||||
hle/service/nvflinger/nvflinger.cpp
|
||||
hle/service/nvflinger/nvflinger.h
|
||||
hle/service/nvflinger/parcel.h
|
||||
|
|
36
src/core/hle/service/nvflinger/hos_binder_driver_server.cpp
Normal file
36
src/core/hle/service/nvflinger/hos_binder_driver_server.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Copyright 2021 yuzu Emulator Project
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/nvflinger/hos_binder_driver_server.h"
|
||||
|
||||
namespace Service::NVFlinger {
|
||||
|
||||
HosBinderDriverServer::HosBinderDriverServer(Core::System& system_)
|
||||
: service_context(system_, "HosBinderDriverServer") {}
|
||||
|
||||
HosBinderDriverServer::~HosBinderDriverServer() {}
|
||||
|
||||
u64 HosBinderDriverServer::RegisterProducer(std::unique_ptr<android::IBinder>&& binder) {
|
||||
std::lock_guard lk{lock};
|
||||
|
||||
last_id++;
|
||||
|
||||
producers[last_id] = std::move(binder);
|
||||
|
||||
return last_id;
|
||||
}
|
||||
|
||||
android::IBinder* HosBinderDriverServer::TryGetProducer(u64 id) {
|
||||
std::lock_guard lk{lock};
|
||||
|
||||
if (auto search = producers.find(id); search != producers.end()) {
|
||||
return search->second.get();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace Service::NVFlinger
|
37
src/core/hle/service/nvflinger/hos_binder_driver_server.h
Normal file
37
src/core/hle/service/nvflinger/hos_binder_driver_server.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Copyright 2021 yuzu Emulator Project
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/kernel_helpers.h"
|
||||
#include "core/hle/service/nvflinger/binder.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::NVFlinger {
|
||||
|
||||
class HosBinderDriverServer final {
|
||||
public:
|
||||
explicit HosBinderDriverServer(Core::System& system_);
|
||||
~HosBinderDriverServer();
|
||||
|
||||
u64 RegisterProducer(std::unique_ptr<android::IBinder>&& binder);
|
||||
|
||||
android::IBinder* TryGetProducer(u64 id);
|
||||
|
||||
private:
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
|
||||
std::unordered_map<u64, std::unique_ptr<android::IBinder>> producers;
|
||||
std::mutex lock;
|
||||
u64 last_id{};
|
||||
};
|
||||
|
||||
} // namespace Service::NVFlinger
|
Loading…
Reference in a new issue