diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index bdae8b8875..d0490173ae 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp @@ -10,6 +10,9 @@ namespace Service::Nvidia::Devices { +constexpr u32 NVHOST_IOCTL_MAGIC(0x0); +constexpr u32 NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER(0x9); + nvhost_nvdec::nvhost_nvdec(Core::System& system) : nvdevice(system) {} nvhost_nvdec::~nvhost_nvdec() = default; @@ -23,6 +26,12 @@ u32 nvhost_nvdec::ioctl(Ioctl command, const std::vector& input, const std:: case IoctlCommand::IocSetNVMAPfdCommand: return SetNVMAPfd(input, output); } + + if (command.group == NVHOST_IOCTL_MAGIC) { + if (command.cmd == NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER) { + return ChannelMapCmdBuffer(input, output); + } + } UNIMPLEMENTED_MSG("Unimplemented ioctl"); return 0; @@ -37,4 +46,23 @@ u32 nvhost_nvdec::SetNVMAPfd(const std::vector& input, std::vector& outp return 0; } +u32 nvhost_nvdec::ChannelMapCmdBuffer(const std::vector& input, std::vector& output) { + IoctlMapCmdBuffer params{}; + std::memcpy(¶ms, input.data(), 12); + + std::vector handles(params.num_handles); + std::memcpy(handles.data(), input.data() + 12, + sizeof(IoctlHandleMapBuffer) * params.num_handles); + + LOG_WARNING(Service_NVDRV, "(STUBBED) called, num_handles: {}, is_compressed: {}", params.num_handles, params.is_compressed); + + //TODO(namkazt): Uses nvmap_pin internally to pin a given number of nvmap handles to an appropriate device + // physical address. + + std::memcpy(output.data(), ¶ms, 12); + std::memcpy(output.data() + 12, handles.data(), + sizeof(IoctlHandleMapBuffer) * params.num_handles); + return 0; +} + } // namespace Service::Nvidia::Devices