summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/vi/vi.cpp79
-rw-r--r--src/core/hle/service/vi/vi.h9
2 files changed, 85 insertions, 3 deletions
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 93ebbe75f..6e1bf481b 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -361,7 +361,7 @@ public:
361 static const FunctionInfo functions[] = { 361 static const FunctionInfo functions[] = {
362 {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, 362 {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"},
363 {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"}, 363 {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"},
364 {2, nullptr, "GetNativeHandle"}, 364 {2, &IHOSBinderDriver::GetNativeHandle, "GetNativeHandle"},
365 {3, nullptr, "TransactParcelAuto"}, 365 {3, nullptr, "TransactParcelAuto"},
366 }; 366 };
367 RegisterHandlers(functions); 367 RegisterHandlers(functions);
@@ -463,6 +463,21 @@ private:
463 rb.Push(RESULT_SUCCESS); 463 rb.Push(RESULT_SUCCESS);
464 } 464 }
465 465
466 void GetNativeHandle(Kernel::HLERequestContext& ctx) {
467 IPC::RequestParser rp{ctx};
468 u32 id = rp.Pop<u32>();
469 u32 unknown = rp.Pop<u32>();
470
471 auto buffer_queue = nv_flinger->GetBufferQueue(id);
472
473 // TODO(Subv): Find out what this actually is.
474
475 LOG_WARNING(Service, "(STUBBED) called id=%u, unknown=%08X", id, unknown);
476 IPC::RequestBuilder rb{ctx, 2, 1};
477 rb.Push(RESULT_SUCCESS);
478 rb.PushCopyObjects(buffer_queue->GetNativeHandle());
479 }
480
466 std::shared_ptr<NVFlinger> nv_flinger; 481 std::shared_ptr<NVFlinger> nv_flinger;
467}; 482};
468 483
@@ -565,6 +580,15 @@ void IApplicationDisplayService::GetManagerDisplayService(Kernel::HLERequestCont
565 rb.PushIpcInterface<IManagerDisplayService>(nv_flinger); 580 rb.PushIpcInterface<IManagerDisplayService>(nv_flinger);
566} 581}
567 582
583void IApplicationDisplayService::GetIndirectDisplayTransactionService(
584 Kernel::HLERequestContext& ctx) {
585 LOG_WARNING(Service, "(STUBBED) called");
586
587 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1};
588 rb.Push(RESULT_SUCCESS);
589 rb.PushIpcInterface<IHOSBinderDriver>(nv_flinger);
590}
591
568void IApplicationDisplayService::OpenDisplay(Kernel::HLERequestContext& ctx) { 592void IApplicationDisplayService::OpenDisplay(Kernel::HLERequestContext& ctx) {
569 LOG_WARNING(Service, "(STUBBED) called"); 593 LOG_WARNING(Service, "(STUBBED) called");
570 IPC::RequestParser rp{ctx}; 594 IPC::RequestParser rp{ctx};
@@ -580,6 +604,15 @@ void IApplicationDisplayService::OpenDisplay(Kernel::HLERequestContext& ctx) {
580 rb.Push<u64>(nv_flinger->OpenDisplay(name)); 604 rb.Push<u64>(nv_flinger->OpenDisplay(name));
581} 605}
582 606
607void IApplicationDisplayService::CloseDisplay(Kernel::HLERequestContext& ctx) {
608 LOG_WARNING(Service, "(STUBBED) called");
609 IPC::RequestParser rp{ctx};
610 u64 display_id = rp.Pop<u64>();
611
612 IPC::RequestBuilder rb = rp.MakeBuilder(4, 0, 0, 0);
613 rb.Push(RESULT_SUCCESS);
614}
615
583void IApplicationDisplayService::OpenLayer(Kernel::HLERequestContext& ctx) { 616void IApplicationDisplayService::OpenLayer(Kernel::HLERequestContext& ctx) {
584 LOG_WARNING(Service, "(STUBBED) called"); 617 LOG_WARNING(Service, "(STUBBED) called");
585 IPC::RequestParser rp{ctx}; 618 IPC::RequestParser rp{ctx};
@@ -605,6 +638,40 @@ void IApplicationDisplayService::OpenLayer(Kernel::HLERequestContext& ctx) {
605 rb.Push<u64>(data.size()); 638 rb.Push<u64>(data.size());
606} 639}
607 640
641void IApplicationDisplayService::CreateStrayLayer(Kernel::HLERequestContext& ctx) {
642 LOG_WARNING(Service, "(STUBBED) called");
643
644 IPC::RequestParser rp{ctx};
645 u32 flags = rp.Pop<u32>();
646 u64 display_id = rp.Pop<u64>();
647
648 auto& buffer = ctx.BufferDescriptorB()[0];
649
650 // TODO(Subv): What's the difference between a Stray and a Managed layer?
651
652 u64 layer_id = nv_flinger->CreateLayer(display_id);
653 u32 buffer_queue_id = nv_flinger->GetBufferQueueId(display_id, layer_id);
654
655 NativeWindow native_window{buffer_queue_id};
656 auto data = native_window.Serialize();
657 Memory::WriteBlock(buffer.Address(), data.data(), data.size());
658
659 IPC::RequestBuilder rb = rp.MakeBuilder(6, 0, 0, 0);
660 rb.Push(RESULT_SUCCESS);
661 rb.Push(layer_id);
662 rb.Push<u64>(data.size());
663}
664
665void IApplicationDisplayService::DestroyStrayLayer(Kernel::HLERequestContext& ctx) {
666 LOG_WARNING(Service, "(STUBBED) called");
667
668 IPC::RequestParser rp{ctx};
669 u64 layer_id = rp.Pop<u64>();
670
671 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0, 0, 0);
672 rb.Push(RESULT_SUCCESS);
673}
674
608void IApplicationDisplayService::SetLayerScalingMode(Kernel::HLERequestContext& ctx) { 675void IApplicationDisplayService::SetLayerScalingMode(Kernel::HLERequestContext& ctx) {
609 LOG_WARNING(Service, "(STUBBED) called"); 676 LOG_WARNING(Service, "(STUBBED) called");
610 IPC::RequestParser rp{ctx}; 677 IPC::RequestParser rp{ctx};
@@ -633,11 +700,15 @@ IApplicationDisplayService::IApplicationDisplayService(std::shared_ptr<NVFlinger
633 {100, &IApplicationDisplayService::GetRelayService, "GetRelayService"}, 700 {100, &IApplicationDisplayService::GetRelayService, "GetRelayService"},
634 {101, &IApplicationDisplayService::GetSystemDisplayService, "GetSystemDisplayService"}, 701 {101, &IApplicationDisplayService::GetSystemDisplayService, "GetSystemDisplayService"},
635 {102, &IApplicationDisplayService::GetManagerDisplayService, "GetManagerDisplayService"}, 702 {102, &IApplicationDisplayService::GetManagerDisplayService, "GetManagerDisplayService"},
636 {103, nullptr, "GetIndirectDisplayTransactionService"}, 703 {103, &IApplicationDisplayService::GetIndirectDisplayTransactionService,
704 "GetIndirectDisplayTransactionService"},
637 {1000, nullptr, "ListDisplays"}, 705 {1000, nullptr, "ListDisplays"},
638 {1010, &IApplicationDisplayService::OpenDisplay, "OpenDisplay"}, 706 {1010, &IApplicationDisplayService::OpenDisplay, "OpenDisplay"},
707 {1020, &IApplicationDisplayService::CloseDisplay, "CloseDisplay"},
639 {2101, &IApplicationDisplayService::SetLayerScalingMode, "SetLayerScalingMode"}, 708 {2101, &IApplicationDisplayService::SetLayerScalingMode, "SetLayerScalingMode"},
640 {2020, &IApplicationDisplayService::OpenLayer, "OpenLayer"}, 709 {2020, &IApplicationDisplayService::OpenLayer, "OpenLayer"},
710 {2030, &IApplicationDisplayService::CreateStrayLayer, "CreateStrayLayer"},
711 {2031, &IApplicationDisplayService::DestroyStrayLayer, "DestroyStrayLayer"},
641 {5202, &IApplicationDisplayService::GetDisplayVsyncEvent, "GetDisplayVsyncEvent"}, 712 {5202, &IApplicationDisplayService::GetDisplayVsyncEvent, "GetDisplayVsyncEvent"},
642 }; 713 };
643 RegisterHandlers(functions); 714 RegisterHandlers(functions);
@@ -778,7 +849,9 @@ void NVFlinger::Compose() {
778 } 849 }
779} 850}
780 851
781BufferQueue::BufferQueue(u32 id, u64 layer_id) : id(id), layer_id(layer_id) {} 852BufferQueue::BufferQueue(u32 id, u64 layer_id) : id(id), layer_id(layer_id) {
853 native_handle = Kernel::Event::Create(Kernel::ResetType::OneShot, "BufferQueue NativeHandle");
854}
782 855
783void BufferQueue::SetPreallocatedBuffer(u32 slot, IGBPBuffer& igbp_buffer) { 856void BufferQueue::SetPreallocatedBuffer(u32 slot, IGBPBuffer& igbp_buffer) {
784 Buffer buffer{}; 857 Buffer buffer{};
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h
index 10e894f8c..81d4f3daa 100644
--- a/src/core/hle/service/vi/vi.h
+++ b/src/core/hle/service/vi/vi.h
@@ -59,11 +59,16 @@ public:
59 return id; 59 return id;
60 } 60 }
61 61
62 Kernel::SharedPtr<Kernel::Event> GetNativeHandle() const {
63 return native_handle;
64 }
65
62private: 66private:
63 u32 id; 67 u32 id;
64 u64 layer_id; 68 u64 layer_id;
65 69
66 std::vector<Buffer> queue; 70 std::vector<Buffer> queue;
71 Kernel::SharedPtr<Kernel::Event> native_handle;
67}; 72};
68 73
69struct Layer { 74struct Layer {
@@ -138,9 +143,13 @@ private:
138 void GetRelayService(Kernel::HLERequestContext& ctx); 143 void GetRelayService(Kernel::HLERequestContext& ctx);
139 void GetSystemDisplayService(Kernel::HLERequestContext& ctx); 144 void GetSystemDisplayService(Kernel::HLERequestContext& ctx);
140 void GetManagerDisplayService(Kernel::HLERequestContext& ctx); 145 void GetManagerDisplayService(Kernel::HLERequestContext& ctx);
146 void GetIndirectDisplayTransactionService(Kernel::HLERequestContext& ctx);
141 void OpenDisplay(Kernel::HLERequestContext& ctx); 147 void OpenDisplay(Kernel::HLERequestContext& ctx);
148 void CloseDisplay(Kernel::HLERequestContext& ctx);
142 void SetLayerScalingMode(Kernel::HLERequestContext& ctx); 149 void SetLayerScalingMode(Kernel::HLERequestContext& ctx);
143 void OpenLayer(Kernel::HLERequestContext& ctx); 150 void OpenLayer(Kernel::HLERequestContext& ctx);
151 void CreateStrayLayer(Kernel::HLERequestContext& ctx);
152 void DestroyStrayLayer(Kernel::HLERequestContext& ctx);
144 void GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx); 153 void GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx);
145 154
146 std::shared_ptr<NVFlinger> nv_flinger; 155 std::shared_ptr<NVFlinger> nv_flinger;