pineapple-src/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp

85 lines
2.9 KiB
C++
Raw Normal View History

2022-11-05 08:58:44 -04:00
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/assert.h"
#include "common/logging/log.h"
#include "core/core.h"
#include "core/hle/service/nvdrv/core/container.h"
2023-10-31 20:55:30 -04:00
#include "core/hle/service/nvdrv/devices/ioctl_serialization.h"
2022-11-05 08:58:44 -04:00
#include "core/hle/service/nvdrv/devices/nvhost_vic.h"
#include "video_core/renderer_base.h"
namespace Service::Nvidia::Devices {
nvhost_vic::nvhost_vic(Core::System& system_, NvCore::Container& core_)
: nvhost_nvdec_common{system_, core_, NvCore::ChannelType::VIC} {}
nvhost_vic::~nvhost_vic() = default;
2023-02-03 20:02:39 -05:00
NvResult nvhost_vic::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> input,
2023-06-12 19:03:27 -04:00
std::span<u8> output) {
2022-11-05 08:58:44 -04:00
switch (command.group) {
case 0x0:
switch (command.cmd) {
2024-01-26 01:10:49 -05:00
case 0x1: {
auto& host1x_file = core.Host1xDeviceFile();
if (!host1x_file.fd_to_id.contains(fd)) {
host1x_file.fd_to_id[fd] = host1x_file.vic_next_id++;
}
2023-10-31 20:55:30 -04:00
return WrapFixedVariable(this, &nvhost_vic::Submit, input, output, fd);
2024-01-26 01:10:49 -05:00
}
2022-11-05 08:58:44 -04:00
case 0x2:
2023-10-31 20:55:30 -04:00
return WrapFixed(this, &nvhost_vic::GetSyncpoint, input, output);
2022-11-05 08:58:44 -04:00
case 0x3:
2023-10-31 20:55:30 -04:00
return WrapFixed(this, &nvhost_vic::GetWaitbase, input, output);
2022-11-05 08:58:44 -04:00
case 0x9:
2024-01-07 04:47:31 -05:00
return WrapFixedVariable(this, &nvhost_vic::MapBuffer, input, output, fd);
2022-11-05 08:58:44 -04:00
case 0xa:
2023-10-31 20:55:30 -04:00
return WrapFixedVariable(this, &nvhost_vic::UnmapBuffer, input, output);
2022-11-05 08:58:44 -04:00
default:
break;
}
break;
case 'H':
switch (command.cmd) {
case 0x1:
2023-10-31 20:55:30 -04:00
return WrapFixed(this, &nvhost_vic::SetNVMAPfd, input, output);
2022-11-05 08:58:44 -04:00
default:
break;
}
break;
default:
break;
}
UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
return NvResult::NotImplemented;
}
2023-02-03 20:02:39 -05:00
NvResult nvhost_vic::Ioctl2(DeviceFD fd, Ioctl command, std::span<const u8> input,
2023-06-12 19:03:27 -04:00
std::span<const u8> inline_input, std::span<u8> output) {
2022-11-05 08:58:44 -04:00
UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
return NvResult::NotImplemented;
}
2023-02-03 20:02:39 -05:00
NvResult nvhost_vic::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input,
2023-06-12 19:03:27 -04:00
std::span<u8> output, std::span<u8> inline_output) {
2022-11-05 08:58:44 -04:00
UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
return NvResult::NotImplemented;
}
2024-01-16 01:24:48 -05:00
void nvhost_vic::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {
2024-01-07 04:47:31 -05:00
sessions[fd] = session_id;
}
2022-11-05 08:58:44 -04:00
void nvhost_vic::OnClose(DeviceFD fd) {
2024-01-26 01:10:49 -05:00
auto& host1x_file = core.Host1xDeviceFile();
const auto iter = host1x_file.fd_to_id.find(fd);
if (iter != host1x_file.fd_to_id.end()) {
system.GPU().ClearCdmaInstance(iter->second);
}
2024-01-16 01:24:48 -05:00
sessions.erase(fd);
2022-11-05 08:58:44 -04:00
}
} // namespace Service::Nvidia::Devices