yuzu-emu
/
yuzu
Archived
1
0
Fork 0

nv_services: Stub CtrlEventSignal

This commit is contained in:
Fernando Sahmkow 2019-06-07 21:13:20 -04:00 committed by FernandoS27
parent 8942047d41
commit a45643cb3b
4 changed files with 48 additions and 13 deletions

View File

@ -33,6 +33,8 @@ u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<
return IocCtrlEventRegister(input, output); return IocCtrlEventRegister(input, output);
case IoctlCommand::IocCtrlEventUnregisterCommand: case IoctlCommand::IocCtrlEventUnregisterCommand:
return IocCtrlEventUnregister(input, output); return IocCtrlEventUnregister(input, output);
case IoctlCommand::IocCtrlEventSignalCommand:
return IocCtrlEventSignal(input, output);
} }
UNIMPLEMENTED_MSG("Unimplemented ioctl"); UNIMPLEMENTED_MSG("Unimplemented ioctl");
return 0; return 0;
@ -74,30 +76,29 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
return NvResult::Timeout; return NvResult::Timeout;
} }
u32 event_index; u32 event_id;
if (is_async) { if (is_async) {
event_index = params.value; event_id = params.value & 0x00FF;
if (event_index >= 64) { if (event_id >= 64) {
std::memcpy(output.data(), &params, sizeof(params)); std::memcpy(output.data(), &params, sizeof(params));
return NvResult::BadParameter; return NvResult::BadParameter;
} }
} else { } else {
event_index = events_interface.GetFreeEvent(); event_id = events_interface.GetFreeEvent();
} }
EventState status = events_interface.status[event_index]; EventState status = events_interface.status[event_id];
if (event_index < MaxNvEvents || status == EventState::Free || if (event_id < MaxNvEvents || status == EventState::Free || status == EventState::Registered) {
status == EventState::Registered) { events_interface.SetEventStatus(event_id, EventState::Waiting);
events_interface.SetEventStatus(event_index, EventState::Waiting); events_interface.assigned_syncpt[event_id] = params.syncpt_id;
events_interface.assigned_syncpt[event_index] = params.syncpt_id; events_interface.assigned_value[event_id] = params.threshold;
events_interface.assigned_value[event_index] = params.threshold;
if (is_async) { if (is_async) {
params.value = params.syncpt_id << 4; params.value = params.syncpt_id << 4;
} else { } else {
params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000; params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000;
} }
params.value |= event_index; params.value |= event_id;
gpu.RegisterEvent(event_index, params.syncpt_id, params.threshold); gpu.RegisterEvent(event_id, params.syncpt_id, params.threshold);
std::memcpy(output.data(), &params, sizeof(params)); std::memcpy(output.data(), &params, sizeof(params));
return NvResult::Timeout; return NvResult::Timeout;
} }
@ -131,4 +132,23 @@ u32 nvhost_ctrl::IocCtrlEventUnregister(const std::vector<u8>& input, std::vecto
return NvResult::Success; return NvResult::Success;
} }
u32 nvhost_ctrl::IocCtrlEventSignal(const std::vector<u8>& input, std::vector<u8>& output) {
IocCtrlEventSignalParams params{};
std::memcpy(&params, input.data(), sizeof(params));
// TODO(Blinkhawk): This is normally called when an NvEvents timeout on WaitSynchronization
// It is believed to cancel the GPU Event. However, better research is required
u32 event_id = params.user_event_id & 0x00FF;
LOG_WARNING(Service_NVDRV, "(STUBBED) called, user_event_id: {:X}", event_id);
if (event_id >= MaxNvEvents) {
return NvResult::BadParameter;
}
if (events_interface.status[event_id] == EventState::Waiting) {
auto& gpu = Core::System::GetInstance().GPU();
gpu.CancelEvent(event_id, events_interface.assigned_syncpt[event_id],
events_interface.assigned_value[event_id]);
events_interface.LiberateEvent(event_id);
}
return NvResult::Success;
}
} // namespace Service::Nvidia::Devices } // namespace Service::Nvidia::Devices

View File

@ -139,6 +139,8 @@ private:
u32 IocCtrlEventUnregister(const std::vector<u8>& input, std::vector<u8>& output); u32 IocCtrlEventUnregister(const std::vector<u8>& input, std::vector<u8>& output);
u32 IocCtrlEventSignal(const std::vector<u8>& input, std::vector<u8>& output);
EventsInterface& events_interface; EventsInterface& events_interface;
}; };

View File

@ -95,6 +95,17 @@ void GPU::RegisterEvent(const u32 event_id, const u32 syncpoint_id, const u32 va
events[syncpoint_id].emplace_back(event_id, value); events[syncpoint_id].emplace_back(event_id, value);
} }
void GPU::CancelEvent(const u32 event_id, const u32 syncpoint_id, const u32 value) {
auto it = events[syncpoint_id].begin();
while (it != events[syncpoint_id].end()) {
if (value == it->value) {
it = events[syncpoint_id].erase(it);
return;
}
it++;
}
}
u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { u32 RenderTargetBytesPerPixel(RenderTargetFormat format) {
ASSERT(format != RenderTargetFormat::NONE); ASSERT(format != RenderTargetFormat::NONE);

View File

@ -171,7 +171,9 @@ public:
u32 GetSyncpointValue(const u32 syncpoint_id) const; u32 GetSyncpointValue(const u32 syncpoint_id) const;
void RegisterEvent(const u32 event_id, const u32 sync_point_id, const u32 value); void RegisterEvent(const u32 event_id, const u32 syncpoint_id, const u32 value);
void CancelEvent(const u32 event_id, const u32 syncpoint_id, const u32 value);
/// Returns a const reference to the GPU DMA pusher. /// Returns a const reference to the GPU DMA pusher.
const Tegra::DmaPusher& DmaPusher() const; const Tegra::DmaPusher& DmaPusher() const;