diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.cpp | 81 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.h | 27 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/service.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/vi/display/vi_display.cpp | 50 | ||||
| -rw-r--r-- | src/core/hle/service/vi/display/vi_display.h | 29 | ||||
| -rw-r--r-- | src/core/hle/service/vi/layer/vi_layer.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/vi/layer/vi_layer.h | 57 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi.cpp | 690 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi.h | 10 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi_m.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi_m.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi_s.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi_s.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi_u.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi_u.h | 7 |
16 files changed, 285 insertions, 723 deletions
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 01e69de30..e21dc902a 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Licensed under GPLv2 or any later version | 2 | // Copyright 2021 yuzu Emulator Project |
| 3 | // Refer to the license.txt file included. | ||
| 4 | 3 | ||
| 5 | #include <algorithm> | 4 | #include <algorithm> |
| 6 | #include <optional> | 5 | #include <optional> |
| @@ -16,8 +15,11 @@ | |||
| 16 | #include "core/hle/kernel/k_readable_event.h" | 15 | #include "core/hle/kernel/k_readable_event.h" |
| 17 | #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" | 16 | #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" |
| 18 | #include "core/hle/service/nvdrv/nvdrv.h" | 17 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 19 | #include "core/hle/service/nvflinger/buffer_queue.h" | 18 | #include "core/hle/service/nvflinger/buffer_item_consumer.h" |
| 19 | #include "core/hle/service/nvflinger/buffer_queue_core.h" | ||
| 20 | #include "core/hle/service/nvflinger/hos_binder_driver_server.h" | ||
| 20 | #include "core/hle/service/nvflinger/nvflinger.h" | 21 | #include "core/hle/service/nvflinger/nvflinger.h" |
| 22 | #include "core/hle/service/nvflinger/ui/graphic_buffer.h" | ||
| 21 | #include "core/hle/service/vi/display/vi_display.h" | 23 | #include "core/hle/service/vi/display/vi_display.h" |
| 22 | #include "core/hle/service/vi/layer/vi_layer.h" | 24 | #include "core/hle/service/vi/layer/vi_layer.h" |
| 23 | #include "video_core/gpu.h" | 25 | #include "video_core/gpu.h" |
| @@ -53,13 +55,14 @@ void NVFlinger::SplitVSync(std::stop_token stop_token) { | |||
| 53 | } | 55 | } |
| 54 | } | 56 | } |
| 55 | 57 | ||
| 56 | NVFlinger::NVFlinger(Core::System& system_) | 58 | NVFlinger::NVFlinger(Core::System& system_, HosBinderDriverServer& hos_binder_driver_server_) |
| 57 | : system(system_), service_context(system_, "nvflinger") { | 59 | : system(system_), service_context(system_, "nvflinger"), |
| 58 | displays.emplace_back(0, "Default", service_context, system); | 60 | hos_binder_driver_server(hos_binder_driver_server_) { |
| 59 | displays.emplace_back(1, "External", service_context, system); | 61 | displays.emplace_back(0, "Default", hos_binder_driver_server, service_context, system); |
| 60 | displays.emplace_back(2, "Edid", service_context, system); | 62 | displays.emplace_back(1, "External", hos_binder_driver_server, service_context, system); |
| 61 | displays.emplace_back(3, "Internal", service_context, system); | 63 | displays.emplace_back(2, "Edid", hos_binder_driver_server, service_context, system); |
| 62 | displays.emplace_back(4, "Null", service_context, system); | 64 | displays.emplace_back(3, "Internal", hos_binder_driver_server, service_context, system); |
| 65 | displays.emplace_back(4, "Null", hos_binder_driver_server, service_context, system); | ||
| 63 | guard = std::make_shared<std::mutex>(); | 66 | guard = std::make_shared<std::mutex>(); |
| 64 | 67 | ||
| 65 | // Schedule the screen composition events | 68 | // Schedule the screen composition events |
| @@ -83,12 +86,15 @@ NVFlinger::NVFlinger(Core::System& system_) | |||
| 83 | } | 86 | } |
| 84 | 87 | ||
| 85 | NVFlinger::~NVFlinger() { | 88 | NVFlinger::~NVFlinger() { |
| 86 | for (auto& buffer_queue : buffer_queues) { | ||
| 87 | buffer_queue->Disconnect(); | ||
| 88 | } | ||
| 89 | if (!system.IsMulticore()) { | 89 | if (!system.IsMulticore()) { |
| 90 | system.CoreTiming().UnscheduleEvent(composition_event, 0); | 90 | system.CoreTiming().UnscheduleEvent(composition_event, 0); |
| 91 | } | 91 | } |
| 92 | |||
| 93 | for (auto& display : displays) { | ||
| 94 | for (size_t layer = 0; layer < display.GetNumLayers(); ++layer) { | ||
| 95 | display.GetLayer(layer).Core().NotifyShutdown(); | ||
| 96 | } | ||
| 97 | } | ||
| 92 | } | 98 | } |
| 93 | 99 | ||
| 94 | void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { | 100 | void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { |
| @@ -125,10 +131,8 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { | |||
| 125 | } | 131 | } |
| 126 | 132 | ||
| 127 | void NVFlinger::CreateLayerAtId(VI::Display& display, u64 layer_id) { | 133 | void NVFlinger::CreateLayerAtId(VI::Display& display, u64 layer_id) { |
| 128 | const u32 buffer_queue_id = next_buffer_queue_id++; | 134 | const auto buffer_id = next_buffer_queue_id++; |
| 129 | buffer_queues.emplace_back( | 135 | display.CreateLayer(layer_id, buffer_id); |
| 130 | std::make_unique<BufferQueue>(system.Kernel(), buffer_queue_id, layer_id, service_context)); | ||
| 131 | display.CreateLayer(layer_id, *buffer_queues.back()); | ||
| 132 | } | 136 | } |
| 133 | 137 | ||
| 134 | void NVFlinger::CloseLayer(u64 layer_id) { | 138 | void NVFlinger::CloseLayer(u64 layer_id) { |
| @@ -147,7 +151,7 @@ std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) { | |||
| 147 | return std::nullopt; | 151 | return std::nullopt; |
| 148 | } | 152 | } |
| 149 | 153 | ||
| 150 | return layer->GetBufferQueue().GetId(); | 154 | return layer->GetBinderId(); |
| 151 | } | 155 | } |
| 152 | 156 | ||
| 153 | Kernel::KReadableEvent* NVFlinger::FindVsyncEvent(u64 display_id) { | 157 | Kernel::KReadableEvent* NVFlinger::FindVsyncEvent(u64 display_id) { |
| @@ -161,18 +165,6 @@ Kernel::KReadableEvent* NVFlinger::FindVsyncEvent(u64 display_id) { | |||
| 161 | return &display->GetVSyncEvent(); | 165 | return &display->GetVSyncEvent(); |
| 162 | } | 166 | } |
| 163 | 167 | ||
| 164 | BufferQueue* NVFlinger::FindBufferQueue(u32 id) { | ||
| 165 | const auto lock_guard = Lock(); | ||
| 166 | const auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(), | ||
| 167 | [id](const auto& queue) { return queue->GetId() == id; }); | ||
| 168 | |||
| 169 | if (itr == buffer_queues.end()) { | ||
| 170 | return nullptr; | ||
| 171 | } | ||
| 172 | |||
| 173 | return itr->get(); | ||
| 174 | } | ||
| 175 | |||
| 176 | VI::Display* NVFlinger::FindDisplay(u64 display_id) { | 168 | VI::Display* NVFlinger::FindDisplay(u64 display_id) { |
| 177 | const auto itr = | 169 | const auto itr = |
| 178 | std::find_if(displays.begin(), displays.end(), | 170 | std::find_if(displays.begin(), displays.end(), |
| @@ -246,23 +238,22 @@ void NVFlinger::Compose() { | |||
| 246 | 238 | ||
| 247 | // TODO(Subv): Support more than 1 layer. | 239 | // TODO(Subv): Support more than 1 layer. |
| 248 | VI::Layer& layer = display.GetLayer(0); | 240 | VI::Layer& layer = display.GetLayer(0); |
| 249 | auto& buffer_queue = layer.GetBufferQueue(); | ||
| 250 | 241 | ||
| 251 | // Search for a queued buffer and acquire it | 242 | android::BufferItem buffer{}; |
| 252 | auto buffer = buffer_queue.AcquireBuffer(); | 243 | const auto status = layer.GetConsumer().AcquireBuffer(&buffer, 0, false); |
| 253 | 244 | ||
| 254 | if (!buffer) { | 245 | if (status != android::Status::NoError) { |
| 255 | continue; | 246 | continue; |
| 256 | } | 247 | } |
| 257 | 248 | ||
| 258 | const auto& igbp_buffer = buffer->get().igbp_buffer; | 249 | const auto& igbp_buffer = *buffer.graphic_buffer; |
| 259 | 250 | ||
| 260 | if (!system.IsPoweredOn()) { | 251 | if (!system.IsPoweredOn()) { |
| 261 | return; // We are likely shutting down | 252 | return; // We are likely shutting down |
| 262 | } | 253 | } |
| 263 | 254 | ||
| 264 | auto& gpu = system.GPU(); | 255 | auto& gpu = system.GPU(); |
| 265 | const auto& multi_fence = buffer->get().multi_fence; | 256 | const auto& multi_fence = buffer.fence; |
| 266 | guard->unlock(); | 257 | guard->unlock(); |
| 267 | for (u32 fence_id = 0; fence_id < multi_fence.num_fences; fence_id++) { | 258 | for (u32 fence_id = 0; fence_id < multi_fence.num_fences; fence_id++) { |
| 268 | const auto& fence = multi_fence.fences[fence_id]; | 259 | const auto& fence = multi_fence.fences[fence_id]; |
| @@ -278,12 +269,18 @@ void NVFlinger::Compose() { | |||
| 278 | auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>("/dev/nvdisp_disp0"); | 269 | auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>("/dev/nvdisp_disp0"); |
| 279 | ASSERT(nvdisp); | 270 | ASSERT(nvdisp); |
| 280 | 271 | ||
| 281 | nvdisp->flip(igbp_buffer.gpu_buffer_id, igbp_buffer.offset, igbp_buffer.external_format, | 272 | Common::Rectangle<int> crop_rect{ |
| 282 | igbp_buffer.width, igbp_buffer.height, igbp_buffer.stride, | 273 | static_cast<int>(buffer.crop.Left()), static_cast<int>(buffer.crop.Top()), |
| 283 | buffer->get().transform, buffer->get().crop_rect); | 274 | static_cast<int>(buffer.crop.Right()), static_cast<int>(buffer.crop.Bottom())}; |
| 275 | |||
| 276 | nvdisp->flip(igbp_buffer.BufferId(), igbp_buffer.Offset(), igbp_buffer.ExternalFormat(), | ||
| 277 | igbp_buffer.Width(), igbp_buffer.Height(), igbp_buffer.Stride(), | ||
| 278 | static_cast<android::BufferTransformFlags>(buffer.transform), crop_rect); | ||
| 279 | |||
| 280 | swap_interval = buffer.swap_interval; | ||
| 284 | 281 | ||
| 285 | swap_interval = buffer->get().swap_interval; | 282 | auto fence = android::Fence::NoFence(); |
| 286 | buffer_queue.ReleaseBuffer(buffer->get().slot); | 283 | layer.GetConsumer().ReleaseBuffer(buffer, fence); |
| 287 | } | 284 | } |
| 288 | } | 285 | } |
| 289 | 286 | ||
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 7935cf773..5112ae136 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Licensed under GPLv2 or any later version | 2 | // Copyright 2021 yuzu Emulator Project |
| 3 | // Refer to the license.txt file included. | ||
| 4 | 3 | ||
| 5 | #pragma once | 4 | #pragma once |
| 6 | 5 | ||
| @@ -9,6 +8,7 @@ | |||
| 9 | #include <mutex> | 8 | #include <mutex> |
| 10 | #include <optional> | 9 | #include <optional> |
| 11 | #include <thread> | 10 | #include <thread> |
| 11 | #include <unordered_map> | ||
| 12 | #include <vector> | 12 | #include <vector> |
| 13 | 13 | ||
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| @@ -37,13 +37,16 @@ class Display; | |||
| 37 | class Layer; | 37 | class Layer; |
| 38 | } // namespace Service::VI | 38 | } // namespace Service::VI |
| 39 | 39 | ||
| 40 | namespace Service::NVFlinger { | 40 | namespace android { |
| 41 | class BufferQueueCore; | ||
| 42 | class BufferQueueProducer; | ||
| 43 | } // namespace android | ||
| 41 | 44 | ||
| 42 | class BufferQueue; | 45 | namespace Service::NVFlinger { |
| 43 | 46 | ||
| 44 | class NVFlinger final { | 47 | class NVFlinger final { |
| 45 | public: | 48 | public: |
| 46 | explicit NVFlinger(Core::System& system_); | 49 | explicit NVFlinger(Core::System& system_, HosBinderDriverServer& hos_binder_driver_server_); |
| 47 | ~NVFlinger(); | 50 | ~NVFlinger(); |
| 48 | 51 | ||
| 49 | /// Sets the NVDrv module instance to use to send buffers to the GPU. | 52 | /// Sets the NVDrv module instance to use to send buffers to the GPU. |
| @@ -72,9 +75,6 @@ public: | |||
| 72 | /// If an invalid display ID is provided, then nullptr is returned. | 75 | /// If an invalid display ID is provided, then nullptr is returned. |
| 73 | [[nodiscard]] Kernel::KReadableEvent* FindVsyncEvent(u64 display_id); | 76 | [[nodiscard]] Kernel::KReadableEvent* FindVsyncEvent(u64 display_id); |
| 74 | 77 | ||
| 75 | /// Obtains a buffer queue identified by the ID. | ||
| 76 | [[nodiscard]] BufferQueue* FindBufferQueue(u32 id); | ||
| 77 | |||
| 78 | /// Performs a composition request to the emulated nvidia GPU and triggers the vsync events when | 78 | /// Performs a composition request to the emulated nvidia GPU and triggers the vsync events when |
| 79 | /// finished. | 79 | /// finished. |
| 80 | void Compose(); | 80 | void Compose(); |
| @@ -82,6 +82,12 @@ public: | |||
| 82 | [[nodiscard]] s64 GetNextTicks() const; | 82 | [[nodiscard]] s64 GetNextTicks() const; |
| 83 | 83 | ||
| 84 | private: | 84 | private: |
| 85 | struct Layer { | ||
| 86 | std::unique_ptr<android::BufferQueueCore> core; | ||
| 87 | std::unique_ptr<android::BufferQueueProducer> producer; | ||
| 88 | }; | ||
| 89 | |||
| 90 | private: | ||
| 85 | [[nodiscard]] std::unique_lock<std::mutex> Lock() const { | 91 | [[nodiscard]] std::unique_lock<std::mutex> Lock() const { |
| 86 | return std::unique_lock{*guard}; | 92 | return std::unique_lock{*guard}; |
| 87 | } | 93 | } |
| @@ -111,7 +117,6 @@ private: | |||
| 111 | std::shared_ptr<Nvidia::Module> nvdrv; | 117 | std::shared_ptr<Nvidia::Module> nvdrv; |
| 112 | 118 | ||
| 113 | std::list<VI::Display> displays; | 119 | std::list<VI::Display> displays; |
| 114 | std::vector<std::unique_ptr<BufferQueue>> buffer_queues; | ||
| 115 | 120 | ||
| 116 | /// Id to use for the next layer that is created, this counter is shared among all displays. | 121 | /// Id to use for the next layer that is created, this counter is shared among all displays. |
| 117 | u64 next_layer_id = 1; | 122 | u64 next_layer_id = 1; |
| @@ -131,6 +136,8 @@ private: | |||
| 131 | std::jthread vsync_thread; | 136 | std::jthread vsync_thread; |
| 132 | 137 | ||
| 133 | KernelHelpers::ServiceContext service_context; | 138 | KernelHelpers::ServiceContext service_context; |
| 139 | |||
| 140 | HosBinderDriverServer& hos_binder_driver_server; | ||
| 134 | }; | 141 | }; |
| 135 | 142 | ||
| 136 | } // namespace Service::NVFlinger | 143 | } // namespace Service::NVFlinger |
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index eb1138313..ab3286db9 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -49,6 +49,7 @@ | |||
| 49 | #include "core/hle/service/npns/npns.h" | 49 | #include "core/hle/service/npns/npns.h" |
| 50 | #include "core/hle/service/ns/ns.h" | 50 | #include "core/hle/service/ns/ns.h" |
| 51 | #include "core/hle/service/nvdrv/nvdrv.h" | 51 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 52 | #include "core/hle/service/nvflinger/hos_binder_driver_server.h" | ||
| 52 | #include "core/hle/service/nvflinger/nvflinger.h" | 53 | #include "core/hle/service/nvflinger/nvflinger.h" |
| 53 | #include "core/hle/service/olsc/olsc.h" | 54 | #include "core/hle/service/olsc/olsc.h" |
| 54 | #include "core/hle/service/pcie/pcie.h" | 55 | #include "core/hle/service/pcie/pcie.h" |
| @@ -230,7 +231,8 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::KServerSession& sessi | |||
| 230 | 231 | ||
| 231 | /// Initialize Services | 232 | /// Initialize Services |
| 232 | Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) | 233 | Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) |
| 233 | : nv_flinger{std::make_unique<NVFlinger::NVFlinger>(system)} { | 234 | : hos_binder_driver_server{std::make_unique<NVFlinger::HosBinderDriverServer>(system)}, |
| 235 | nv_flinger{std::make_unique<NVFlinger::NVFlinger>(system, *hos_binder_driver_server)} { | ||
| 234 | 236 | ||
| 235 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it | 237 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it |
| 236 | // here and pass it into the respective InstallInterfaces functions. | 238 | // here and pass it into the respective InstallInterfaces functions. |
| @@ -290,7 +292,7 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system | |||
| 290 | SSL::InstallInterfaces(*sm, system); | 292 | SSL::InstallInterfaces(*sm, system); |
| 291 | Time::InstallInterfaces(system); | 293 | Time::InstallInterfaces(system); |
| 292 | USB::InstallInterfaces(*sm, system); | 294 | USB::InstallInterfaces(*sm, system); |
| 293 | VI::InstallInterfaces(*sm, system, *nv_flinger); | 295 | VI::InstallInterfaces(*sm, system, *nv_flinger, *hos_binder_driver_server); |
| 294 | WLAN::InstallInterfaces(*sm, system); | 296 | WLAN::InstallInterfaces(*sm, system); |
| 295 | } | 297 | } |
| 296 | 298 | ||
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index c9d6b879d..b9ab2c465 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -33,8 +33,9 @@ class FileSystemController; | |||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | namespace NVFlinger { | 35 | namespace NVFlinger { |
| 36 | class HosBinderDriverServer; | ||
| 36 | class NVFlinger; | 37 | class NVFlinger; |
| 37 | } | 38 | } // namespace NVFlinger |
| 38 | 39 | ||
| 39 | namespace SM { | 40 | namespace SM { |
| 40 | class ServiceManager; | 41 | class ServiceManager; |
| @@ -236,6 +237,7 @@ public: | |||
| 236 | ~Services(); | 237 | ~Services(); |
| 237 | 238 | ||
| 238 | private: | 239 | private: |
| 240 | std::unique_ptr<NVFlinger::HosBinderDriverServer> hos_binder_driver_server; | ||
| 239 | std::unique_ptr<NVFlinger::NVFlinger> nv_flinger; | 241 | std::unique_ptr<NVFlinger::NVFlinger> nv_flinger; |
| 240 | }; | 242 | }; |
| 241 | 243 | ||
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index b7705c02a..558022511 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp | |||
| @@ -13,14 +13,34 @@ | |||
| 13 | #include "core/hle/kernel/k_readable_event.h" | 13 | #include "core/hle/kernel/k_readable_event.h" |
| 14 | #include "core/hle/kernel/k_writable_event.h" | 14 | #include "core/hle/kernel/k_writable_event.h" |
| 15 | #include "core/hle/service/kernel_helpers.h" | 15 | #include "core/hle/service/kernel_helpers.h" |
| 16 | #include "core/hle/service/nvflinger/buffer_item_consumer.h" | ||
| 17 | #include "core/hle/service/nvflinger/buffer_queue_consumer.h" | ||
| 18 | #include "core/hle/service/nvflinger/buffer_queue_core.h" | ||
| 19 | #include "core/hle/service/nvflinger/buffer_queue_producer.h" | ||
| 20 | #include "core/hle/service/nvflinger/hos_binder_driver_server.h" | ||
| 16 | #include "core/hle/service/vi/display/vi_display.h" | 21 | #include "core/hle/service/vi/display/vi_display.h" |
| 17 | #include "core/hle/service/vi/layer/vi_layer.h" | 22 | #include "core/hle/service/vi/layer/vi_layer.h" |
| 18 | 23 | ||
| 19 | namespace Service::VI { | 24 | namespace Service::VI { |
| 20 | 25 | ||
| 21 | Display::Display(u64 id, std::string name_, KernelHelpers::ServiceContext& service_context_, | 26 | struct BufferQueue { |
| 22 | Core::System& system_) | 27 | std::shared_ptr<android::BufferQueueCore> core; |
| 23 | : display_id{id}, name{std::move(name_)}, service_context{service_context_} { | 28 | std::unique_ptr<android::BufferQueueProducer> producer; |
| 29 | std::unique_ptr<android::BufferQueueConsumer> consumer; | ||
| 30 | }; | ||
| 31 | |||
| 32 | static BufferQueue CreateBufferQueue(KernelHelpers::ServiceContext& service_context) { | ||
| 33 | auto buffer_queue_core = std::make_shared<android::BufferQueueCore>(); | ||
| 34 | return {buffer_queue_core, | ||
| 35 | std::make_unique<android::BufferQueueProducer>(service_context, buffer_queue_core), | ||
| 36 | std::make_unique<android::BufferQueueConsumer>(buffer_queue_core)}; | ||
| 37 | } | ||
| 38 | |||
| 39 | Display::Display(u64 id, std::string name_, | ||
| 40 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server_, | ||
| 41 | KernelHelpers::ServiceContext& service_context_, Core::System& system_) | ||
| 42 | : display_id{id}, name{std::move(name_)}, hos_binder_driver_server{hos_binder_driver_server_}, | ||
| 43 | service_context{service_context_} { | ||
| 24 | vsync_event = service_context.CreateEvent(fmt::format("Display VSync Event {}", id)); | 44 | vsync_event = service_context.CreateEvent(fmt::format("Display VSync Event {}", id)); |
| 25 | } | 45 | } |
| 26 | 46 | ||
| @@ -44,21 +64,29 @@ void Display::SignalVSyncEvent() { | |||
| 44 | vsync_event->GetWritableEvent().Signal(); | 64 | vsync_event->GetWritableEvent().Signal(); |
| 45 | } | 65 | } |
| 46 | 66 | ||
| 47 | void Display::CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue) { | 67 | void Display::CreateLayer(u64 layer_id, u32 binder_id) { |
| 48 | // TODO(Subv): Support more than 1 layer. | ||
| 49 | ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment"); | 68 | ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment"); |
| 50 | 69 | ||
| 51 | layers.emplace_back(std::make_shared<Layer>(layer_id, buffer_queue)); | 70 | auto [core, producer, consumer] = CreateBufferQueue(service_context); |
| 71 | |||
| 72 | auto buffer_item_consumer = std::make_shared<android::BufferItemConsumer>(std::move(consumer)); | ||
| 73 | buffer_item_consumer->Connect(false); | ||
| 74 | |||
| 75 | layers.emplace_back(std::make_unique<Layer>(layer_id, binder_id, *core, *producer, | ||
| 76 | std::move(buffer_item_consumer))); | ||
| 77 | |||
| 78 | hos_binder_driver_server.RegisterProducer(std::move(producer)); | ||
| 52 | } | 79 | } |
| 53 | 80 | ||
| 54 | void Display::CloseLayer(u64 layer_id) { | 81 | void Display::CloseLayer(u64 layer_id) { |
| 55 | std::erase_if(layers, [layer_id](const auto& layer) { return layer->GetID() == layer_id; }); | 82 | std::erase_if(layers, |
| 83 | [layer_id](const auto& layer) { return layer->GetLayerId() == layer_id; }); | ||
| 56 | } | 84 | } |
| 57 | 85 | ||
| 58 | Layer* Display::FindLayer(u64 layer_id) { | 86 | Layer* Display::FindLayer(u64 layer_id) { |
| 59 | const auto itr = | 87 | const auto itr = |
| 60 | std::find_if(layers.begin(), layers.end(), [layer_id](const std::shared_ptr<Layer>& layer) { | 88 | std::find_if(layers.begin(), layers.end(), [layer_id](const std::unique_ptr<Layer>& layer) { |
| 61 | return layer->GetID() == layer_id; | 89 | return layer->GetLayerId() == layer_id; |
| 62 | }); | 90 | }); |
| 63 | 91 | ||
| 64 | if (itr == layers.end()) { | 92 | if (itr == layers.end()) { |
| @@ -70,8 +98,8 @@ Layer* Display::FindLayer(u64 layer_id) { | |||
| 70 | 98 | ||
| 71 | const Layer* Display::FindLayer(u64 layer_id) const { | 99 | const Layer* Display::FindLayer(u64 layer_id) const { |
| 72 | const auto itr = | 100 | const auto itr = |
| 73 | std::find_if(layers.begin(), layers.end(), [layer_id](const std::shared_ptr<Layer>& layer) { | 101 | std::find_if(layers.begin(), layers.end(), [layer_id](const std::unique_ptr<Layer>& layer) { |
| 74 | return layer->GetID() == layer_id; | 102 | return layer->GetLayerId() == layer_id; |
| 75 | }); | 103 | }); |
| 76 | 104 | ||
| 77 | if (itr == layers.end()) { | 105 | if (itr == layers.end()) { |
diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 329f4ba86..9cf324395 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h | |||
| @@ -15,12 +15,17 @@ namespace Kernel { | |||
| 15 | class KEvent; | 15 | class KEvent; |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | namespace Service::NVFlinger { | 18 | namespace android { |
| 19 | class BufferQueue; | 19 | class BufferQueueProducer; |
| 20 | } | 20 | } |
| 21 | |||
| 21 | namespace Service::KernelHelpers { | 22 | namespace Service::KernelHelpers { |
| 22 | class ServiceContext; | 23 | class ServiceContext; |
| 23 | } // namespace Service::KernelHelpers | 24 | } |
| 25 | |||
| 26 | namespace Service::NVFlinger { | ||
| 27 | class HosBinderDriverServer; | ||
| 28 | } | ||
| 24 | 29 | ||
| 25 | namespace Service::VI { | 30 | namespace Service::VI { |
| 26 | 31 | ||
| @@ -35,12 +40,13 @@ public: | |||
| 35 | /// Constructs a display with a given unique ID and name. | 40 | /// Constructs a display with a given unique ID and name. |
| 36 | /// | 41 | /// |
| 37 | /// @param id The unique ID for this display. | 42 | /// @param id The unique ID for this display. |
| 43 | /// @param hos_binder_driver_server_ NVFlinger HOSBinderDriver server instance. | ||
| 38 | /// @param service_context_ The ServiceContext for the owning service. | 44 | /// @param service_context_ The ServiceContext for the owning service. |
| 39 | /// @param name_ The name for this display. | 45 | /// @param name_ The name for this display. |
| 40 | /// @param system_ The global system instance. | 46 | /// @param system_ The global system instance. |
| 41 | /// | 47 | /// |
| 42 | Display(u64 id, std::string name_, KernelHelpers::ServiceContext& service_context_, | 48 | Display(u64 id, std::string name_, NVFlinger::HosBinderDriverServer& hos_binder_driver_server_, |
| 43 | Core::System& system_); | 49 | KernelHelpers::ServiceContext& service_context_, Core::System& system_); |
| 44 | ~Display(); | 50 | ~Display(); |
| 45 | 51 | ||
| 46 | /// Gets the unique ID assigned to this display. | 52 | /// Gets the unique ID assigned to this display. |
| @@ -64,6 +70,10 @@ public: | |||
| 64 | /// Gets a layer for this display based off an index. | 70 | /// Gets a layer for this display based off an index. |
| 65 | const Layer& GetLayer(std::size_t index) const; | 71 | const Layer& GetLayer(std::size_t index) const; |
| 66 | 72 | ||
| 73 | std::size_t GetNumLayers() const { | ||
| 74 | return layers.size(); | ||
| 75 | } | ||
| 76 | |||
| 67 | /// Gets the readable vsync event. | 77 | /// Gets the readable vsync event. |
| 68 | Kernel::KReadableEvent& GetVSyncEvent(); | 78 | Kernel::KReadableEvent& GetVSyncEvent(); |
| 69 | 79 | ||
| @@ -72,10 +82,10 @@ public: | |||
| 72 | 82 | ||
| 73 | /// Creates and adds a layer to this display with the given ID. | 83 | /// Creates and adds a layer to this display with the given ID. |
| 74 | /// | 84 | /// |
| 75 | /// @param layer_id The ID to assign to the created layer. | 85 | /// @param layer_id The ID to assign to the created layer. |
| 76 | /// @param buffer_queue The buffer queue for the layer instance to use. | 86 | /// @param binder_id The ID assigned to the buffer queue. |
| 77 | /// | 87 | /// |
| 78 | void CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue); | 88 | void CreateLayer(u64 layer_id, u32 binder_id); |
| 79 | 89 | ||
| 80 | /// Closes and removes a layer from this display with the given ID. | 90 | /// Closes and removes a layer from this display with the given ID. |
| 81 | /// | 91 | /// |
| @@ -104,9 +114,10 @@ public: | |||
| 104 | private: | 114 | private: |
| 105 | u64 display_id; | 115 | u64 display_id; |
| 106 | std::string name; | 116 | std::string name; |
| 117 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server; | ||
| 107 | KernelHelpers::ServiceContext& service_context; | 118 | KernelHelpers::ServiceContext& service_context; |
| 108 | 119 | ||
| 109 | std::vector<std::shared_ptr<Layer>> layers; | 120 | std::vector<std::unique_ptr<Layer>> layers; |
| 110 | Kernel::KEvent* vsync_event{}; | 121 | Kernel::KEvent* vsync_event{}; |
| 111 | }; | 122 | }; |
| 112 | 123 | ||
diff --git a/src/core/hle/service/vi/layer/vi_layer.cpp b/src/core/hle/service/vi/layer/vi_layer.cpp index 9bc382587..93858e91f 100644 --- a/src/core/hle/service/vi/layer/vi_layer.cpp +++ b/src/core/hle/service/vi/layer/vi_layer.cpp | |||
| @@ -6,7 +6,11 @@ | |||
| 6 | 6 | ||
| 7 | namespace Service::VI { | 7 | namespace Service::VI { |
| 8 | 8 | ||
| 9 | Layer::Layer(u64 id, NVFlinger::BufferQueue& queue) : layer_id{id}, buffer_queue{queue} {} | 9 | Layer::Layer(u64 layer_id_, u32 binder_id_, android::BufferQueueCore& core_, |
| 10 | android::BufferQueueProducer& binder_, | ||
| 11 | std::shared_ptr<android::BufferItemConsumer>&& consumer_) | ||
| 12 | : layer_id{layer_id_}, binder_id{binder_id_}, core{core_}, binder{binder_}, consumer{std::move( | ||
| 13 | consumer_)} {} | ||
| 10 | 14 | ||
| 11 | Layer::~Layer() = default; | 15 | Layer::~Layer() = default; |
| 12 | 16 | ||
diff --git a/src/core/hle/service/vi/layer/vi_layer.h b/src/core/hle/service/vi/layer/vi_layer.h index ebdd85505..079ec4dda 100644 --- a/src/core/hle/service/vi/layer/vi_layer.h +++ b/src/core/hle/service/vi/layer/vi_layer.h | |||
| @@ -4,11 +4,15 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | ||
| 8 | |||
| 7 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 8 | 10 | ||
| 9 | namespace Service::NVFlinger { | 11 | namespace android { |
| 10 | class BufferQueue; | 12 | class BufferItemConsumer; |
| 11 | } | 13 | class BufferQueueCore; |
| 14 | class BufferQueueProducer; | ||
| 15 | } // namespace android | ||
| 12 | 16 | ||
| 13 | namespace Service::VI { | 17 | namespace Service::VI { |
| 14 | 18 | ||
| @@ -17,10 +21,13 @@ class Layer { | |||
| 17 | public: | 21 | public: |
| 18 | /// Constructs a layer with a given ID and buffer queue. | 22 | /// Constructs a layer with a given ID and buffer queue. |
| 19 | /// | 23 | /// |
| 20 | /// @param id The ID to assign to this layer. | 24 | /// @param layer_id_ The ID to assign to this layer. |
| 21 | /// @param queue The buffer queue for this layer to use. | 25 | /// @param binder_id_ The binder ID to assign to this layer. |
| 26 | /// @param binder_ The buffer producer queue for this layer to use. | ||
| 22 | /// | 27 | /// |
| 23 | Layer(u64 id, NVFlinger::BufferQueue& queue); | 28 | Layer(u64 layer_id_, u32 binder_id_, android::BufferQueueCore& core_, |
| 29 | android::BufferQueueProducer& binder_, | ||
| 30 | std::shared_ptr<android::BufferItemConsumer>&& consumer_); | ||
| 24 | ~Layer(); | 31 | ~Layer(); |
| 25 | 32 | ||
| 26 | Layer(const Layer&) = delete; | 33 | Layer(const Layer&) = delete; |
| @@ -30,23 +37,47 @@ public: | |||
| 30 | Layer& operator=(Layer&&) = delete; | 37 | Layer& operator=(Layer&&) = delete; |
| 31 | 38 | ||
| 32 | /// Gets the ID for this layer. | 39 | /// Gets the ID for this layer. |
| 33 | u64 GetID() const { | 40 | u64 GetLayerId() const { |
| 34 | return layer_id; | 41 | return layer_id; |
| 35 | } | 42 | } |
| 36 | 43 | ||
| 44 | /// Gets the binder ID for this layer. | ||
| 45 | u32 GetBinderId() const { | ||
| 46 | return binder_id; | ||
| 47 | } | ||
| 48 | |||
| 37 | /// Gets a reference to the buffer queue this layer is using. | 49 | /// Gets a reference to the buffer queue this layer is using. |
| 38 | NVFlinger::BufferQueue& GetBufferQueue() { | 50 | android::BufferQueueProducer& GetBufferQueue() { |
| 39 | return buffer_queue; | 51 | return binder; |
| 40 | } | 52 | } |
| 41 | 53 | ||
| 42 | /// Gets a const reference to the buffer queue this layer is using. | 54 | /// Gets a const reference to the buffer queue this layer is using. |
| 43 | const NVFlinger::BufferQueue& GetBufferQueue() const { | 55 | const android::BufferQueueProducer& GetBufferQueue() const { |
| 44 | return buffer_queue; | 56 | return binder; |
| 57 | } | ||
| 58 | |||
| 59 | android::BufferItemConsumer& GetConsumer() { | ||
| 60 | return *consumer; | ||
| 61 | } | ||
| 62 | |||
| 63 | const android::BufferItemConsumer& GetConsumer() const { | ||
| 64 | return *consumer; | ||
| 65 | } | ||
| 66 | |||
| 67 | android::BufferQueueCore& Core() { | ||
| 68 | return core; | ||
| 69 | } | ||
| 70 | |||
| 71 | const android::BufferQueueCore& Core() const { | ||
| 72 | return core; | ||
| 45 | } | 73 | } |
| 46 | 74 | ||
| 47 | private: | 75 | private: |
| 48 | u64 layer_id; | 76 | const u64 layer_id; |
| 49 | NVFlinger::BufferQueue& buffer_queue; | 77 | const u32 binder_id; |
| 78 | android::BufferQueueCore& core; | ||
| 79 | android::BufferQueueProducer& binder; | ||
| 80 | std::shared_ptr<android::BufferItemConsumer> consumer; | ||
| 50 | }; | 81 | }; |
| 51 | 82 | ||
| 52 | } // namespace Service::VI | 83 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 75ee3e5e4..e49e1ae28 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -22,8 +22,11 @@ | |||
| 22 | #include "core/hle/kernel/k_readable_event.h" | 22 | #include "core/hle/kernel/k_readable_event.h" |
| 23 | #include "core/hle/kernel/k_thread.h" | 23 | #include "core/hle/kernel/k_thread.h" |
| 24 | #include "core/hle/service/nvdrv/nvdata.h" | 24 | #include "core/hle/service/nvdrv/nvdata.h" |
| 25 | #include "core/hle/service/nvflinger/buffer_queue.h" | 25 | #include "core/hle/service/nvflinger/binder.h" |
| 26 | #include "core/hle/service/nvflinger/buffer_queue_producer.h" | ||
| 27 | #include "core/hle/service/nvflinger/hos_binder_driver_server.h" | ||
| 26 | #include "core/hle/service/nvflinger/nvflinger.h" | 28 | #include "core/hle/service/nvflinger/nvflinger.h" |
| 29 | #include "core/hle/service/nvflinger/parcel.h" | ||
| 27 | #include "core/hle/service/service.h" | 30 | #include "core/hle/service/service.h" |
| 28 | #include "core/hle/service/vi/vi.h" | 31 | #include "core/hle/service/vi/vi.h" |
| 29 | #include "core/hle/service/vi/vi_m.h" | 32 | #include "core/hle/service/vi/vi_m.h" |
| @@ -57,447 +60,24 @@ struct DisplayInfo { | |||
| 57 | }; | 60 | }; |
| 58 | static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size"); | 61 | static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size"); |
| 59 | 62 | ||
| 60 | class Parcel { | 63 | class NativeWindow final { |
| 61 | public: | 64 | public: |
| 62 | // This default size was chosen arbitrarily. | 65 | constexpr explicit NativeWindow(u32 id_) : id{id_} {} |
| 63 | static constexpr std::size_t DefaultBufferSize = 0x40; | ||
| 64 | Parcel() : buffer(DefaultBufferSize) {} | ||
| 65 | explicit Parcel(std::vector<u8> data) : buffer(std::move(data)) {} | ||
| 66 | virtual ~Parcel() = default; | ||
| 67 | |||
| 68 | template <typename T> | ||
| 69 | T Read() { | ||
| 70 | static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable."); | ||
| 71 | ASSERT(read_index + sizeof(T) <= buffer.size()); | ||
| 72 | |||
| 73 | T val; | ||
| 74 | std::memcpy(&val, buffer.data() + read_index, sizeof(T)); | ||
| 75 | read_index += sizeof(T); | ||
| 76 | read_index = Common::AlignUp(read_index, 4); | ||
| 77 | return val; | ||
| 78 | } | ||
| 79 | |||
| 80 | template <typename T> | ||
| 81 | T ReadUnaligned() { | ||
| 82 | static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable."); | ||
| 83 | ASSERT(read_index + sizeof(T) <= buffer.size()); | ||
| 84 | |||
| 85 | T val; | ||
| 86 | std::memcpy(&val, buffer.data() + read_index, sizeof(T)); | ||
| 87 | read_index += sizeof(T); | ||
| 88 | return val; | ||
| 89 | } | ||
| 90 | |||
| 91 | std::vector<u8> ReadBlock(std::size_t length) { | ||
| 92 | ASSERT(read_index + length <= buffer.size()); | ||
| 93 | const u8* const begin = buffer.data() + read_index; | ||
| 94 | const u8* const end = begin + length; | ||
| 95 | std::vector<u8> data(begin, end); | ||
| 96 | read_index += length; | ||
| 97 | read_index = Common::AlignUp(read_index, 4); | ||
| 98 | return data; | ||
| 99 | } | ||
| 100 | |||
| 101 | std::u16string ReadInterfaceToken() { | ||
| 102 | [[maybe_unused]] const u32 unknown = Read<u32_le>(); | ||
| 103 | const u32 length = Read<u32_le>(); | ||
| 104 | |||
| 105 | std::u16string token{}; | ||
| 106 | |||
| 107 | for (u32 ch = 0; ch < length + 1; ++ch) { | ||
| 108 | token.push_back(ReadUnaligned<u16_le>()); | ||
| 109 | } | ||
| 110 | |||
| 111 | read_index = Common::AlignUp(read_index, 4); | ||
| 112 | |||
| 113 | return token; | ||
| 114 | } | ||
| 115 | |||
| 116 | template <typename T> | ||
| 117 | void Write(const T& val) { | ||
| 118 | static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable."); | ||
| 119 | |||
| 120 | if (buffer.size() < write_index + sizeof(T)) { | ||
| 121 | buffer.resize(buffer.size() + sizeof(T) + DefaultBufferSize); | ||
| 122 | } | ||
| 123 | |||
| 124 | std::memcpy(buffer.data() + write_index, &val, sizeof(T)); | ||
| 125 | write_index += sizeof(T); | ||
| 126 | write_index = Common::AlignUp(write_index, 4); | ||
| 127 | } | ||
| 128 | |||
| 129 | template <typename T> | ||
| 130 | void WriteObject(const T& val) { | ||
| 131 | static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable."); | ||
| 132 | |||
| 133 | const u32_le size = static_cast<u32>(sizeof(val)); | ||
| 134 | Write(size); | ||
| 135 | // TODO(Subv): Support file descriptors. | ||
| 136 | Write<u32_le>(0); // Fd count. | ||
| 137 | Write(val); | ||
| 138 | } | ||
| 139 | |||
| 140 | void Deserialize() { | ||
| 141 | ASSERT(buffer.size() > sizeof(Header)); | ||
| 142 | |||
| 143 | Header header{}; | ||
| 144 | std::memcpy(&header, buffer.data(), sizeof(Header)); | ||
| 145 | |||
| 146 | read_index = header.data_offset; | ||
| 147 | DeserializeData(); | ||
| 148 | } | ||
| 149 | |||
| 150 | std::vector<u8> Serialize() { | ||
| 151 | ASSERT(read_index == 0); | ||
| 152 | write_index = sizeof(Header); | ||
| 153 | |||
| 154 | SerializeData(); | ||
| 155 | |||
| 156 | Header header{}; | ||
| 157 | header.data_size = static_cast<u32_le>(write_index - sizeof(Header)); | ||
| 158 | header.data_offset = sizeof(Header); | ||
| 159 | header.objects_size = 4; | ||
| 160 | header.objects_offset = static_cast<u32>(sizeof(Header) + header.data_size); | ||
| 161 | std::memcpy(buffer.data(), &header, sizeof(Header)); | ||
| 162 | |||
| 163 | return buffer; | ||
| 164 | } | ||
| 165 | |||
| 166 | protected: | ||
| 167 | virtual void SerializeData() {} | ||
| 168 | |||
| 169 | virtual void DeserializeData() {} | ||
| 170 | |||
| 171 | private: | ||
| 172 | struct Header { | ||
| 173 | u32_le data_size; | ||
| 174 | u32_le data_offset; | ||
| 175 | u32_le objects_size; | ||
| 176 | u32_le objects_offset; | ||
| 177 | }; | ||
| 178 | static_assert(sizeof(Header) == 16, "ParcelHeader has wrong size"); | ||
| 179 | |||
| 180 | std::vector<u8> buffer; | ||
| 181 | std::size_t read_index = 0; | ||
| 182 | std::size_t write_index = 0; | ||
| 183 | }; | ||
| 184 | |||
| 185 | class NativeWindow : public Parcel { | ||
| 186 | public: | ||
| 187 | explicit NativeWindow(u32 id) { | ||
| 188 | data.id = id; | ||
| 189 | } | ||
| 190 | ~NativeWindow() override = default; | ||
| 191 | |||
| 192 | protected: | ||
| 193 | void SerializeData() override { | ||
| 194 | Write(data); | ||
| 195 | } | ||
| 196 | |||
| 197 | private: | ||
| 198 | struct Data { | ||
| 199 | u32_le magic = 2; | ||
| 200 | u32_le process_id = 1; | ||
| 201 | u32_le id; | ||
| 202 | INSERT_PADDING_WORDS(3); | ||
| 203 | std::array<u8, 8> dispdrv = {'d', 'i', 's', 'p', 'd', 'r', 'v', '\0'}; | ||
| 204 | INSERT_PADDING_WORDS(2); | ||
| 205 | }; | ||
| 206 | static_assert(sizeof(Data) == 0x28, "ParcelData has wrong size"); | ||
| 207 | |||
| 208 | Data data{}; | ||
| 209 | }; | ||
| 210 | |||
| 211 | class IGBPConnectRequestParcel : public Parcel { | ||
| 212 | public: | ||
| 213 | explicit IGBPConnectRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { | ||
| 214 | Deserialize(); | ||
| 215 | } | ||
| 216 | |||
| 217 | void DeserializeData() override { | ||
| 218 | [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); | ||
| 219 | data = Read<Data>(); | ||
| 220 | } | ||
| 221 | |||
| 222 | struct Data { | ||
| 223 | u32_le unk; | ||
| 224 | u32_le api; | ||
| 225 | u32_le producer_controlled_by_app; | ||
| 226 | }; | ||
| 227 | |||
| 228 | Data data; | ||
| 229 | }; | ||
| 230 | |||
| 231 | class IGBPConnectResponseParcel : public Parcel { | ||
| 232 | public: | ||
| 233 | explicit IGBPConnectResponseParcel(u32 width, u32 height) { | ||
| 234 | data.width = width; | ||
| 235 | data.height = height; | ||
| 236 | } | ||
| 237 | ~IGBPConnectResponseParcel() override = default; | ||
| 238 | |||
| 239 | protected: | ||
| 240 | void SerializeData() override { | ||
| 241 | Write(data); | ||
| 242 | } | ||
| 243 | |||
| 244 | private: | ||
| 245 | struct Data { | ||
| 246 | u32_le width; | ||
| 247 | u32_le height; | ||
| 248 | u32_le transform_hint; | ||
| 249 | u32_le num_pending_buffers; | ||
| 250 | u32_le status; | ||
| 251 | }; | ||
| 252 | static_assert(sizeof(Data) == 20, "ParcelData has wrong size"); | ||
| 253 | |||
| 254 | Data data{}; | ||
| 255 | }; | ||
| 256 | |||
| 257 | /// Represents a parcel containing one int '0' as its data | ||
| 258 | /// Used by DetachBuffer and Disconnect | ||
| 259 | class IGBPEmptyResponseParcel : public Parcel { | ||
| 260 | protected: | ||
| 261 | void SerializeData() override { | ||
| 262 | Write(data); | ||
| 263 | } | ||
| 264 | |||
| 265 | private: | ||
| 266 | struct Data { | ||
| 267 | u32_le unk_0{}; | ||
| 268 | }; | ||
| 269 | |||
| 270 | Data data{}; | ||
| 271 | }; | ||
| 272 | |||
| 273 | class IGBPSetPreallocatedBufferRequestParcel : public Parcel { | ||
| 274 | public: | ||
| 275 | explicit IGBPSetPreallocatedBufferRequestParcel(std::vector<u8> buffer_) | ||
| 276 | : Parcel(std::move(buffer_)) { | ||
| 277 | Deserialize(); | ||
| 278 | } | ||
| 279 | |||
| 280 | void DeserializeData() override { | ||
| 281 | [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); | ||
| 282 | data = Read<Data>(); | ||
| 283 | if (data.contains_object != 0) { | ||
| 284 | buffer_container = Read<BufferContainer>(); | ||
| 285 | } | ||
| 286 | } | ||
| 287 | |||
| 288 | struct Data { | ||
| 289 | u32_le slot; | ||
| 290 | u32_le contains_object; | ||
| 291 | }; | ||
| 292 | |||
| 293 | struct BufferContainer { | ||
| 294 | u32_le graphic_buffer_length; | ||
| 295 | INSERT_PADDING_WORDS(1); | ||
| 296 | NVFlinger::IGBPBuffer buffer{}; | ||
| 297 | }; | ||
| 298 | |||
| 299 | Data data{}; | ||
| 300 | BufferContainer buffer_container{}; | ||
| 301 | }; | ||
| 302 | |||
| 303 | class IGBPSetPreallocatedBufferResponseParcel : public Parcel { | ||
| 304 | protected: | ||
| 305 | void SerializeData() override { | ||
| 306 | // TODO(Subv): Find out what this means | ||
| 307 | Write<u32>(0); | ||
| 308 | } | ||
| 309 | }; | ||
| 310 | |||
| 311 | class IGBPCancelBufferRequestParcel : public Parcel { | ||
| 312 | public: | ||
| 313 | explicit IGBPCancelBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { | ||
| 314 | Deserialize(); | ||
| 315 | } | ||
| 316 | |||
| 317 | void DeserializeData() override { | ||
| 318 | [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); | ||
| 319 | data = Read<Data>(); | ||
| 320 | } | ||
| 321 | |||
| 322 | struct Data { | ||
| 323 | u32_le slot; | ||
| 324 | Service::Nvidia::MultiFence multi_fence; | ||
| 325 | }; | ||
| 326 | |||
| 327 | Data data; | ||
| 328 | }; | ||
| 329 | |||
| 330 | class IGBPCancelBufferResponseParcel : public Parcel { | ||
| 331 | protected: | ||
| 332 | void SerializeData() override { | ||
| 333 | Write<u32>(0); // Success | ||
| 334 | } | ||
| 335 | }; | ||
| 336 | |||
| 337 | class IGBPDequeueBufferRequestParcel : public Parcel { | ||
| 338 | public: | ||
| 339 | explicit IGBPDequeueBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { | ||
| 340 | Deserialize(); | ||
| 341 | } | ||
| 342 | |||
| 343 | void DeserializeData() override { | ||
| 344 | [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); | ||
| 345 | data = Read<Data>(); | ||
| 346 | } | ||
| 347 | |||
| 348 | struct Data { | ||
| 349 | u32_le pixel_format; | ||
| 350 | u32_le width; | ||
| 351 | u32_le height; | ||
| 352 | u32_le get_frame_timestamps; | ||
| 353 | u32_le usage; | ||
| 354 | }; | ||
| 355 | |||
| 356 | Data data; | ||
| 357 | }; | ||
| 358 | |||
| 359 | class IGBPDequeueBufferResponseParcel : public Parcel { | ||
| 360 | public: | ||
| 361 | explicit IGBPDequeueBufferResponseParcel(u32 slot_, Nvidia::MultiFence& multi_fence_) | ||
| 362 | : slot(slot_), multi_fence(multi_fence_) {} | ||
| 363 | |||
| 364 | protected: | ||
| 365 | void SerializeData() override { | ||
| 366 | Write(slot); | ||
| 367 | Write<u32_le>(1); | ||
| 368 | WriteObject(multi_fence); | ||
| 369 | Write<u32_le>(0); | ||
| 370 | } | ||
| 371 | |||
| 372 | u32_le slot; | ||
| 373 | Service::Nvidia::MultiFence multi_fence; | ||
| 374 | }; | ||
| 375 | |||
| 376 | class IGBPRequestBufferRequestParcel : public Parcel { | ||
| 377 | public: | ||
| 378 | explicit IGBPRequestBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { | ||
| 379 | Deserialize(); | ||
| 380 | } | ||
| 381 | |||
| 382 | void DeserializeData() override { | ||
| 383 | [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); | ||
| 384 | slot = Read<u32_le>(); | ||
| 385 | } | ||
| 386 | |||
| 387 | u32_le slot; | ||
| 388 | }; | ||
| 389 | |||
| 390 | class IGBPRequestBufferResponseParcel : public Parcel { | ||
| 391 | public: | ||
| 392 | explicit IGBPRequestBufferResponseParcel(NVFlinger::IGBPBuffer buffer_) : buffer(buffer_) {} | ||
| 393 | ~IGBPRequestBufferResponseParcel() override = default; | ||
| 394 | |||
| 395 | protected: | ||
| 396 | void SerializeData() override { | ||
| 397 | // TODO(Subv): Figure out what this value means, writing non-zero here will make libnx | ||
| 398 | // try to read an IGBPBuffer object from the parcel. | ||
| 399 | Write<u32_le>(1); | ||
| 400 | WriteObject(buffer); | ||
| 401 | Write<u32_le>(0); | ||
| 402 | } | ||
| 403 | |||
| 404 | NVFlinger::IGBPBuffer buffer; | ||
| 405 | }; | ||
| 406 | |||
| 407 | class IGBPQueueBufferRequestParcel : public Parcel { | ||
| 408 | public: | ||
| 409 | explicit IGBPQueueBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { | ||
| 410 | Deserialize(); | ||
| 411 | } | ||
| 412 | |||
| 413 | void DeserializeData() override { | ||
| 414 | [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); | ||
| 415 | data = Read<Data>(); | ||
| 416 | } | ||
| 417 | |||
| 418 | struct Data { | ||
| 419 | u32_le slot; | ||
| 420 | INSERT_PADDING_WORDS(3); | ||
| 421 | u32_le timestamp; | ||
| 422 | s32_le is_auto_timestamp; | ||
| 423 | s32_le crop_top; | ||
| 424 | s32_le crop_left; | ||
| 425 | s32_le crop_right; | ||
| 426 | s32_le crop_bottom; | ||
| 427 | s32_le scaling_mode; | ||
| 428 | NVFlinger::BufferQueue::BufferTransformFlags transform; | ||
| 429 | u32_le sticky_transform; | ||
| 430 | INSERT_PADDING_WORDS(1); | ||
| 431 | u32_le swap_interval; | ||
| 432 | Service::Nvidia::MultiFence multi_fence; | ||
| 433 | |||
| 434 | Common::Rectangle<int> GetCropRect() const { | ||
| 435 | return {crop_left, crop_top, crop_right, crop_bottom}; | ||
| 436 | } | ||
| 437 | }; | ||
| 438 | static_assert(sizeof(Data) == 96, "ParcelData has wrong size"); | ||
| 439 | |||
| 440 | Data data; | ||
| 441 | }; | ||
| 442 | |||
| 443 | class IGBPQueueBufferResponseParcel : public Parcel { | ||
| 444 | public: | ||
| 445 | explicit IGBPQueueBufferResponseParcel(u32 width, u32 height) { | ||
| 446 | data.width = width; | ||
| 447 | data.height = height; | ||
| 448 | } | ||
| 449 | ~IGBPQueueBufferResponseParcel() override = default; | ||
| 450 | |||
| 451 | protected: | ||
| 452 | void SerializeData() override { | ||
| 453 | Write(data); | ||
| 454 | } | ||
| 455 | |||
| 456 | private: | ||
| 457 | struct Data { | ||
| 458 | u32_le width; | ||
| 459 | u32_le height; | ||
| 460 | u32_le transform_hint; | ||
| 461 | u32_le num_pending_buffers; | ||
| 462 | u32_le status; | ||
| 463 | }; | ||
| 464 | static_assert(sizeof(Data) == 20, "ParcelData has wrong size"); | ||
| 465 | |||
| 466 | Data data{}; | ||
| 467 | }; | ||
| 468 | |||
| 469 | class IGBPQueryRequestParcel : public Parcel { | ||
| 470 | public: | ||
| 471 | explicit IGBPQueryRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { | ||
| 472 | Deserialize(); | ||
| 473 | } | ||
| 474 | |||
| 475 | void DeserializeData() override { | ||
| 476 | [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); | ||
| 477 | type = Read<u32_le>(); | ||
| 478 | } | ||
| 479 | |||
| 480 | u32 type; | ||
| 481 | }; | ||
| 482 | |||
| 483 | class IGBPQueryResponseParcel : public Parcel { | ||
| 484 | public: | ||
| 485 | explicit IGBPQueryResponseParcel(u32 value_) : value{value_} {} | ||
| 486 | ~IGBPQueryResponseParcel() override = default; | ||
| 487 | |||
| 488 | protected: | ||
| 489 | void SerializeData() override { | ||
| 490 | Write(value); | ||
| 491 | } | ||
| 492 | 66 | ||
| 493 | private: | 67 | private: |
| 494 | u32_le value; | 68 | const u32 magic = 2; |
| 69 | const u32 process_id = 1; | ||
| 70 | const u32 id; | ||
| 71 | const INSERT_PADDING_WORDS(3); | ||
| 72 | const std::array<u8, 8> dispdrv = {'d', 'i', 's', 'p', 'd', 'r', 'v', '\0'}; | ||
| 73 | const INSERT_PADDING_WORDS(2); | ||
| 495 | }; | 74 | }; |
| 75 | static_assert(sizeof(NativeWindow) == 0x28, "ParcelData has wrong size"); | ||
| 496 | 76 | ||
| 497 | class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> { | 77 | class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> { |
| 498 | public: | 78 | public: |
| 499 | explicit IHOSBinderDriver(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_) | 79 | explicit IHOSBinderDriver(Core::System& system_, NVFlinger::HosBinderDriverServer& server_) |
| 500 | : ServiceFramework{system_, "IHOSBinderDriver"}, nv_flinger(nv_flinger_) { | 80 | : ServiceFramework{system_, "IHOSBinderDriver"}, server(server_) { |
| 501 | static const FunctionInfo functions[] = { | 81 | static const FunctionInfo functions[] = { |
| 502 | {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, | 82 | {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, |
| 503 | {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"}, | 83 | {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"}, |
| @@ -508,147 +88,16 @@ public: | |||
| 508 | } | 88 | } |
| 509 | 89 | ||
| 510 | private: | 90 | private: |
| 511 | enum class TransactionId { | ||
| 512 | RequestBuffer = 1, | ||
| 513 | SetBufferCount = 2, | ||
| 514 | DequeueBuffer = 3, | ||
| 515 | DetachBuffer = 4, | ||
| 516 | DetachNextBuffer = 5, | ||
| 517 | AttachBuffer = 6, | ||
| 518 | QueueBuffer = 7, | ||
| 519 | CancelBuffer = 8, | ||
| 520 | Query = 9, | ||
| 521 | Connect = 10, | ||
| 522 | Disconnect = 11, | ||
| 523 | |||
| 524 | AllocateBuffers = 13, | ||
| 525 | SetPreallocatedBuffer = 14, | ||
| 526 | |||
| 527 | GetBufferHistory = 17 | ||
| 528 | }; | ||
| 529 | |||
| 530 | void TransactParcel(Kernel::HLERequestContext& ctx) { | 91 | void TransactParcel(Kernel::HLERequestContext& ctx) { |
| 531 | IPC::RequestParser rp{ctx}; | 92 | IPC::RequestParser rp{ctx}; |
| 532 | const u32 id = rp.Pop<u32>(); | 93 | const u32 id = rp.Pop<u32>(); |
| 533 | const auto transaction = static_cast<TransactionId>(rp.Pop<u32>()); | 94 | const auto transaction = static_cast<android::TransactionId>(rp.Pop<u32>()); |
| 534 | const u32 flags = rp.Pop<u32>(); | 95 | const u32 flags = rp.Pop<u32>(); |
| 535 | 96 | ||
| 536 | LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, | 97 | LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, |
| 537 | transaction, flags); | 98 | transaction, flags); |
| 538 | 99 | ||
| 539 | auto& buffer_queue = *nv_flinger.FindBufferQueue(id); | 100 | server.TryGetProducer(id)->Transact(ctx, transaction, flags); |
| 540 | |||
| 541 | switch (transaction) { | ||
| 542 | case TransactionId::Connect: { | ||
| 543 | IGBPConnectRequestParcel request{ctx.ReadBuffer()}; | ||
| 544 | IGBPConnectResponseParcel response{static_cast<u32>(DisplayResolution::UndockedWidth), | ||
| 545 | static_cast<u32>(DisplayResolution::UndockedHeight)}; | ||
| 546 | |||
| 547 | buffer_queue.Connect(); | ||
| 548 | |||
| 549 | ctx.WriteBuffer(response.Serialize()); | ||
| 550 | break; | ||
| 551 | } | ||
| 552 | case TransactionId::SetPreallocatedBuffer: { | ||
| 553 | IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()}; | ||
| 554 | |||
| 555 | buffer_queue.SetPreallocatedBuffer(request.data.slot, request.buffer_container.buffer); | ||
| 556 | |||
| 557 | IGBPSetPreallocatedBufferResponseParcel response{}; | ||
| 558 | ctx.WriteBuffer(response.Serialize()); | ||
| 559 | break; | ||
| 560 | } | ||
| 561 | case TransactionId::DequeueBuffer: { | ||
| 562 | IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()}; | ||
| 563 | const u32 width{request.data.width}; | ||
| 564 | const u32 height{request.data.height}; | ||
| 565 | |||
| 566 | do { | ||
| 567 | if (auto result = buffer_queue.DequeueBuffer(width, height); result) { | ||
| 568 | // Buffer is available | ||
| 569 | IGBPDequeueBufferResponseParcel response{result->first, *result->second}; | ||
| 570 | ctx.WriteBuffer(response.Serialize()); | ||
| 571 | break; | ||
| 572 | } | ||
| 573 | } while (buffer_queue.IsConnected()); | ||
| 574 | |||
| 575 | break; | ||
| 576 | } | ||
| 577 | case TransactionId::RequestBuffer: { | ||
| 578 | IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()}; | ||
| 579 | |||
| 580 | auto& buffer = buffer_queue.RequestBuffer(request.slot); | ||
| 581 | IGBPRequestBufferResponseParcel response{buffer}; | ||
| 582 | ctx.WriteBuffer(response.Serialize()); | ||
| 583 | |||
| 584 | break; | ||
| 585 | } | ||
| 586 | case TransactionId::QueueBuffer: { | ||
| 587 | IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()}; | ||
| 588 | |||
| 589 | buffer_queue.QueueBuffer(request.data.slot, request.data.transform, | ||
| 590 | request.data.GetCropRect(), request.data.swap_interval, | ||
| 591 | request.data.multi_fence); | ||
| 592 | |||
| 593 | IGBPQueueBufferResponseParcel response{1280, 720}; | ||
| 594 | ctx.WriteBuffer(response.Serialize()); | ||
| 595 | break; | ||
| 596 | } | ||
| 597 | case TransactionId::Query: { | ||
| 598 | IGBPQueryRequestParcel request{ctx.ReadBuffer()}; | ||
| 599 | |||
| 600 | const u32 value = | ||
| 601 | buffer_queue.Query(static_cast<NVFlinger::BufferQueue::QueryType>(request.type)); | ||
| 602 | |||
| 603 | IGBPQueryResponseParcel response{value}; | ||
| 604 | ctx.WriteBuffer(response.Serialize()); | ||
| 605 | break; | ||
| 606 | } | ||
| 607 | case TransactionId::CancelBuffer: { | ||
| 608 | IGBPCancelBufferRequestParcel request{ctx.ReadBuffer()}; | ||
| 609 | |||
| 610 | buffer_queue.CancelBuffer(request.data.slot, request.data.multi_fence); | ||
| 611 | |||
| 612 | IGBPCancelBufferResponseParcel response{}; | ||
| 613 | ctx.WriteBuffer(response.Serialize()); | ||
| 614 | break; | ||
| 615 | } | ||
| 616 | case TransactionId::Disconnect: { | ||
| 617 | LOG_WARNING(Service_VI, "(STUBBED) called, transaction=Disconnect"); | ||
| 618 | const auto buffer = ctx.ReadBuffer(); | ||
| 619 | |||
| 620 | buffer_queue.Disconnect(); | ||
| 621 | |||
| 622 | IGBPEmptyResponseParcel response{}; | ||
| 623 | ctx.WriteBuffer(response.Serialize()); | ||
| 624 | break; | ||
| 625 | } | ||
| 626 | case TransactionId::DetachBuffer: { | ||
| 627 | const auto buffer = ctx.ReadBuffer(); | ||
| 628 | |||
| 629 | IGBPEmptyResponseParcel response{}; | ||
| 630 | ctx.WriteBuffer(response.Serialize()); | ||
| 631 | break; | ||
| 632 | } | ||
| 633 | case TransactionId::SetBufferCount: { | ||
| 634 | LOG_WARNING(Service_VI, "(STUBBED) called, transaction=SetBufferCount"); | ||
| 635 | [[maybe_unused]] const auto buffer = ctx.ReadBuffer(); | ||
| 636 | |||
| 637 | IGBPEmptyResponseParcel response{}; | ||
| 638 | ctx.WriteBuffer(response.Serialize()); | ||
| 639 | break; | ||
| 640 | } | ||
| 641 | case TransactionId::GetBufferHistory: { | ||
| 642 | LOG_WARNING(Service_VI, "(STUBBED) called, transaction=GetBufferHistory"); | ||
| 643 | [[maybe_unused]] const auto buffer = ctx.ReadBuffer(); | ||
| 644 | |||
| 645 | IGBPEmptyResponseParcel response{}; | ||
| 646 | ctx.WriteBuffer(response.Serialize()); | ||
| 647 | break; | ||
| 648 | } | ||
| 649 | default: | ||
| 650 | ASSERT_MSG(false, "Unimplemented"); | ||
| 651 | } | ||
| 652 | 101 | ||
| 653 | IPC::ResponseBuilder rb{ctx, 2}; | 102 | IPC::ResponseBuilder rb{ctx, 2}; |
| 654 | rb.Push(ResultSuccess); | 103 | rb.Push(ResultSuccess); |
| @@ -674,13 +123,13 @@ private: | |||
| 674 | 123 | ||
| 675 | LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown); | 124 | LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown); |
| 676 | 125 | ||
| 677 | // TODO(Subv): Find out what this actually is. | ||
| 678 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 126 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 679 | rb.Push(ResultSuccess); | 127 | rb.Push(ResultSuccess); |
| 680 | rb.PushCopyObjects(nv_flinger.FindBufferQueue(id)->GetBufferWaitEvent()); | 128 | rb.PushCopyObjects(server.TryGetProducer(id)->GetNativeHandle()); |
| 681 | } | 129 | } |
| 682 | 130 | ||
| 683 | NVFlinger::NVFlinger& nv_flinger; | 131 | private: |
| 132 | NVFlinger::HosBinderDriverServer& server; | ||
| 684 | }; | 133 | }; |
| 685 | 134 | ||
| 686 | class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> { | 135 | class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> { |
| @@ -937,7 +386,40 @@ private: | |||
| 937 | 386 | ||
| 938 | class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> { | 387 | class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> { |
| 939 | public: | 388 | public: |
| 940 | explicit IApplicationDisplayService(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_); | 389 | IApplicationDisplayService(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, |
| 390 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server_) | ||
| 391 | : ServiceFramework{system_, "IApplicationDisplayService"}, nv_flinger{nv_flinger_}, | ||
| 392 | hos_binder_driver_server{hos_binder_driver_server_} { | ||
| 393 | |||
| 394 | static const FunctionInfo functions[] = { | ||
| 395 | {100, &IApplicationDisplayService::GetRelayService, "GetRelayService"}, | ||
| 396 | {101, &IApplicationDisplayService::GetSystemDisplayService, "GetSystemDisplayService"}, | ||
| 397 | {102, &IApplicationDisplayService::GetManagerDisplayService, | ||
| 398 | "GetManagerDisplayService"}, | ||
| 399 | {103, &IApplicationDisplayService::GetIndirectDisplayTransactionService, | ||
| 400 | "GetIndirectDisplayTransactionService"}, | ||
| 401 | {1000, &IApplicationDisplayService::ListDisplays, "ListDisplays"}, | ||
| 402 | {1010, &IApplicationDisplayService::OpenDisplay, "OpenDisplay"}, | ||
| 403 | {1011, &IApplicationDisplayService::OpenDefaultDisplay, "OpenDefaultDisplay"}, | ||
| 404 | {1020, &IApplicationDisplayService::CloseDisplay, "CloseDisplay"}, | ||
| 405 | {1101, &IApplicationDisplayService::SetDisplayEnabled, "SetDisplayEnabled"}, | ||
| 406 | {1102, &IApplicationDisplayService::GetDisplayResolution, "GetDisplayResolution"}, | ||
| 407 | {2020, &IApplicationDisplayService::OpenLayer, "OpenLayer"}, | ||
| 408 | {2021, &IApplicationDisplayService::CloseLayer, "CloseLayer"}, | ||
| 409 | {2030, &IApplicationDisplayService::CreateStrayLayer, "CreateStrayLayer"}, | ||
| 410 | {2031, &IApplicationDisplayService::DestroyStrayLayer, "DestroyStrayLayer"}, | ||
| 411 | {2101, &IApplicationDisplayService::SetLayerScalingMode, "SetLayerScalingMode"}, | ||
| 412 | {2102, &IApplicationDisplayService::ConvertScalingMode, "ConvertScalingMode"}, | ||
| 413 | {2450, &IApplicationDisplayService::GetIndirectLayerImageMap, | ||
| 414 | "GetIndirectLayerImageMap"}, | ||
| 415 | {2451, nullptr, "GetIndirectLayerImageCropMap"}, | ||
| 416 | {2460, &IApplicationDisplayService::GetIndirectLayerImageRequiredMemoryInfo, | ||
| 417 | "GetIndirectLayerImageRequiredMemoryInfo"}, | ||
| 418 | {5202, &IApplicationDisplayService::GetDisplayVsyncEvent, "GetDisplayVsyncEvent"}, | ||
| 419 | {5203, nullptr, "GetDisplayVsyncEventForDebug"}, | ||
| 420 | }; | ||
| 421 | RegisterHandlers(functions); | ||
| 422 | } | ||
| 941 | 423 | ||
| 942 | private: | 424 | private: |
| 943 | enum class ConvertedScaleMode : u64 { | 425 | enum class ConvertedScaleMode : u64 { |
| @@ -961,7 +443,7 @@ private: | |||
| 961 | 443 | ||
| 962 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 444 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 963 | rb.Push(ResultSuccess); | 445 | rb.Push(ResultSuccess); |
| 964 | rb.PushIpcInterface<IHOSBinderDriver>(system, nv_flinger); | 446 | rb.PushIpcInterface<IHOSBinderDriver>(system, hos_binder_driver_server); |
| 965 | } | 447 | } |
| 966 | 448 | ||
| 967 | void GetSystemDisplayService(Kernel::HLERequestContext& ctx) { | 449 | void GetSystemDisplayService(Kernel::HLERequestContext& ctx) { |
| @@ -985,7 +467,7 @@ private: | |||
| 985 | 467 | ||
| 986 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 468 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 987 | rb.Push(ResultSuccess); | 469 | rb.Push(ResultSuccess); |
| 988 | rb.PushIpcInterface<IHOSBinderDriver>(system, nv_flinger); | 470 | rb.PushIpcInterface<IHOSBinderDriver>(system, hos_binder_driver_server); |
| 989 | } | 471 | } |
| 990 | 472 | ||
| 991 | void OpenDisplay(Kernel::HLERequestContext& ctx) { | 473 | void OpenDisplay(Kernel::HLERequestContext& ctx) { |
| @@ -1089,7 +571,7 @@ private: | |||
| 1089 | void ListDisplays(Kernel::HLERequestContext& ctx) { | 571 | void ListDisplays(Kernel::HLERequestContext& ctx) { |
| 1090 | LOG_WARNING(Service_VI, "(STUBBED) called"); | 572 | LOG_WARNING(Service_VI, "(STUBBED) called"); |
| 1091 | 573 | ||
| 1092 | DisplayInfo display_info; | 574 | const DisplayInfo display_info; |
| 1093 | ctx.WriteBuffer(&display_info, sizeof(DisplayInfo)); | 575 | ctx.WriteBuffer(&display_info, sizeof(DisplayInfo)); |
| 1094 | IPC::ResponseBuilder rb{ctx, 4}; | 576 | IPC::ResponseBuilder rb{ctx, 4}; |
| 1095 | rb.Push(ResultSuccess); | 577 | rb.Push(ResultSuccess); |
| @@ -1124,8 +606,8 @@ private: | |||
| 1124 | return; | 606 | return; |
| 1125 | } | 607 | } |
| 1126 | 608 | ||
| 1127 | NativeWindow native_window{*buffer_queue_id}; | 609 | const auto parcel = android::Parcel{NativeWindow{*buffer_queue_id}}; |
| 1128 | const auto buffer_size = ctx.WriteBuffer(native_window.Serialize()); | 610 | const auto buffer_size = ctx.WriteBuffer(parcel.Serialize()); |
| 1129 | 611 | ||
| 1130 | IPC::ResponseBuilder rb{ctx, 4}; | 612 | IPC::ResponseBuilder rb{ctx, 4}; |
| 1131 | rb.Push(ResultSuccess); | 613 | rb.Push(ResultSuccess); |
| @@ -1170,8 +652,8 @@ private: | |||
| 1170 | return; | 652 | return; |
| 1171 | } | 653 | } |
| 1172 | 654 | ||
| 1173 | NativeWindow native_window{*buffer_queue_id}; | 655 | const auto parcel = android::Parcel{NativeWindow{*buffer_queue_id}}; |
| 1174 | const auto buffer_size = ctx.WriteBuffer(native_window.Serialize()); | 656 | const auto buffer_size = ctx.WriteBuffer(parcel.Serialize()); |
| 1175 | 657 | ||
| 1176 | IPC::ResponseBuilder rb{ctx, 6}; | 658 | IPC::ResponseBuilder rb{ctx, 6}; |
| 1177 | rb.Push(ResultSuccess); | 659 | rb.Push(ResultSuccess); |
| @@ -1287,39 +769,9 @@ private: | |||
| 1287 | } | 769 | } |
| 1288 | 770 | ||
| 1289 | NVFlinger::NVFlinger& nv_flinger; | 771 | NVFlinger::NVFlinger& nv_flinger; |
| 772 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server; | ||
| 1290 | }; | 773 | }; |
| 1291 | 774 | ||
| 1292 | IApplicationDisplayService::IApplicationDisplayService(Core::System& system_, | ||
| 1293 | NVFlinger::NVFlinger& nv_flinger_) | ||
| 1294 | : ServiceFramework{system_, "IApplicationDisplayService"}, nv_flinger{nv_flinger_} { | ||
| 1295 | static const FunctionInfo functions[] = { | ||
| 1296 | {100, &IApplicationDisplayService::GetRelayService, "GetRelayService"}, | ||
| 1297 | {101, &IApplicationDisplayService::GetSystemDisplayService, "GetSystemDisplayService"}, | ||
| 1298 | {102, &IApplicationDisplayService::GetManagerDisplayService, "GetManagerDisplayService"}, | ||
| 1299 | {103, &IApplicationDisplayService::GetIndirectDisplayTransactionService, | ||
| 1300 | "GetIndirectDisplayTransactionService"}, | ||
| 1301 | {1000, &IApplicationDisplayService::ListDisplays, "ListDisplays"}, | ||
| 1302 | {1010, &IApplicationDisplayService::OpenDisplay, "OpenDisplay"}, | ||
| 1303 | {1011, &IApplicationDisplayService::OpenDefaultDisplay, "OpenDefaultDisplay"}, | ||
| 1304 | {1020, &IApplicationDisplayService::CloseDisplay, "CloseDisplay"}, | ||
| 1305 | {1101, &IApplicationDisplayService::SetDisplayEnabled, "SetDisplayEnabled"}, | ||
| 1306 | {1102, &IApplicationDisplayService::GetDisplayResolution, "GetDisplayResolution"}, | ||
| 1307 | {2020, &IApplicationDisplayService::OpenLayer, "OpenLayer"}, | ||
| 1308 | {2021, &IApplicationDisplayService::CloseLayer, "CloseLayer"}, | ||
| 1309 | {2030, &IApplicationDisplayService::CreateStrayLayer, "CreateStrayLayer"}, | ||
| 1310 | {2031, &IApplicationDisplayService::DestroyStrayLayer, "DestroyStrayLayer"}, | ||
| 1311 | {2101, &IApplicationDisplayService::SetLayerScalingMode, "SetLayerScalingMode"}, | ||
| 1312 | {2102, &IApplicationDisplayService::ConvertScalingMode, "ConvertScalingMode"}, | ||
| 1313 | {2450, &IApplicationDisplayService::GetIndirectLayerImageMap, "GetIndirectLayerImageMap"}, | ||
| 1314 | {2451, nullptr, "GetIndirectLayerImageCropMap"}, | ||
| 1315 | {2460, &IApplicationDisplayService::GetIndirectLayerImageRequiredMemoryInfo, | ||
| 1316 | "GetIndirectLayerImageRequiredMemoryInfo"}, | ||
| 1317 | {5202, &IApplicationDisplayService::GetDisplayVsyncEvent, "GetDisplayVsyncEvent"}, | ||
| 1318 | {5203, nullptr, "GetDisplayVsyncEventForDebug"}, | ||
| 1319 | }; | ||
| 1320 | RegisterHandlers(functions); | ||
| 1321 | } | ||
| 1322 | |||
| 1323 | static bool IsValidServiceAccess(Permission permission, Policy policy) { | 775 | static bool IsValidServiceAccess(Permission permission, Policy policy) { |
| 1324 | if (permission == Permission::User) { | 776 | if (permission == Permission::User) { |
| 1325 | return policy == Policy::User; | 777 | return policy == Policy::User; |
| @@ -1333,7 +785,9 @@ static bool IsValidServiceAccess(Permission permission, Policy policy) { | |||
| 1333 | } | 785 | } |
| 1334 | 786 | ||
| 1335 | void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& system, | 787 | void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& system, |
| 1336 | NVFlinger::NVFlinger& nv_flinger, Permission permission) { | 788 | NVFlinger::NVFlinger& nv_flinger, |
| 789 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server, | ||
| 790 | Permission permission) { | ||
| 1337 | IPC::RequestParser rp{ctx}; | 791 | IPC::RequestParser rp{ctx}; |
| 1338 | const auto policy = rp.PopEnum<Policy>(); | 792 | const auto policy = rp.PopEnum<Policy>(); |
| 1339 | 793 | ||
| @@ -1346,14 +800,18 @@ void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& | |||
| 1346 | 800 | ||
| 1347 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 801 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 1348 | rb.Push(ResultSuccess); | 802 | rb.Push(ResultSuccess); |
| 1349 | rb.PushIpcInterface<IApplicationDisplayService>(system, nv_flinger); | 803 | rb.PushIpcInterface<IApplicationDisplayService>(system, nv_flinger, hos_binder_driver_server); |
| 1350 | } | 804 | } |
| 1351 | 805 | ||
| 1352 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system, | 806 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system, |
| 1353 | NVFlinger::NVFlinger& nv_flinger) { | 807 | NVFlinger::NVFlinger& nv_flinger, |
| 1354 | std::make_shared<VI_M>(system, nv_flinger)->InstallAsService(service_manager); | 808 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server) { |
| 1355 | std::make_shared<VI_S>(system, nv_flinger)->InstallAsService(service_manager); | 809 | std::make_shared<VI_M>(system, nv_flinger, hos_binder_driver_server) |
| 1356 | std::make_shared<VI_U>(system, nv_flinger)->InstallAsService(service_manager); | 810 | ->InstallAsService(service_manager); |
| 811 | std::make_shared<VI_S>(system, nv_flinger, hos_binder_driver_server) | ||
| 812 | ->InstallAsService(service_manager); | ||
| 813 | std::make_shared<VI_U>(system, nv_flinger, hos_binder_driver_server) | ||
| 814 | ->InstallAsService(service_manager); | ||
| 1357 | } | 815 | } |
| 1358 | 816 | ||
| 1359 | } // namespace Service::VI | 817 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h index 2fd7f8e61..d68f2646b 100644 --- a/src/core/hle/service/vi/vi.h +++ b/src/core/hle/service/vi/vi.h | |||
| @@ -15,8 +15,9 @@ class HLERequestContext; | |||
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | namespace Service::NVFlinger { | 17 | namespace Service::NVFlinger { |
| 18 | class HosBinderDriverServer; | ||
| 18 | class NVFlinger; | 19 | class NVFlinger; |
| 19 | } | 20 | } // namespace Service::NVFlinger |
| 20 | 21 | ||
| 21 | namespace Service::SM { | 22 | namespace Service::SM { |
| 22 | class ServiceManager; | 23 | class ServiceManager; |
| @@ -47,11 +48,14 @@ enum class Policy { | |||
| 47 | 48 | ||
| 48 | namespace detail { | 49 | namespace detail { |
| 49 | void GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& system, | 50 | void GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& system, |
| 50 | NVFlinger::NVFlinger& nv_flinger, Permission permission); | 51 | NVFlinger::NVFlinger& nv_flinger, |
| 52 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server, | ||
| 53 | Permission permission); | ||
| 51 | } // namespace detail | 54 | } // namespace detail |
| 52 | 55 | ||
| 53 | /// Registers all VI services with the specified service manager. | 56 | /// Registers all VI services with the specified service manager. |
| 54 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system, | 57 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system, |
| 55 | NVFlinger::NVFlinger& nv_flinger); | 58 | NVFlinger::NVFlinger& nv_flinger, |
| 59 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server); | ||
| 56 | 60 | ||
| 57 | } // namespace Service::VI | 61 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/vi_m.cpp b/src/core/hle/service/vi/vi_m.cpp index 87db1c416..be0255f3d 100644 --- a/src/core/hle/service/vi/vi_m.cpp +++ b/src/core/hle/service/vi/vi_m.cpp | |||
| @@ -8,8 +8,10 @@ | |||
| 8 | 8 | ||
| 9 | namespace Service::VI { | 9 | namespace Service::VI { |
| 10 | 10 | ||
| 11 | VI_M::VI_M(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_) | 11 | VI_M::VI_M(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, |
| 12 | : ServiceFramework{system_, "vi:m"}, nv_flinger{nv_flinger_} { | 12 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server_) |
| 13 | : ServiceFramework{system_, "vi:m"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{ | ||
| 14 | hos_binder_driver_server_} { | ||
| 13 | static const FunctionInfo functions[] = { | 15 | static const FunctionInfo functions[] = { |
| 14 | {2, &VI_M::GetDisplayService, "GetDisplayService"}, | 16 | {2, &VI_M::GetDisplayService, "GetDisplayService"}, |
| 15 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, | 17 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, |
| @@ -22,7 +24,8 @@ VI_M::~VI_M() = default; | |||
| 22 | void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) { | 24 | void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) { |
| 23 | LOG_DEBUG(Service_VI, "called"); | 25 | LOG_DEBUG(Service_VI, "called"); |
| 24 | 26 | ||
| 25 | detail::GetDisplayServiceImpl(ctx, system, nv_flinger, Permission::Manager); | 27 | detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server, |
| 28 | Permission::Manager); | ||
| 26 | } | 29 | } |
| 27 | 30 | ||
| 28 | } // namespace Service::VI | 31 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/vi_m.h b/src/core/hle/service/vi/vi_m.h index d79c41beb..efbd34e09 100644 --- a/src/core/hle/service/vi/vi_m.h +++ b/src/core/hle/service/vi/vi_m.h | |||
| @@ -15,20 +15,23 @@ class HLERequestContext; | |||
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | namespace Service::NVFlinger { | 17 | namespace Service::NVFlinger { |
| 18 | class HosBinderDriverServer; | ||
| 18 | class NVFlinger; | 19 | class NVFlinger; |
| 19 | } | 20 | } // namespace Service::NVFlinger |
| 20 | 21 | ||
| 21 | namespace Service::VI { | 22 | namespace Service::VI { |
| 22 | 23 | ||
| 23 | class VI_M final : public ServiceFramework<VI_M> { | 24 | class VI_M final : public ServiceFramework<VI_M> { |
| 24 | public: | 25 | public: |
| 25 | explicit VI_M(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_); | 26 | explicit VI_M(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, |
| 27 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server_); | ||
| 26 | ~VI_M() override; | 28 | ~VI_M() override; |
| 27 | 29 | ||
| 28 | private: | 30 | private: |
| 29 | void GetDisplayService(Kernel::HLERequestContext& ctx); | 31 | void GetDisplayService(Kernel::HLERequestContext& ctx); |
| 30 | 32 | ||
| 31 | NVFlinger::NVFlinger& nv_flinger; | 33 | NVFlinger::NVFlinger& nv_flinger; |
| 34 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server; | ||
| 32 | }; | 35 | }; |
| 33 | 36 | ||
| 34 | } // namespace Service::VI | 37 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/vi_s.cpp b/src/core/hle/service/vi/vi_s.cpp index 5cd22f7df..7996a6811 100644 --- a/src/core/hle/service/vi/vi_s.cpp +++ b/src/core/hle/service/vi/vi_s.cpp | |||
| @@ -8,8 +8,10 @@ | |||
| 8 | 8 | ||
| 9 | namespace Service::VI { | 9 | namespace Service::VI { |
| 10 | 10 | ||
| 11 | VI_S::VI_S(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_) | 11 | VI_S::VI_S(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, |
| 12 | : ServiceFramework{system_, "vi:s"}, nv_flinger{nv_flinger_} { | 12 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server_) |
| 13 | : ServiceFramework{system_, "vi:s"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{ | ||
| 14 | hos_binder_driver_server_} { | ||
| 13 | static const FunctionInfo functions[] = { | 15 | static const FunctionInfo functions[] = { |
| 14 | {1, &VI_S::GetDisplayService, "GetDisplayService"}, | 16 | {1, &VI_S::GetDisplayService, "GetDisplayService"}, |
| 15 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, | 17 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, |
| @@ -22,7 +24,8 @@ VI_S::~VI_S() = default; | |||
| 22 | void VI_S::GetDisplayService(Kernel::HLERequestContext& ctx) { | 24 | void VI_S::GetDisplayService(Kernel::HLERequestContext& ctx) { |
| 23 | LOG_DEBUG(Service_VI, "called"); | 25 | LOG_DEBUG(Service_VI, "called"); |
| 24 | 26 | ||
| 25 | detail::GetDisplayServiceImpl(ctx, system, nv_flinger, Permission::System); | 27 | detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server, |
| 28 | Permission::System); | ||
| 26 | } | 29 | } |
| 27 | 30 | ||
| 28 | } // namespace Service::VI | 31 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/vi_s.h b/src/core/hle/service/vi/vi_s.h index 5f1f8f290..3812c5061 100644 --- a/src/core/hle/service/vi/vi_s.h +++ b/src/core/hle/service/vi/vi_s.h | |||
| @@ -15,20 +15,23 @@ class HLERequestContext; | |||
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | namespace Service::NVFlinger { | 17 | namespace Service::NVFlinger { |
| 18 | class HosBinderDriverServer; | ||
| 18 | class NVFlinger; | 19 | class NVFlinger; |
| 19 | } | 20 | } // namespace Service::NVFlinger |
| 20 | 21 | ||
| 21 | namespace Service::VI { | 22 | namespace Service::VI { |
| 22 | 23 | ||
| 23 | class VI_S final : public ServiceFramework<VI_S> { | 24 | class VI_S final : public ServiceFramework<VI_S> { |
| 24 | public: | 25 | public: |
| 25 | explicit VI_S(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_); | 26 | explicit VI_S(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, |
| 27 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server_); | ||
| 26 | ~VI_S() override; | 28 | ~VI_S() override; |
| 27 | 29 | ||
| 28 | private: | 30 | private: |
| 29 | void GetDisplayService(Kernel::HLERequestContext& ctx); | 31 | void GetDisplayService(Kernel::HLERequestContext& ctx); |
| 30 | 32 | ||
| 31 | NVFlinger::NVFlinger& nv_flinger; | 33 | NVFlinger::NVFlinger& nv_flinger; |
| 34 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server; | ||
| 32 | }; | 35 | }; |
| 33 | 36 | ||
| 34 | } // namespace Service::VI | 37 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/vi_u.cpp b/src/core/hle/service/vi/vi_u.cpp index 0079d51f0..57c888313 100644 --- a/src/core/hle/service/vi/vi_u.cpp +++ b/src/core/hle/service/vi/vi_u.cpp | |||
| @@ -8,8 +8,10 @@ | |||
| 8 | 8 | ||
| 9 | namespace Service::VI { | 9 | namespace Service::VI { |
| 10 | 10 | ||
| 11 | VI_U::VI_U(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_) | 11 | VI_U::VI_U(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, |
| 12 | : ServiceFramework{system_, "vi:u"}, nv_flinger{nv_flinger_} { | 12 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server_) |
| 13 | : ServiceFramework{system_, "vi:u"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{ | ||
| 14 | hos_binder_driver_server_} { | ||
| 13 | static const FunctionInfo functions[] = { | 15 | static const FunctionInfo functions[] = { |
| 14 | {0, &VI_U::GetDisplayService, "GetDisplayService"}, | 16 | {0, &VI_U::GetDisplayService, "GetDisplayService"}, |
| 15 | {1, nullptr, "GetDisplayServiceWithProxyNameExchange"}, | 17 | {1, nullptr, "GetDisplayServiceWithProxyNameExchange"}, |
| @@ -22,7 +24,8 @@ VI_U::~VI_U() = default; | |||
| 22 | void VI_U::GetDisplayService(Kernel::HLERequestContext& ctx) { | 24 | void VI_U::GetDisplayService(Kernel::HLERequestContext& ctx) { |
| 23 | LOG_DEBUG(Service_VI, "called"); | 25 | LOG_DEBUG(Service_VI, "called"); |
| 24 | 26 | ||
| 25 | detail::GetDisplayServiceImpl(ctx, system, nv_flinger, Permission::User); | 27 | detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server, |
| 28 | Permission::User); | ||
| 26 | } | 29 | } |
| 27 | 30 | ||
| 28 | } // namespace Service::VI | 31 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/vi_u.h b/src/core/hle/service/vi/vi_u.h index 8e3885c73..b08e56576 100644 --- a/src/core/hle/service/vi/vi_u.h +++ b/src/core/hle/service/vi/vi_u.h | |||
| @@ -15,20 +15,23 @@ class HLERequestContext; | |||
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | namespace Service::NVFlinger { | 17 | namespace Service::NVFlinger { |
| 18 | class HosBinderDriverServer; | ||
| 18 | class NVFlinger; | 19 | class NVFlinger; |
| 19 | } | 20 | } // namespace Service::NVFlinger |
| 20 | 21 | ||
| 21 | namespace Service::VI { | 22 | namespace Service::VI { |
| 22 | 23 | ||
| 23 | class VI_U final : public ServiceFramework<VI_U> { | 24 | class VI_U final : public ServiceFramework<VI_U> { |
| 24 | public: | 25 | public: |
| 25 | explicit VI_U(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_); | 26 | explicit VI_U(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, |
| 27 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server_); | ||
| 26 | ~VI_U() override; | 28 | ~VI_U() override; |
| 27 | 29 | ||
| 28 | private: | 30 | private: |
| 29 | void GetDisplayService(Kernel::HLERequestContext& ctx); | 31 | void GetDisplayService(Kernel::HLERequestContext& ctx); |
| 30 | 32 | ||
| 31 | NVFlinger::NVFlinger& nv_flinger; | 33 | NVFlinger::NVFlinger& nv_flinger; |
| 34 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server; | ||
| 32 | }; | 35 | }; |
| 33 | 36 | ||
| 34 | } // namespace Service::VI | 37 | } // namespace Service::VI |