vi: move shared buffer management from nvnflinger
This commit is contained in:
parent
ee8eccc5fa
commit
dcce9837d2
|
@ -798,8 +798,6 @@ add_library(core STATIC
|
||||||
hle/service/nvnflinger/consumer_base.cpp
|
hle/service/nvnflinger/consumer_base.cpp
|
||||||
hle/service/nvnflinger/consumer_base.h
|
hle/service/nvnflinger/consumer_base.h
|
||||||
hle/service/nvnflinger/consumer_listener.h
|
hle/service/nvnflinger/consumer_listener.h
|
||||||
hle/service/nvnflinger/fb_share_buffer_manager.cpp
|
|
||||||
hle/service/nvnflinger/fb_share_buffer_manager.h
|
|
||||||
hle/service/nvnflinger/graphic_buffer_producer.cpp
|
hle/service/nvnflinger/graphic_buffer_producer.cpp
|
||||||
hle/service/nvnflinger/graphic_buffer_producer.h
|
hle/service/nvnflinger/graphic_buffer_producer.h
|
||||||
hle/service/nvnflinger/hos_binder_driver_server.cpp
|
hle/service/nvnflinger/hos_binder_driver_server.cpp
|
||||||
|
@ -963,6 +961,8 @@ add_library(core STATIC
|
||||||
hle/service/vi/application_display_service.h
|
hle/service/vi/application_display_service.h
|
||||||
hle/service/vi/application_root_service.cpp
|
hle/service/vi/application_root_service.cpp
|
||||||
hle/service/vi/application_root_service.h
|
hle/service/vi/application_root_service.h
|
||||||
|
hle/service/vi/fbshare_buffer_manager.cpp
|
||||||
|
hle/service/vi/fbshare_buffer_manager.h
|
||||||
hle/service/vi/manager_display_service.cpp
|
hle/service/vi/manager_display_service.cpp
|
||||||
hle/service/vi/manager_display_service.h
|
hle/service/vi/manager_display_service.h
|
||||||
hle/service/vi/manager_root_service.cpp
|
hle/service/vi/manager_root_service.cpp
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
|
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/service/am/display_layer_manager.h"
|
#include "core/hle/service/am/display_layer_manager.h"
|
||||||
#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
|
|
||||||
#include "core/hle/service/nvnflinger/hos_binder_driver.h"
|
#include "core/hle/service/nvnflinger/hos_binder_driver.h"
|
||||||
#include "core/hle/service/nvnflinger/nvnflinger.h"
|
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
|
#include "core/hle/service/vi/application_display_service.h"
|
||||||
|
#include "core/hle/service/vi/fbshare_buffer_manager.h"
|
||||||
|
#include "core/hle/service/vi/manager_root_service.h"
|
||||||
#include "core/hle/service/vi/vi_results.h"
|
#include "core/hle/service/vi/vi_results.h"
|
||||||
|
#include "core/hle/service/vi/vi_types.h"
|
||||||
|
|
||||||
namespace Service::AM {
|
namespace Service::AM {
|
||||||
|
|
||||||
|
@ -18,10 +20,14 @@ DisplayLayerManager::~DisplayLayerManager() {
|
||||||
|
|
||||||
void DisplayLayerManager::Initialize(Core::System& system, Kernel::KProcess* process,
|
void DisplayLayerManager::Initialize(Core::System& system, Kernel::KProcess* process,
|
||||||
AppletId applet_id, LibraryAppletMode mode) {
|
AppletId applet_id, LibraryAppletMode mode) {
|
||||||
m_process = process;
|
|
||||||
m_surface_flinger = system.ServiceManager()
|
m_surface_flinger = system.ServiceManager()
|
||||||
.GetService<Nvnflinger::IHOSBinderDriver>("dispdrv", true)
|
.GetService<Nvnflinger::IHOSBinderDriver>("dispdrv", true)
|
||||||
->GetSurfaceFlinger();
|
->GetSurfaceFlinger();
|
||||||
|
R_ASSERT(system.ServiceManager()
|
||||||
|
.GetService<VI::IManagerRootService>("vi:m", true)
|
||||||
|
->GetDisplayService(&m_display_service, VI::Policy::Compositor));
|
||||||
|
|
||||||
|
m_process = process;
|
||||||
m_system_shared_buffer_id = 0;
|
m_system_shared_buffer_id = 0;
|
||||||
m_system_shared_layer_id = 0;
|
m_system_shared_layer_id = 0;
|
||||||
m_applet_id = applet_id;
|
m_applet_id = applet_id;
|
||||||
|
@ -46,7 +52,7 @@ void DisplayLayerManager::Finalize() {
|
||||||
|
|
||||||
// Clean up shared layers.
|
// Clean up shared layers.
|
||||||
if (m_buffer_sharing_enabled) {
|
if (m_buffer_sharing_enabled) {
|
||||||
m_surface_flinger->GetSystemBufferManager().Finalize(m_process);
|
m_display_service->GetSharedBufferManager()->Finalize(m_process);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_surface_flinger = nullptr;
|
m_surface_flinger = nullptr;
|
||||||
|
@ -103,7 +109,7 @@ Result DisplayLayerManager::IsSystemBufferSharingEnabled() {
|
||||||
const auto blend =
|
const auto blend =
|
||||||
m_blending_enabled ? Nvnflinger::LayerBlending::Coverage : Nvnflinger::LayerBlending::None;
|
m_blending_enabled ? Nvnflinger::LayerBlending::Coverage : Nvnflinger::LayerBlending::None;
|
||||||
const auto display_id = m_surface_flinger->OpenDisplay("Default").value();
|
const auto display_id = m_surface_flinger->OpenDisplay("Default").value();
|
||||||
R_TRY(m_surface_flinger->GetSystemBufferManager().Initialize(
|
R_TRY(m_display_service->GetSharedBufferManager()->Initialize(
|
||||||
m_process, &m_system_shared_buffer_id, &m_system_shared_layer_id, display_id, blend));
|
m_process, &m_system_shared_buffer_id, &m_system_shared_layer_id, display_id, blend));
|
||||||
|
|
||||||
// We succeeded, so set up remaining state.
|
// We succeeded, so set up remaining state.
|
||||||
|
@ -147,7 +153,7 @@ bool DisplayLayerManager::GetWindowVisibility() const {
|
||||||
Result DisplayLayerManager::WriteAppletCaptureBuffer(bool* out_was_written,
|
Result DisplayLayerManager::WriteAppletCaptureBuffer(bool* out_was_written,
|
||||||
s32* out_fbshare_layer_index) {
|
s32* out_fbshare_layer_index) {
|
||||||
R_UNLESS(m_buffer_sharing_enabled, VI::ResultPermissionDenied);
|
R_UNLESS(m_buffer_sharing_enabled, VI::ResultPermissionDenied);
|
||||||
R_RETURN(m_surface_flinger->GetSystemBufferManager().WriteAppletCaptureBuffer(
|
R_RETURN(m_display_service->GetSharedBufferManager()->WriteAppletCaptureBuffer(
|
||||||
out_was_written, out_fbshare_layer_index));
|
out_was_written, out_fbshare_layer_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,10 @@ namespace Service::Nvnflinger {
|
||||||
class Nvnflinger;
|
class Nvnflinger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Service::VI {
|
||||||
|
class IApplicationDisplayService;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Service::AM {
|
namespace Service::AM {
|
||||||
|
|
||||||
class DisplayLayerManager {
|
class DisplayLayerManager {
|
||||||
|
@ -47,6 +51,7 @@ public:
|
||||||
private:
|
private:
|
||||||
Kernel::KProcess* m_process{};
|
Kernel::KProcess* m_process{};
|
||||||
std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger{};
|
std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger{};
|
||||||
|
std::shared_ptr<VI::IApplicationDisplayService> m_display_service{};
|
||||||
std::set<u64> m_managed_display_layers{};
|
std::set<u64> m_managed_display_layers{};
|
||||||
std::set<u64> m_managed_display_recording_layers{};
|
std::set<u64> m_managed_display_recording_layers{};
|
||||||
u64 m_system_shared_buffer_id{};
|
u64 m_system_shared_buffer_id{};
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h"
|
#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h"
|
||||||
#include "core/hle/service/nvdrv/nvdrv.h"
|
#include "core/hle/service/nvdrv/nvdrv.h"
|
||||||
#include "core/hle/service/nvdrv/nvdrv_interface.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/hardware_composer.h"
|
||||||
#include "core/hle/service/nvnflinger/hos_binder_driver.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/hos_binder_driver_server.h"
|
||||||
|
@ -311,16 +310,6 @@ s64 Nvnflinger::GetNextTicks() const {
|
||||||
return static_cast<s64>(speed_scale * (1000000000.f / effective_fps));
|
return static_cast<s64>(speed_scale * (1000000000.f / effective_fps));
|
||||||
}
|
}
|
||||||
|
|
||||||
FbShareBufferManager& Nvnflinger::GetSystemBufferManager() {
|
|
||||||
const auto lock_guard = Lock();
|
|
||||||
|
|
||||||
if (!system_buffer_manager) {
|
|
||||||
system_buffer_manager = std::make_unique<FbShareBufferManager>(system, *this, nvdrv);
|
|
||||||
}
|
|
||||||
|
|
||||||
return *system_buffer_manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoopProcess(Core::System& system) {
|
void LoopProcess(Core::System& system) {
|
||||||
const auto binder_server = std::make_shared<HosBinderDriverServer>(system);
|
const auto binder_server = std::make_shared<HosBinderDriverServer>(system);
|
||||||
const auto surface_flinger = std::make_shared<Nvnflinger>(system, *binder_server);
|
const auto surface_flinger = std::make_shared<Nvnflinger>(system, *binder_server);
|
||||||
|
|
|
@ -35,6 +35,7 @@ class Module;
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
class Display;
|
class Display;
|
||||||
|
class FbshareBufferManager;
|
||||||
class Layer;
|
class Layer;
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
||||||
|
@ -45,7 +46,6 @@ class BufferQueueProducer;
|
||||||
|
|
||||||
namespace Service::Nvnflinger {
|
namespace Service::Nvnflinger {
|
||||||
|
|
||||||
class FbShareBufferManager;
|
|
||||||
class HardwareComposer;
|
class HardwareComposer;
|
||||||
class HosBinderDriverServer;
|
class HosBinderDriverServer;
|
||||||
|
|
||||||
|
@ -101,17 +101,9 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] s64 GetNextTicks() const;
|
[[nodiscard]] s64 GetNextTicks() const;
|
||||||
|
|
||||||
FbShareBufferManager& GetSystemBufferManager();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Layer {
|
friend class VI::FbshareBufferManager;
|
||||||
std::unique_ptr<android::BufferQueueCore> core;
|
|
||||||
std::unique_ptr<android::BufferQueueProducer> producer;
|
|
||||||
};
|
|
||||||
|
|
||||||
friend class FbShareBufferManager;
|
|
||||||
|
|
||||||
private:
|
|
||||||
[[nodiscard]] std::unique_lock<std::mutex> Lock() const {
|
[[nodiscard]] std::unique_lock<std::mutex> Lock() const {
|
||||||
return std::unique_lock{*guard};
|
return std::unique_lock{*guard};
|
||||||
}
|
}
|
||||||
|
@ -150,8 +142,6 @@ private:
|
||||||
std::shared_ptr<Core::Timing::EventType> multi_composition_event;
|
std::shared_ptr<Core::Timing::EventType> multi_composition_event;
|
||||||
std::shared_ptr<Core::Timing::EventType> single_composition_event;
|
std::shared_ptr<Core::Timing::EventType> single_composition_event;
|
||||||
|
|
||||||
std::unique_ptr<FbShareBufferManager> system_buffer_manager;
|
|
||||||
|
|
||||||
std::shared_ptr<std::mutex> guard;
|
std::shared_ptr<std::mutex> guard;
|
||||||
|
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
|
|
|
@ -13,10 +13,12 @@
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
IApplicationDisplayService::IApplicationDisplayService(
|
IApplicationDisplayService::IApplicationDisplayService(
|
||||||
Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service)
|
Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
||||||
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager)
|
||||||
: ServiceFramework{system_, "IApplicationDisplayService"},
|
: ServiceFramework{system_, "IApplicationDisplayService"},
|
||||||
m_binder_service{std::move(binder_service)},
|
m_binder_service{std::move(binder_service)},
|
||||||
m_surface_flinger{m_binder_service->GetSurfaceFlinger()} {
|
m_surface_flinger{m_binder_service->GetSurfaceFlinger()},
|
||||||
|
m_shared_buffer_manager{std::move(shared_buffer_manager)} {
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
|
@ -64,7 +66,7 @@ Result IApplicationDisplayService::GetSystemDisplayService(
|
||||||
Out<SharedPointer<ISystemDisplayService>> out_system_display_service) {
|
Out<SharedPointer<ISystemDisplayService>> out_system_display_service) {
|
||||||
LOG_WARNING(Service_VI, "(STUBBED) called");
|
LOG_WARNING(Service_VI, "(STUBBED) called");
|
||||||
*out_system_display_service =
|
*out_system_display_service =
|
||||||
std::make_shared<ISystemDisplayService>(system, m_surface_flinger);
|
std::make_shared<ISystemDisplayService>(system, m_surface_flinger, m_shared_buffer_manager);
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,15 +16,21 @@ class IHOSBinderDriver;
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
|
class FbshareBufferManager;
|
||||||
class IManagerDisplayService;
|
class IManagerDisplayService;
|
||||||
class ISystemDisplayService;
|
class ISystemDisplayService;
|
||||||
|
|
||||||
class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> {
|
class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> {
|
||||||
public:
|
public:
|
||||||
IApplicationDisplayService(Core::System& system_,
|
IApplicationDisplayService(Core::System& system_,
|
||||||
std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service);
|
std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
||||||
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager);
|
||||||
~IApplicationDisplayService() override;
|
~IApplicationDisplayService() override;
|
||||||
|
|
||||||
|
std::shared_ptr<FbshareBufferManager> GetSharedBufferManager() const {
|
||||||
|
return m_shared_buffer_manager;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Result GetRelayService(Out<SharedPointer<Nvnflinger::IHOSBinderDriver>> out_relay_service);
|
Result GetRelayService(Out<SharedPointer<Nvnflinger::IHOSBinderDriver>> out_relay_service);
|
||||||
Result GetSystemDisplayService(
|
Result GetSystemDisplayService(
|
||||||
|
@ -62,6 +68,7 @@ private:
|
||||||
private:
|
private:
|
||||||
const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
|
const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
|
||||||
const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger;
|
const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger;
|
||||||
|
const std::shared_ptr<FbshareBufferManager> m_shared_buffer_manager;
|
||||||
std::vector<u64> m_stray_layer_ids;
|
std::vector<u64> m_stray_layer_ids;
|
||||||
bool m_vsync_event_fetched{false};
|
bool m_vsync_event_fetched{false};
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,8 +11,10 @@
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
IApplicationRootService::IApplicationRootService(
|
IApplicationRootService::IApplicationRootService(
|
||||||
Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service)
|
Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
||||||
: ServiceFramework{system_, "vi:u"}, m_binder_service{std::move(binder_service)} {
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager)
|
||||||
|
: ServiceFramework{system_, "vi:u"}, m_binder_service{std::move(binder_service)},
|
||||||
|
m_shared_buffer_manager{std::move(shared_buffer_manager)} {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, C<&IApplicationRootService::GetDisplayService>, "GetDisplayService"},
|
{0, C<&IApplicationRootService::GetDisplayService>, "GetDisplayService"},
|
||||||
{1, nullptr, "GetDisplayServiceWithProxyNameExchange"},
|
{1, nullptr, "GetDisplayServiceWithProxyNameExchange"},
|
||||||
|
@ -26,7 +28,7 @@ Result IApplicationRootService::GetDisplayService(
|
||||||
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
|
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
|
||||||
LOG_DEBUG(Service_VI, "called");
|
LOG_DEBUG(Service_VI, "called");
|
||||||
R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service,
|
R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service,
|
||||||
Permission::User, policy));
|
m_shared_buffer_manager, Permission::User, policy));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
|
@ -16,13 +16,15 @@ class IHOSBinderDriver;
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
|
class FbshareBufferManager;
|
||||||
class IApplicationDisplayService;
|
class IApplicationDisplayService;
|
||||||
enum class Policy : u32;
|
enum class Policy : u32;
|
||||||
|
|
||||||
class IApplicationRootService final : public ServiceFramework<IApplicationRootService> {
|
class IApplicationRootService final : public ServiceFramework<IApplicationRootService> {
|
||||||
public:
|
public:
|
||||||
explicit IApplicationRootService(Core::System& system_,
|
explicit IApplicationRootService(Core::System& system_,
|
||||||
std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service);
|
std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
||||||
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager);
|
||||||
~IApplicationRootService() override;
|
~IApplicationRootService() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -32,6 +34,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
|
const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
|
||||||
|
const std::shared_ptr<FbshareBufferManager> m_shared_buffer_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
|
@ -9,15 +9,15 @@
|
||||||
#include "core/hle/service/nvdrv/devices/nvmap.h"
|
#include "core/hle/service/nvdrv/devices/nvmap.h"
|
||||||
#include "core/hle/service/nvdrv/nvdrv.h"
|
#include "core/hle/service/nvdrv/nvdrv.h"
|
||||||
#include "core/hle/service/nvnflinger/buffer_queue_producer.h"
|
#include "core/hle/service/nvnflinger/buffer_queue_producer.h"
|
||||||
#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
|
|
||||||
#include "core/hle/service/nvnflinger/pixel_format.h"
|
#include "core/hle/service/nvnflinger/pixel_format.h"
|
||||||
#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
|
#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
|
||||||
|
#include "core/hle/service/vi/fbshare_buffer_manager.h"
|
||||||
#include "core/hle/service/vi/layer/vi_layer.h"
|
#include "core/hle/service/vi/layer/vi_layer.h"
|
||||||
#include "core/hle/service/vi/vi_results.h"
|
#include "core/hle/service/vi/vi_results.h"
|
||||||
#include "video_core/gpu.h"
|
#include "video_core/gpu.h"
|
||||||
#include "video_core/host1x/host1x.h"
|
#include "video_core/host1x/host1x.h"
|
||||||
|
|
||||||
namespace Service::Nvnflinger {
|
namespace Service::VI {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ Result AllocateSharedBufferMemory(std::unique_ptr<Kernel::KPageGroup>* out_page_
|
||||||
using Core::Memory::YUZU_PAGESIZE;
|
using Core::Memory::YUZU_PAGESIZE;
|
||||||
|
|
||||||
// Allocate memory for the system shared buffer.
|
// Allocate memory for the system shared buffer.
|
||||||
// FIXME: This memory belongs to vi's .data section.
|
|
||||||
auto& kernel = system.Kernel();
|
auto& kernel = system.Kernel();
|
||||||
|
|
||||||
// Hold a temporary page group reference while we try to map it.
|
// Hold a temporary page group reference while we try to map it.
|
||||||
|
@ -204,15 +203,16 @@ void MakeGraphicBuffer(android::BufferQueueProducer& producer, u32 slot, u32 han
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
FbShareBufferManager::FbShareBufferManager(Core::System& system, Nvnflinger& flinger,
|
FbshareBufferManager::FbshareBufferManager(Core::System& system,
|
||||||
|
std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger,
|
||||||
std::shared_ptr<Nvidia::Module> nvdrv)
|
std::shared_ptr<Nvidia::Module> nvdrv)
|
||||||
: m_system(system), m_flinger(flinger), m_nvdrv(std::move(nvdrv)) {}
|
: m_system(system), m_surface_flinger(std::move(surface_flinger)), m_nvdrv(std::move(nvdrv)) {}
|
||||||
|
|
||||||
FbShareBufferManager::~FbShareBufferManager() = default;
|
FbshareBufferManager::~FbshareBufferManager() = default;
|
||||||
|
|
||||||
Result FbShareBufferManager::Initialize(Kernel::KProcess* owner_process, u64* out_buffer_id,
|
Result FbshareBufferManager::Initialize(Kernel::KProcess* owner_process, u64* out_buffer_id,
|
||||||
u64* out_layer_handle, u64 display_id,
|
u64* out_layer_handle, u64 display_id,
|
||||||
LayerBlending blending) {
|
Nvnflinger::LayerBlending blending) {
|
||||||
std::scoped_lock lk{m_guard};
|
std::scoped_lock lk{m_guard};
|
||||||
|
|
||||||
// Ensure we haven't already created.
|
// Ensure we haven't already created.
|
||||||
|
@ -237,7 +237,7 @@ Result FbShareBufferManager::Initialize(Kernel::KProcess* owner_process, u64* ou
|
||||||
owner_process, m_system));
|
owner_process, m_system));
|
||||||
|
|
||||||
// Create new session.
|
// Create new session.
|
||||||
auto [it, was_emplaced] = m_sessions.emplace(aruid, FbShareSession{});
|
auto [it, was_emplaced] = m_sessions.emplace(aruid, FbshareSession{});
|
||||||
auto& session = it->second;
|
auto& session = it->second;
|
||||||
|
|
||||||
auto& container = m_nvdrv->GetContainer();
|
auto& container = m_nvdrv->GetContainer();
|
||||||
|
@ -249,11 +249,11 @@ Result FbShareBufferManager::Initialize(Kernel::KProcess* owner_process, u64* ou
|
||||||
session.nvmap_fd, map_address, SharedBufferSize));
|
session.nvmap_fd, map_address, SharedBufferSize));
|
||||||
|
|
||||||
// Create and open a layer for the display.
|
// Create and open a layer for the display.
|
||||||
session.layer_id = m_flinger.CreateLayer(m_display_id, blending).value();
|
session.layer_id = m_surface_flinger->CreateLayer(m_display_id, blending).value();
|
||||||
m_flinger.OpenLayer(session.layer_id);
|
m_surface_flinger->OpenLayer(session.layer_id);
|
||||||
|
|
||||||
// Get the layer.
|
// Get the layer.
|
||||||
VI::Layer* layer = m_flinger.FindLayer(m_display_id, session.layer_id);
|
VI::Layer* layer = m_surface_flinger->FindLayer(m_display_id, session.layer_id);
|
||||||
ASSERT(layer != nullptr);
|
ASSERT(layer != nullptr);
|
||||||
|
|
||||||
// Get the producer and set preallocated buffers.
|
// Get the producer and set preallocated buffers.
|
||||||
|
@ -269,7 +269,7 @@ Result FbShareBufferManager::Initialize(Kernel::KProcess* owner_process, u64* ou
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FbShareBufferManager::Finalize(Kernel::KProcess* owner_process) {
|
void FbshareBufferManager::Finalize(Kernel::KProcess* owner_process) {
|
||||||
std::scoped_lock lk{m_guard};
|
std::scoped_lock lk{m_guard};
|
||||||
|
|
||||||
if (m_buffer_id == 0) {
|
if (m_buffer_id == 0) {
|
||||||
|
@ -285,7 +285,7 @@ void FbShareBufferManager::Finalize(Kernel::KProcess* owner_process) {
|
||||||
auto& session = it->second;
|
auto& session = it->second;
|
||||||
|
|
||||||
// Destroy the layer.
|
// Destroy the layer.
|
||||||
m_flinger.DestroyLayer(session.layer_id);
|
m_surface_flinger->DestroyLayer(session.layer_id);
|
||||||
|
|
||||||
// Close nvmap handle.
|
// Close nvmap handle.
|
||||||
FreeHandle(session.buffer_nvmap_handle, *m_nvdrv, session.nvmap_fd);
|
FreeHandle(session.buffer_nvmap_handle, *m_nvdrv, session.nvmap_fd);
|
||||||
|
@ -301,7 +301,7 @@ void FbShareBufferManager::Finalize(Kernel::KProcess* owner_process) {
|
||||||
m_sessions.erase(it);
|
m_sessions.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FbShareBufferManager::GetSharedBufferMemoryHandleId(u64* out_buffer_size,
|
Result FbshareBufferManager::GetSharedBufferMemoryHandleId(u64* out_buffer_size,
|
||||||
s32* out_nvmap_handle,
|
s32* out_nvmap_handle,
|
||||||
SharedMemoryPoolLayout* out_pool_layout,
|
SharedMemoryPoolLayout* out_pool_layout,
|
||||||
u64 buffer_id,
|
u64 buffer_id,
|
||||||
|
@ -319,12 +319,12 @@ Result FbShareBufferManager::GetSharedBufferMemoryHandleId(u64* out_buffer_size,
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FbShareBufferManager::GetLayerFromId(VI::Layer** out_layer, u64 layer_id) {
|
Result FbshareBufferManager::GetLayerFromId(VI::Layer** out_layer, u64 layer_id) {
|
||||||
// Ensure the layer id is valid.
|
// Ensure the layer id is valid.
|
||||||
R_UNLESS(layer_id > 0, VI::ResultNotFound);
|
R_UNLESS(layer_id > 0, VI::ResultNotFound);
|
||||||
|
|
||||||
// Get the layer.
|
// Get the layer.
|
||||||
VI::Layer* layer = m_flinger.FindLayer(m_display_id, layer_id);
|
VI::Layer* layer = m_surface_flinger->FindLayer(m_display_id, layer_id);
|
||||||
R_UNLESS(layer != nullptr, VI::ResultNotFound);
|
R_UNLESS(layer != nullptr, VI::ResultNotFound);
|
||||||
|
|
||||||
// We succeeded.
|
// We succeeded.
|
||||||
|
@ -332,7 +332,7 @@ Result FbShareBufferManager::GetLayerFromId(VI::Layer** out_layer, u64 layer_id)
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FbShareBufferManager::AcquireSharedFrameBuffer(android::Fence* out_fence,
|
Result FbshareBufferManager::AcquireSharedFrameBuffer(android::Fence* out_fence,
|
||||||
std::array<s32, 4>& out_slot_indexes,
|
std::array<s32, 4>& out_slot_indexes,
|
||||||
s64* out_target_slot, u64 layer_id) {
|
s64* out_target_slot, u64 layer_id) {
|
||||||
std::scoped_lock lk{m_guard};
|
std::scoped_lock lk{m_guard};
|
||||||
|
@ -359,7 +359,7 @@ Result FbShareBufferManager::AcquireSharedFrameBuffer(android::Fence* out_fence,
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FbShareBufferManager::PresentSharedFrameBuffer(android::Fence fence,
|
Result FbshareBufferManager::PresentSharedFrameBuffer(android::Fence fence,
|
||||||
Common::Rectangle<s32> crop_region,
|
Common::Rectangle<s32> crop_region,
|
||||||
u32 transform, s32 swap_interval,
|
u32 transform, s32 swap_interval,
|
||||||
u64 layer_id, s64 slot) {
|
u64 layer_id, s64 slot) {
|
||||||
|
@ -397,7 +397,7 @@ Result FbShareBufferManager::PresentSharedFrameBuffer(android::Fence fence,
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FbShareBufferManager::GetSharedFrameBufferAcquirableEvent(Kernel::KReadableEvent** out_event,
|
Result FbshareBufferManager::GetSharedFrameBufferAcquirableEvent(Kernel::KReadableEvent** out_event,
|
||||||
u64 layer_id) {
|
u64 layer_id) {
|
||||||
std::scoped_lock lk{m_guard};
|
std::scoped_lock lk{m_guard};
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ Result FbShareBufferManager::GetSharedFrameBufferAcquirableEvent(Kernel::KReadab
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FbShareBufferManager::WriteAppletCaptureBuffer(bool* out_was_written, s32* out_layer_index) {
|
Result FbshareBufferManager::WriteAppletCaptureBuffer(bool* out_was_written, s32* out_layer_index) {
|
||||||
std::vector<u8> capture_buffer(m_system.GPU().GetAppletCaptureBuffer());
|
std::vector<u8> capture_buffer(m_system.GPU().GetAppletCaptureBuffer());
|
||||||
Common::ScratchBuffer<u32> scratch;
|
Common::ScratchBuffer<u32> scratch;
|
||||||
|
|
||||||
|
@ -444,4 +444,4 @@ Result FbShareBufferManager::WriteAppletCaptureBuffer(bool* out_was_written, s32
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::Nvnflinger
|
} // namespace Service::VI
|
|
@ -16,7 +16,7 @@ namespace Kernel {
|
||||||
class KPageGroup;
|
class KPageGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Service::Nvnflinger {
|
namespace Service::VI {
|
||||||
|
|
||||||
struct SharedMemorySlot {
|
struct SharedMemorySlot {
|
||||||
u64 buffer_offset;
|
u64 buffer_offset;
|
||||||
|
@ -32,16 +32,17 @@ struct SharedMemoryPoolLayout {
|
||||||
};
|
};
|
||||||
static_assert(sizeof(SharedMemoryPoolLayout) == 0x188, "SharedMemoryPoolLayout has wrong size");
|
static_assert(sizeof(SharedMemoryPoolLayout) == 0x188, "SharedMemoryPoolLayout has wrong size");
|
||||||
|
|
||||||
struct FbShareSession;
|
struct FbshareSession;
|
||||||
|
|
||||||
class FbShareBufferManager final {
|
class FbshareBufferManager final {
|
||||||
public:
|
public:
|
||||||
explicit FbShareBufferManager(Core::System& system, Nvnflinger& flinger,
|
explicit FbshareBufferManager(Core::System& system,
|
||||||
|
std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger,
|
||||||
std::shared_ptr<Nvidia::Module> nvdrv);
|
std::shared_ptr<Nvidia::Module> nvdrv);
|
||||||
~FbShareBufferManager();
|
~FbshareBufferManager();
|
||||||
|
|
||||||
Result Initialize(Kernel::KProcess* owner_process, u64* out_buffer_id, u64* out_layer_handle,
|
Result Initialize(Kernel::KProcess* owner_process, u64* out_buffer_id, u64* out_layer_handle,
|
||||||
u64 display_id, LayerBlending blending);
|
u64 display_id, Nvnflinger::LayerBlending blending);
|
||||||
void Finalize(Kernel::KProcess* owner_process);
|
void Finalize(Kernel::KProcess* owner_process);
|
||||||
|
|
||||||
Result GetSharedBufferMemoryHandleId(u64* out_buffer_size, s32* out_nvmap_handle,
|
Result GetSharedBufferMemoryHandleId(u64* out_buffer_size, s32* out_nvmap_handle,
|
||||||
|
@ -63,20 +64,20 @@ private:
|
||||||
u64 m_display_id = 0;
|
u64 m_display_id = 0;
|
||||||
u64 m_buffer_id = 0;
|
u64 m_buffer_id = 0;
|
||||||
SharedMemoryPoolLayout m_pool_layout = {};
|
SharedMemoryPoolLayout m_pool_layout = {};
|
||||||
std::map<u64, FbShareSession> m_sessions;
|
std::map<u64, FbshareSession> m_sessions;
|
||||||
std::unique_ptr<Kernel::KPageGroup> m_buffer_page_group;
|
std::unique_ptr<Kernel::KPageGroup> m_buffer_page_group;
|
||||||
|
|
||||||
std::mutex m_guard;
|
std::mutex m_guard;
|
||||||
Core::System& m_system;
|
Core::System& m_system;
|
||||||
Nvnflinger& m_flinger;
|
const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger;
|
||||||
std::shared_ptr<Nvidia::Module> m_nvdrv;
|
const std::shared_ptr<Nvidia::Module> m_nvdrv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FbShareSession {
|
struct FbshareSession {
|
||||||
Nvidia::DeviceFD nvmap_fd = {};
|
Nvidia::DeviceFD nvmap_fd = {};
|
||||||
Nvidia::NvCore::SessionId session_id = {};
|
Nvidia::NvCore::SessionId session_id = {};
|
||||||
u64 layer_id = {};
|
u64 layer_id = {};
|
||||||
u32 buffer_nvmap_handle = 0;
|
u32 buffer_nvmap_handle = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::Nvnflinger
|
} // namespace Service::VI
|
|
@ -2,6 +2,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "core/hle/service/cmif_serialization.h"
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
|
#include "core/hle/service/nvnflinger/hos_binder_driver.h"
|
||||||
#include "core/hle/service/vi/application_display_service.h"
|
#include "core/hle/service/vi/application_display_service.h"
|
||||||
#include "core/hle/service/vi/manager_root_service.h"
|
#include "core/hle/service/vi/manager_root_service.h"
|
||||||
#include "core/hle/service/vi/service_creator.h"
|
#include "core/hle/service/vi/service_creator.h"
|
||||||
|
@ -11,8 +12,10 @@
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
IManagerRootService::IManagerRootService(
|
IManagerRootService::IManagerRootService(
|
||||||
Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service)
|
Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
||||||
: ServiceFramework{system_, "vi:m"}, m_binder_service{std::move(binder_service)} {
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager)
|
||||||
|
: ServiceFramework{system_, "vi:m"}, m_binder_service{std::move(binder_service)},
|
||||||
|
m_shared_buffer_manager{std::move(shared_buffer_manager)} {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{2, C<&IManagerRootService::GetDisplayService>, "GetDisplayService"},
|
{2, C<&IManagerRootService::GetDisplayService>, "GetDisplayService"},
|
||||||
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
|
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
|
||||||
|
@ -30,7 +33,7 @@ Result IManagerRootService::GetDisplayService(
|
||||||
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
|
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
|
||||||
LOG_DEBUG(Service_VI, "called");
|
LOG_DEBUG(Service_VI, "called");
|
||||||
R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service,
|
R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service,
|
||||||
Permission::Manager, policy));
|
m_shared_buffer_manager, Permission::Manager, policy));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
|
@ -16,21 +16,24 @@ class IHOSBinderDriver;
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
|
class FbshareBufferManager;
|
||||||
class IApplicationDisplayService;
|
class IApplicationDisplayService;
|
||||||
enum class Policy : u32;
|
enum class Policy : u32;
|
||||||
|
|
||||||
class IManagerRootService final : public ServiceFramework<IManagerRootService> {
|
class IManagerRootService final : public ServiceFramework<IManagerRootService> {
|
||||||
public:
|
public:
|
||||||
explicit IManagerRootService(Core::System& system_,
|
explicit IManagerRootService(Core::System& system_,
|
||||||
std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service);
|
std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
||||||
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager);
|
||||||
~IManagerRootService() override;
|
~IManagerRootService() override;
|
||||||
|
|
||||||
private:
|
|
||||||
Result GetDisplayService(
|
Result GetDisplayService(
|
||||||
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service,
|
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service,
|
||||||
Policy policy);
|
Policy policy);
|
||||||
|
|
||||||
|
private:
|
||||||
const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
|
const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
|
||||||
|
const std::shared_ptr<FbshareBufferManager> m_shared_buffer_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
|
@ -23,7 +23,8 @@ static bool IsValidServiceAccess(Permission permission, Policy policy) {
|
||||||
Result GetApplicationDisplayService(
|
Result GetApplicationDisplayService(
|
||||||
std::shared_ptr<IApplicationDisplayService>* out_application_display_service,
|
std::shared_ptr<IApplicationDisplayService>* out_application_display_service,
|
||||||
Core::System& system, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
Core::System& system, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
||||||
Permission permission, Policy policy) {
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager, Permission permission,
|
||||||
|
Policy policy) {
|
||||||
|
|
||||||
if (!IsValidServiceAccess(permission, policy)) {
|
if (!IsValidServiceAccess(permission, policy)) {
|
||||||
LOG_ERROR(Service_VI, "Permission denied for policy {}", policy);
|
LOG_ERROR(Service_VI, "Permission denied for policy {}", policy);
|
||||||
|
@ -31,7 +32,7 @@ Result GetApplicationDisplayService(
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_application_display_service =
|
*out_application_display_service =
|
||||||
std::make_shared<IApplicationDisplayService>(system, binder_service);
|
std::make_shared<IApplicationDisplayService>(system, binder_service, shared_buffer_manager);
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ union Result;
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
|
class FbshareBufferManager;
|
||||||
class IApplicationDisplayService;
|
class IApplicationDisplayService;
|
||||||
enum class Permission;
|
enum class Permission;
|
||||||
enum class Policy : u32;
|
enum class Policy : u32;
|
||||||
|
@ -26,6 +27,7 @@ enum class Policy : u32;
|
||||||
Result GetApplicationDisplayService(
|
Result GetApplicationDisplayService(
|
||||||
std::shared_ptr<IApplicationDisplayService>* out_application_display_service,
|
std::shared_ptr<IApplicationDisplayService>* out_application_display_service,
|
||||||
Core::System& system, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
Core::System& system, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
||||||
Permission permission, Policy policy);
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager, Permission permission,
|
||||||
|
Policy policy);
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
|
@ -3,16 +3,17 @@
|
||||||
|
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "core/hle/service/cmif_serialization.h"
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
|
|
||||||
#include "core/hle/service/vi/system_display_service.h"
|
#include "core/hle/service/vi/system_display_service.h"
|
||||||
#include "core/hle/service/vi/vi_types.h"
|
#include "core/hle/service/vi/vi_types.h"
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
ISystemDisplayService::ISystemDisplayService(
|
ISystemDisplayService::ISystemDisplayService(
|
||||||
Core::System& system_, std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger)
|
Core::System& system_, std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger,
|
||||||
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager)
|
||||||
: ServiceFramework{system_, "ISystemDisplayService"},
|
: ServiceFramework{system_, "ISystemDisplayService"},
|
||||||
m_surface_flinger{std::move(surface_flinger)} {
|
m_surface_flinger{std::move(surface_flinger)},
|
||||||
|
m_shared_buffer_manager{std::move(shared_buffer_manager)} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{1200, nullptr, "GetZOrderCountMin"},
|
{1200, nullptr, "GetZOrderCountMin"},
|
||||||
|
@ -101,11 +102,11 @@ Result ISystemDisplayService::GetDisplayMode(Out<u32> out_width, Out<u32> out_he
|
||||||
|
|
||||||
Result ISystemDisplayService::GetSharedBufferMemoryHandleId(
|
Result ISystemDisplayService::GetSharedBufferMemoryHandleId(
|
||||||
Out<s32> out_nvmap_handle, Out<u64> out_size,
|
Out<s32> out_nvmap_handle, Out<u64> out_size,
|
||||||
OutLargeData<Nvnflinger::SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout,
|
OutLargeData<SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout, u64 buffer_id,
|
||||||
u64 buffer_id, ClientAppletResourceUserId aruid) {
|
ClientAppletResourceUserId aruid) {
|
||||||
LOG_INFO(Service_VI, "called. buffer_id={}, aruid={:#x}", buffer_id, aruid.pid);
|
LOG_INFO(Service_VI, "called. buffer_id={}, aruid={:#x}", buffer_id, aruid.pid);
|
||||||
|
|
||||||
R_RETURN(m_surface_flinger->GetSystemBufferManager().GetSharedBufferMemoryHandleId(
|
R_RETURN(m_shared_buffer_manager->GetSharedBufferMemoryHandleId(
|
||||||
out_size, out_nvmap_handle, out_pool_layout, buffer_id, aruid.pid));
|
out_size, out_nvmap_handle, out_pool_layout, buffer_id, aruid.pid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,8 +124,8 @@ Result ISystemDisplayService::AcquireSharedFrameBuffer(Out<android::Fence> out_f
|
||||||
Out<std::array<s32, 4>> out_slots,
|
Out<std::array<s32, 4>> out_slots,
|
||||||
Out<s64> out_target_slot, u64 layer_id) {
|
Out<s64> out_target_slot, u64 layer_id) {
|
||||||
LOG_DEBUG(Service_VI, "called");
|
LOG_DEBUG(Service_VI, "called");
|
||||||
R_RETURN(m_surface_flinger->GetSystemBufferManager().AcquireSharedFrameBuffer(
|
R_RETURN(m_shared_buffer_manager->AcquireSharedFrameBuffer(out_fence, *out_slots,
|
||||||
out_fence, *out_slots, out_target_slot, layer_id));
|
out_target_slot, layer_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ISystemDisplayService::PresentSharedFrameBuffer(android::Fence fence,
|
Result ISystemDisplayService::PresentSharedFrameBuffer(android::Fence fence,
|
||||||
|
@ -132,15 +133,14 @@ Result ISystemDisplayService::PresentSharedFrameBuffer(android::Fence fence,
|
||||||
u32 window_transform, s32 swap_interval,
|
u32 window_transform, s32 swap_interval,
|
||||||
u64 layer_id, s64 surface_id) {
|
u64 layer_id, s64 surface_id) {
|
||||||
LOG_DEBUG(Service_VI, "called");
|
LOG_DEBUG(Service_VI, "called");
|
||||||
R_RETURN(m_surface_flinger->GetSystemBufferManager().PresentSharedFrameBuffer(
|
R_RETURN(m_shared_buffer_manager->PresentSharedFrameBuffer(
|
||||||
fence, crop_region, window_transform, swap_interval, layer_id, surface_id));
|
fence, crop_region, window_transform, swap_interval, layer_id, surface_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ISystemDisplayService::GetSharedFrameBufferAcquirableEvent(
|
Result ISystemDisplayService::GetSharedFrameBufferAcquirableEvent(
|
||||||
OutCopyHandle<Kernel::KReadableEvent> out_event, u64 layer_id) {
|
OutCopyHandle<Kernel::KReadableEvent> out_event, u64 layer_id) {
|
||||||
LOG_DEBUG(Service_VI, "called");
|
LOG_DEBUG(Service_VI, "called");
|
||||||
R_RETURN(m_surface_flinger->GetSystemBufferManager().GetSharedFrameBufferAcquirableEvent(
|
R_RETURN(m_shared_buffer_manager->GetSharedFrameBufferAcquirableEvent(out_event, layer_id));
|
||||||
out_event, layer_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
|
@ -5,18 +5,21 @@
|
||||||
#include "core/hle/service/cmif_types.h"
|
#include "core/hle/service/cmif_types.h"
|
||||||
#include "core/hle/service/nvnflinger/ui/fence.h"
|
#include "core/hle/service/nvnflinger/ui/fence.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
#include "core/hle/service/vi/fbshare_buffer_manager.h"
|
||||||
|
|
||||||
namespace Service::Nvnflinger {
|
namespace Service::Nvnflinger {
|
||||||
class Nvnflinger;
|
class Nvnflinger;
|
||||||
struct SharedMemoryPoolLayout;
|
|
||||||
} // namespace Service::Nvnflinger
|
} // namespace Service::Nvnflinger
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
|
class FbshareBufferManager;
|
||||||
|
|
||||||
class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> {
|
class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> {
|
||||||
public:
|
public:
|
||||||
explicit ISystemDisplayService(Core::System& system_,
|
explicit ISystemDisplayService(Core::System& system_,
|
||||||
std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger);
|
std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger,
|
||||||
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager);
|
||||||
~ISystemDisplayService() override;
|
~ISystemDisplayService() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -27,7 +30,7 @@ private:
|
||||||
|
|
||||||
Result GetSharedBufferMemoryHandleId(
|
Result GetSharedBufferMemoryHandleId(
|
||||||
Out<s32> out_nvmap_handle, Out<u64> out_size,
|
Out<s32> out_nvmap_handle, Out<u64> out_size,
|
||||||
OutLargeData<Nvnflinger::SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout,
|
OutLargeData<SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout,
|
||||||
u64 buffer_id, ClientAppletResourceUserId aruid);
|
u64 buffer_id, ClientAppletResourceUserId aruid);
|
||||||
Result OpenSharedLayer(u64 layer_id);
|
Result OpenSharedLayer(u64 layer_id);
|
||||||
Result ConnectSharedLayer(u64 layer_id);
|
Result ConnectSharedLayer(u64 layer_id);
|
||||||
|
@ -42,6 +45,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger;
|
const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger;
|
||||||
|
const std::shared_ptr<FbshareBufferManager> m_shared_buffer_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
|
@ -11,8 +11,10 @@
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
ISystemRootService::ISystemRootService(Core::System& system_,
|
ISystemRootService::ISystemRootService(Core::System& system_,
|
||||||
std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service)
|
std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
||||||
: ServiceFramework{system_, "vi:s"}, m_binder_service{std::move(binder_service)} {
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager)
|
||||||
|
: ServiceFramework{system_, "vi:s"}, m_binder_service{std::move(binder_service)},
|
||||||
|
m_shared_buffer_manager{std::move(shared_buffer_manager)} {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{1, C<&ISystemRootService::GetDisplayService>, "GetDisplayService"},
|
{1, C<&ISystemRootService::GetDisplayService>, "GetDisplayService"},
|
||||||
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
|
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
|
||||||
|
@ -26,7 +28,7 @@ Result ISystemRootService::GetDisplayService(
|
||||||
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
|
Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) {
|
||||||
LOG_DEBUG(Service_VI, "called");
|
LOG_DEBUG(Service_VI, "called");
|
||||||
R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service,
|
R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service,
|
||||||
Permission::System, policy));
|
m_shared_buffer_manager, Permission::System, policy));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
|
@ -16,13 +16,15 @@ class IHOSBinderDriver;
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
|
class FbshareBufferManager;
|
||||||
class IApplicationDisplayService;
|
class IApplicationDisplayService;
|
||||||
enum class Policy : u32;
|
enum class Policy : u32;
|
||||||
|
|
||||||
class ISystemRootService final : public ServiceFramework<ISystemRootService> {
|
class ISystemRootService final : public ServiceFramework<ISystemRootService> {
|
||||||
public:
|
public:
|
||||||
explicit ISystemRootService(Core::System& system_,
|
explicit ISystemRootService(Core::System& system_,
|
||||||
std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service);
|
std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service,
|
||||||
|
std::shared_ptr<FbshareBufferManager> shared_buffer_manager);
|
||||||
~ISystemRootService() override;
|
~ISystemRootService() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -31,6 +33,7 @@ private:
|
||||||
Policy policy);
|
Policy policy);
|
||||||
|
|
||||||
const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
|
const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service;
|
||||||
|
const std::shared_ptr<FbshareBufferManager> m_shared_buffer_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
|
#include "core/hle/service/nvdrv/nvdrv_interface.h"
|
||||||
#include "core/hle/service/nvnflinger/hos_binder_driver.h"
|
#include "core/hle/service/nvnflinger/hos_binder_driver.h"
|
||||||
#include "core/hle/service/server_manager.h"
|
#include "core/hle/service/server_manager.h"
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
#include "core/hle/service/vi/application_display_service.h"
|
#include "core/hle/service/vi/application_display_service.h"
|
||||||
#include "core/hle/service/vi/application_root_service.h"
|
#include "core/hle/service/vi/application_root_service.h"
|
||||||
|
#include "core/hle/service/vi/fbshare_buffer_manager.h"
|
||||||
#include "core/hle/service/vi/manager_root_service.h"
|
#include "core/hle/service/vi/manager_root_service.h"
|
||||||
#include "core/hle/service/vi/system_root_service.h"
|
#include "core/hle/service/vi/system_root_service.h"
|
||||||
#include "core/hle/service/vi/vi.h"
|
#include "core/hle/service/vi/vi.h"
|
||||||
|
@ -16,14 +18,22 @@ namespace Service::VI {
|
||||||
void LoopProcess(Core::System& system) {
|
void LoopProcess(Core::System& system) {
|
||||||
const auto binder_service =
|
const auto binder_service =
|
||||||
system.ServiceManager().GetService<Nvnflinger::IHOSBinderDriver>("dispdrv", true);
|
system.ServiceManager().GetService<Nvnflinger::IHOSBinderDriver>("dispdrv", true);
|
||||||
|
const auto nvdrv =
|
||||||
|
system.ServiceManager().GetService<Nvidia::NVDRV>("nvdrv:s", true)->GetModule();
|
||||||
|
const auto shared_buffer_manager =
|
||||||
|
std::make_shared<FbshareBufferManager>(system, binder_service->GetSurfaceFlinger(), nvdrv);
|
||||||
|
|
||||||
auto server_manager = std::make_unique<ServerManager>(system);
|
auto server_manager = std::make_unique<ServerManager>(system);
|
||||||
|
|
||||||
server_manager->RegisterNamedService(
|
server_manager->RegisterNamedService(
|
||||||
"vi:m", std::make_shared<IManagerRootService>(system, binder_service));
|
"vi:m",
|
||||||
|
std::make_shared<IManagerRootService>(system, binder_service, shared_buffer_manager));
|
||||||
server_manager->RegisterNamedService(
|
server_manager->RegisterNamedService(
|
||||||
"vi:s", std::make_shared<ISystemRootService>(system, binder_service));
|
"vi:s",
|
||||||
|
std::make_shared<ISystemRootService>(system, binder_service, shared_buffer_manager));
|
||||||
server_manager->RegisterNamedService(
|
server_manager->RegisterNamedService(
|
||||||
"vi:u", std::make_shared<IApplicationRootService>(system, binder_service));
|
"vi:u",
|
||||||
|
std::make_shared<IApplicationRootService>(system, binder_service, shared_buffer_manager));
|
||||||
ServerManager::RunServer(std::move(server_manager));
|
ServerManager::RunServer(std::move(server_manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue