From c3ec6f62edda391b2593d64e36e0c0affe799dbe Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 22 May 2026 04:05:53 +0000 Subject: [PATCH] stub nv ctrl-gpu and nvdec debug stuff --- .../hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp | 8 ++++++++ .../hle/service/nvdrv/devices/nvhost_ctrl_gpu.h | 8 +++++++- .../hle/service/nvdrv/devices/nvhost_nvdec.cpp | 14 ++++++++------ .../service/nvdrv/devices/nvhost_nvdec_common.cpp | 7 +++++++ .../service/nvdrv/devices/nvhost_nvdec_common.h | 7 +++++++ 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp index ace1f7e8f7..b621e5d70d 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp @@ -47,6 +47,8 @@ NvResult nvhost_ctrl_gpu::Ioctl1(DeviceFD fd, Ioctl command, std::span return WrapFixed(this, &nvhost_ctrl_gpu::FlushL2, input, output); case 0x14: return WrapFixed(this, &nvhost_ctrl_gpu::GetActiveSlotMask, input, output); + case 0x15: + return WrapFixed(this, &nvhost_ctrl_gpu::PmuGetGpuLoad, input, output); case 0x1c: return WrapFixed(this, &nvhost_ctrl_gpu::GetGpuTime, input, output); default: @@ -234,6 +236,12 @@ NvResult nvhost_ctrl_gpu::GetActiveSlotMask(IoctlActiveSlotMask& params) { return NvResult::Success; } +NvResult nvhost_ctrl_gpu::PmuGetGpuLoad(IoctlPmuGetLoad& params) { + LOG_WARNING(Service_NVDRV, "(stubbed) called"); + params.pmu_gpu_load = 100; + return NvResult::Success; +} + NvResult nvhost_ctrl_gpu::ZCullGetCtxSize(IoctlZcullGetCtxSize& params) { LOG_DEBUG(Service_NVDRV, "called"); params.size = 0x1; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h index e0603f9a71..80b7abd6a1 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -184,6 +184,11 @@ private: }; static_assert(sizeof(IoctlGetCpuTimeCorrelationInfo) == 264); + struct IoctlPmuGetLoad { + u32 pmu_gpu_load; + }; + static_assert(sizeof(IoctlPmuGetLoad) == 4); + NvResult GetCharacteristics1(IoctlCharacteristics& params); NvResult GetCharacteristics3(IoctlCharacteristics& params, std::span gpu_characteristics); @@ -192,6 +197,7 @@ private: NvResult GetTPCMasks3(IoctlGpuGetTpcMasksArgs& params, std::span tpc_mask); NvResult GetActiveSlotMask(IoctlActiveSlotMask& params); + NvResult PmuGetGpuLoad(IoctlPmuGetLoad& params); NvResult ZCullGetCtxSize(IoctlZcullGetCtxSize& params); NvResult ZCullGetInfo(IoctlNvgpuGpuZcullGetInfoArgs& params); NvResult ZBCSetTable(IoctlZbcSetTable& params); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index d64658bddc..7ac3dfaa46 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp @@ -25,18 +25,20 @@ NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, std::span in switch (command.group) { case 0x0: switch (command.cmd) { - case 0x1: + case 0x01: return WrapFixedVariable(this, &nvhost_nvdec::Submit, input, output, fd); - case 0x2: + case 0x02: return WrapFixed(this, &nvhost_nvdec::GetSyncpoint, input, output); - case 0x3: + case 0x03: return WrapFixed(this, &nvhost_nvdec::GetWaitbase, input, output); - case 0x7: + case 0x07: return WrapFixed(this, &nvhost_nvdec::SetSubmitTimeout, input, output); - case 0x9: + case 0x09: return WrapFixedVariable(this, &nvhost_nvdec::MapBuffer, input, output, fd); - case 0xa: + case 0x0a: return WrapFixedVariable(this, &nvhost_nvdec::UnmapBuffer, input, output); + case 0x23: + return WrapFixed(this, &nvhost_nvdec::GetClkRate, input, output); default: break; } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp index c726d6f93e..698712e152 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp @@ -168,6 +168,13 @@ NvResult nvhost_nvdec_common::SetSubmitTimeout(u32 timeout) { return NvResult::Success; } +NvResult nvhost_nvdec_common::GetClkRate(IoctlGetClkRate& params) { + LOG_WARNING(Service_NVDRV, "(STUBBED) called"); + params.clk_rate = 614400000; + params.module_id = 0; + return NvResult::Success; +} + Kernel::KEvent* nvhost_nvdec_common::QueryEvent(u32 event_id) { LOG_CRITICAL(Service_NVDRV, "Unknown HOSTX1 Event {}", event_id); return nullptr; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h index 6b66a0d28d..8b3b7ee285 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h @@ -111,6 +111,12 @@ protected: }; static_assert(sizeof(IoctlMapBuffer) == 0x0C, "IoctlMapBuffer is incorrect size"); + struct IoctlGetClkRate { + u32_le clk_rate{}; + u32_le module_id{}; + }; + static_assert(sizeof(IoctlGetClkRate) == 8); + /// Ioctl command implementations NvResult SetNVMAPfd(IoctlSetNvmapFD&); NvResult Submit(IoctlSubmit& params, std::span input, DeviceFD fd); @@ -119,6 +125,7 @@ protected: NvResult MapBuffer(IoctlMapBuffer& params, std::span entries, DeviceFD fd); NvResult UnmapBuffer(IoctlMapBuffer& params, std::span entries); NvResult SetSubmitTimeout(u32 timeout); + NvResult GetClkRate(IoctlGetClkRate& params); Kernel::KEvent* QueryEvent(u32 event_id) override;