diff options
| author | 2023-10-24 13:30:35 -0400 | |
|---|---|---|
| committer | 2023-10-25 13:05:56 -0400 | |
| commit | efdb2e8f3dfc1106ee601a2e0cc479c35aa83698 (patch) | |
| tree | ff77b31bb6437e8501f1d70c0f2251454070f540 | |
| parent | nvdrv: convert nvhost_gpu (diff) | |
| download | yuzu-efdb2e8f3dfc1106ee601a2e0cc479c35aa83698.tar.gz yuzu-efdb2e8f3dfc1106ee601a2e0cc479c35aa83698.tar.xz yuzu-efdb2e8f3dfc1106ee601a2e0cc479c35aa83698.zip | |
nvdrv: convert codec devices
6 files changed, 29 insertions, 34 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index a174442a6..74790a7d8 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/hle/service/nvdrv/core/container.h" | 8 | #include "core/hle/service/nvdrv/core/container.h" |
| 9 | #include "core/hle/service/nvdrv/devices/ioctl_serialization.h" | ||
| 9 | #include "core/hle/service/nvdrv/devices/nvhost_nvdec.h" | 10 | #include "core/hle/service/nvdrv/devices/nvhost_nvdec.h" |
| 10 | #include "video_core/renderer_base.h" | 11 | #include "video_core/renderer_base.h" |
| 11 | 12 | ||
| @@ -28,11 +29,11 @@ NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> in | |||
| 28 | return Submit(fd, input, output); | 29 | return Submit(fd, input, output); |
| 29 | } | 30 | } |
| 30 | case 0x2: | 31 | case 0x2: |
| 31 | return GetSyncpoint(input, output); | 32 | return Wrap1(&nvhost_nvdec::GetSyncpoint, input, output); |
| 32 | case 0x3: | 33 | case 0x3: |
| 33 | return GetWaitbase(input, output); | 34 | return Wrap1(&nvhost_nvdec::GetWaitbase, input, output); |
| 34 | case 0x7: | 35 | case 0x7: |
| 35 | return SetSubmitTimeout(input, output); | 36 | return Wrap1(&nvhost_nvdec::SetSubmitTimeout, input, output); |
| 36 | case 0x9: | 37 | case 0x9: |
| 37 | return MapBuffer(input, output); | 38 | return MapBuffer(input, output); |
| 38 | case 0xa: | 39 | case 0xa: |
| @@ -44,7 +45,7 @@ NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> in | |||
| 44 | case 'H': | 45 | case 'H': |
| 45 | switch (command.cmd) { | 46 | switch (command.cmd) { |
| 46 | case 0x1: | 47 | case 0x1: |
| 47 | return SetNVMAPfd(input); | 48 | return Wrap1(&nvhost_nvdec::SetNVMAPfd, input, output); |
| 48 | default: | 49 | default: |
| 49 | break; | 50 | break; |
| 50 | } | 51 | } |
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 61649aa4a..51659934b 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp | |||
| @@ -63,9 +63,7 @@ nvhost_nvdec_common::~nvhost_nvdec_common() { | |||
| 63 | core.Host1xDeviceFile().syncpts_accumulated.push_back(channel_syncpoint); | 63 | core.Host1xDeviceFile().syncpts_accumulated.push_back(channel_syncpoint); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | NvResult nvhost_nvdec_common::SetNVMAPfd(std::span<const u8> input) { | 66 | NvResult nvhost_nvdec_common::SetNVMAPfd(IoctlSetNvmapFD& params) { |
| 67 | IoctlSetNvmapFD params{}; | ||
| 68 | std::memcpy(¶ms, input.data(), sizeof(IoctlSetNvmapFD)); | ||
| 69 | LOG_DEBUG(Service_NVDRV, "called, fd={}", params.nvmap_fd); | 67 | LOG_DEBUG(Service_NVDRV, "called, fd={}", params.nvmap_fd); |
| 70 | 68 | ||
| 71 | nvmap_fd = params.nvmap_fd; | 69 | nvmap_fd = params.nvmap_fd; |
| @@ -74,7 +72,7 @@ NvResult nvhost_nvdec_common::SetNVMAPfd(std::span<const u8> input) { | |||
| 74 | 72 | ||
| 75 | NvResult nvhost_nvdec_common::Submit(DeviceFD fd, std::span<const u8> input, std::span<u8> output) { | 73 | NvResult nvhost_nvdec_common::Submit(DeviceFD fd, std::span<const u8> input, std::span<u8> output) { |
| 76 | IoctlSubmit params{}; | 74 | IoctlSubmit params{}; |
| 77 | std::memcpy(¶ms, input.data(), sizeof(IoctlSubmit)); | 75 | std::memcpy(¶ms, input.data(), std::min(input.size(), sizeof(IoctlSubmit))); |
| 78 | LOG_DEBUG(Service_NVDRV, "called NVDEC Submit, cmd_buffer_count={}", params.cmd_buffer_count); | 76 | LOG_DEBUG(Service_NVDRV, "called NVDEC Submit, cmd_buffer_count={}", params.cmd_buffer_count); |
| 79 | 77 | ||
| 80 | // Instantiate param buffers | 78 | // Instantiate param buffers |
| @@ -120,24 +118,15 @@ NvResult nvhost_nvdec_common::Submit(DeviceFD fd, std::span<const u8> input, std | |||
| 120 | return NvResult::Success; | 118 | return NvResult::Success; |
| 121 | } | 119 | } |
| 122 | 120 | ||
| 123 | NvResult nvhost_nvdec_common::GetSyncpoint(std::span<const u8> input, std::span<u8> output) { | 121 | NvResult nvhost_nvdec_common::GetSyncpoint(IoctlGetSyncpoint& params) { |
| 124 | IoctlGetSyncpoint params{}; | ||
| 125 | std::memcpy(¶ms, input.data(), sizeof(IoctlGetSyncpoint)); | ||
| 126 | LOG_DEBUG(Service_NVDRV, "called GetSyncpoint, id={}", params.param); | 122 | LOG_DEBUG(Service_NVDRV, "called GetSyncpoint, id={}", params.param); |
| 127 | |||
| 128 | // const u32 id{NvCore::SyncpointManager::channel_syncpoints[static_cast<u32>(channel_type)]}; | ||
| 129 | params.value = channel_syncpoint; | 123 | params.value = channel_syncpoint; |
| 130 | std::memcpy(output.data(), ¶ms, sizeof(IoctlGetSyncpoint)); | ||
| 131 | |||
| 132 | return NvResult::Success; | 124 | return NvResult::Success; |
| 133 | } | 125 | } |
| 134 | 126 | ||
| 135 | NvResult nvhost_nvdec_common::GetWaitbase(std::span<const u8> input, std::span<u8> output) { | 127 | NvResult nvhost_nvdec_common::GetWaitbase(IoctlGetWaitbase& params) { |
| 136 | IoctlGetWaitbase params{}; | ||
| 137 | LOG_CRITICAL(Service_NVDRV, "called WAITBASE"); | 128 | LOG_CRITICAL(Service_NVDRV, "called WAITBASE"); |
| 138 | std::memcpy(¶ms, input.data(), sizeof(IoctlGetWaitbase)); | ||
| 139 | params.value = 0; // Seems to be hard coded at 0 | 129 | params.value = 0; // Seems to be hard coded at 0 |
| 140 | std::memcpy(output.data(), ¶ms, sizeof(IoctlGetWaitbase)); | ||
| 141 | return NvResult::Success; | 130 | return NvResult::Success; |
| 142 | } | 131 | } |
| 143 | 132 | ||
| @@ -151,6 +140,12 @@ NvResult nvhost_nvdec_common::MapBuffer(std::span<const u8> input, std::span<u8> | |||
| 151 | for (auto& cmd_buffer : cmd_buffer_handles) { | 140 | for (auto& cmd_buffer : cmd_buffer_handles) { |
| 152 | cmd_buffer.map_address = nvmap.PinHandle(cmd_buffer.map_handle); | 141 | cmd_buffer.map_address = nvmap.PinHandle(cmd_buffer.map_handle); |
| 153 | } | 142 | } |
| 143 | |||
| 144 | if (output.size() < | ||
| 145 | sizeof(IoctlMapBuffer) + cmd_buffer_handles.size() * sizeof(MapBufferEntry)) { | ||
| 146 | return NvResult::InvalidSize; | ||
| 147 | } | ||
| 148 | |||
| 154 | std::memcpy(output.data(), ¶ms, sizeof(IoctlMapBuffer)); | 149 | std::memcpy(output.data(), ¶ms, sizeof(IoctlMapBuffer)); |
| 155 | std::memcpy(output.data() + sizeof(IoctlMapBuffer), cmd_buffer_handles.data(), | 150 | std::memcpy(output.data() + sizeof(IoctlMapBuffer), cmd_buffer_handles.data(), |
| 156 | cmd_buffer_handles.size() * sizeof(MapBufferEntry)); | 151 | cmd_buffer_handles.size() * sizeof(MapBufferEntry)); |
| @@ -160,7 +155,7 @@ NvResult nvhost_nvdec_common::MapBuffer(std::span<const u8> input, std::span<u8> | |||
| 160 | 155 | ||
| 161 | NvResult nvhost_nvdec_common::UnmapBuffer(std::span<const u8> input, std::span<u8> output) { | 156 | NvResult nvhost_nvdec_common::UnmapBuffer(std::span<const u8> input, std::span<u8> output) { |
| 162 | IoctlMapBuffer params{}; | 157 | IoctlMapBuffer params{}; |
| 163 | std::memcpy(¶ms, input.data(), sizeof(IoctlMapBuffer)); | 158 | std::memcpy(¶ms, input.data(), std::min(input.size(), sizeof(IoctlMapBuffer))); |
| 164 | std::vector<MapBufferEntry> cmd_buffer_handles(params.num_entries); | 159 | std::vector<MapBufferEntry> cmd_buffer_handles(params.num_entries); |
| 165 | 160 | ||
| 166 | SliceVectors(input, cmd_buffer_handles, params.num_entries, sizeof(IoctlMapBuffer)); | 161 | SliceVectors(input, cmd_buffer_handles, params.num_entries, sizeof(IoctlMapBuffer)); |
| @@ -172,8 +167,7 @@ NvResult nvhost_nvdec_common::UnmapBuffer(std::span<const u8> input, std::span<u | |||
| 172 | return NvResult::Success; | 167 | return NvResult::Success; |
| 173 | } | 168 | } |
| 174 | 169 | ||
| 175 | NvResult nvhost_nvdec_common::SetSubmitTimeout(std::span<const u8> input, std::span<u8> output) { | 170 | NvResult nvhost_nvdec_common::SetSubmitTimeout(u32 timeout) { |
| 176 | std::memcpy(&submit_timeout, input.data(), input.size()); | ||
| 177 | LOG_WARNING(Service_NVDRV, "(STUBBED) called"); | 171 | LOG_WARNING(Service_NVDRV, "(STUBBED) called"); |
| 178 | return NvResult::Success; | 172 | return NvResult::Success; |
| 179 | } | 173 | } |
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 9bb573bfe..cc988b897 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h | |||
| @@ -107,13 +107,13 @@ protected: | |||
| 107 | static_assert(sizeof(IoctlMapBuffer) == 0x0C, "IoctlMapBuffer is incorrect size"); | 107 | static_assert(sizeof(IoctlMapBuffer) == 0x0C, "IoctlMapBuffer is incorrect size"); |
| 108 | 108 | ||
| 109 | /// Ioctl command implementations | 109 | /// Ioctl command implementations |
| 110 | NvResult SetNVMAPfd(std::span<const u8> input); | 110 | NvResult SetNVMAPfd(IoctlSetNvmapFD&); |
| 111 | NvResult Submit(DeviceFD fd, std::span<const u8> input, std::span<u8> output); | 111 | NvResult Submit(DeviceFD fd, std::span<const u8> input, std::span<u8> output); |
| 112 | NvResult GetSyncpoint(std::span<const u8> input, std::span<u8> output); | 112 | NvResult GetSyncpoint(IoctlGetSyncpoint& params); |
| 113 | NvResult GetWaitbase(std::span<const u8> input, std::span<u8> output); | 113 | NvResult GetWaitbase(IoctlGetWaitbase& params); |
| 114 | NvResult MapBuffer(std::span<const u8> input, std::span<u8> output); | 114 | NvResult MapBuffer(std::span<const u8> input, std::span<u8> output); |
| 115 | NvResult UnmapBuffer(std::span<const u8> input, std::span<u8> output); | 115 | NvResult UnmapBuffer(std::span<const u8> input, std::span<u8> output); |
| 116 | NvResult SetSubmitTimeout(std::span<const u8> input, std::span<u8> output); | 116 | NvResult SetSubmitTimeout(u32 timeout); |
| 117 | 117 | ||
| 118 | Kernel::KEvent* QueryEvent(u32 event_id) override; | 118 | Kernel::KEvent* QueryEvent(u32 event_id) override; |
| 119 | 119 | ||
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp index a05c8cdae..23a57c4d5 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/hle/service/nvdrv/devices/ioctl_serialization.h" | ||
| 8 | #include "core/hle/service/nvdrv/devices/nvhost_nvjpg.h" | 9 | #include "core/hle/service/nvdrv/devices/nvhost_nvjpg.h" |
| 9 | 10 | ||
| 10 | namespace Service::Nvidia::Devices { | 11 | namespace Service::Nvidia::Devices { |
| @@ -18,7 +19,7 @@ NvResult nvhost_nvjpg::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> in | |||
| 18 | case 'H': | 19 | case 'H': |
| 19 | switch (command.cmd) { | 20 | switch (command.cmd) { |
| 20 | case 0x1: | 21 | case 0x1: |
| 21 | return SetNVMAPfd(input, output); | 22 | return Wrap1(&nvhost_nvjpg::SetNVMAPfd, input, output); |
| 22 | default: | 23 | default: |
| 23 | break; | 24 | break; |
| 24 | } | 25 | } |
| @@ -46,9 +47,7 @@ NvResult nvhost_nvjpg::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> in | |||
| 46 | void nvhost_nvjpg::OnOpen(DeviceFD fd) {} | 47 | void nvhost_nvjpg::OnOpen(DeviceFD fd) {} |
| 47 | void nvhost_nvjpg::OnClose(DeviceFD fd) {} | 48 | void nvhost_nvjpg::OnClose(DeviceFD fd) {} |
| 48 | 49 | ||
| 49 | NvResult nvhost_nvjpg::SetNVMAPfd(std::span<const u8> input, std::span<u8> output) { | 50 | NvResult nvhost_nvjpg::SetNVMAPfd(IoctlSetNvmapFD& params) { |
| 50 | IoctlSetNvmapFD params{}; | ||
| 51 | std::memcpy(¶ms, input.data(), input.size()); | ||
| 52 | LOG_DEBUG(Service_NVDRV, "called, fd={}", params.nvmap_fd); | 51 | LOG_DEBUG(Service_NVDRV, "called, fd={}", params.nvmap_fd); |
| 53 | 52 | ||
| 54 | nvmap_fd = params.nvmap_fd; | 53 | nvmap_fd = params.nvmap_fd; |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h index 5623e0d47..790c97f6a 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h | |||
| @@ -33,7 +33,7 @@ private: | |||
| 33 | 33 | ||
| 34 | s32_le nvmap_fd{}; | 34 | s32_le nvmap_fd{}; |
| 35 | 35 | ||
| 36 | NvResult SetNVMAPfd(std::span<const u8> input, std::span<u8> output); | 36 | NvResult SetNVMAPfd(IoctlSetNvmapFD& params); |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | } // namespace Service::Nvidia::Devices | 39 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp index c0b8684c3..20af75872 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 6 | #include "core/core.h" | 6 | #include "core/core.h" |
| 7 | #include "core/hle/service/nvdrv/core/container.h" | 7 | #include "core/hle/service/nvdrv/core/container.h" |
| 8 | #include "core/hle/service/nvdrv/devices/ioctl_serialization.h" | ||
| 8 | #include "core/hle/service/nvdrv/devices/nvhost_vic.h" | 9 | #include "core/hle/service/nvdrv/devices/nvhost_vic.h" |
| 9 | #include "video_core/renderer_base.h" | 10 | #include "video_core/renderer_base.h" |
| 10 | 11 | ||
| @@ -28,9 +29,9 @@ NvResult nvhost_vic::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> inpu | |||
| 28 | return Submit(fd, input, output); | 29 | return Submit(fd, input, output); |
| 29 | } | 30 | } |
| 30 | case 0x2: | 31 | case 0x2: |
| 31 | return GetSyncpoint(input, output); | 32 | return Wrap1(&nvhost_vic::GetSyncpoint, input, output); |
| 32 | case 0x3: | 33 | case 0x3: |
| 33 | return GetWaitbase(input, output); | 34 | return Wrap1(&nvhost_vic::GetWaitbase, input, output); |
| 34 | case 0x9: | 35 | case 0x9: |
| 35 | return MapBuffer(input, output); | 36 | return MapBuffer(input, output); |
| 36 | case 0xa: | 37 | case 0xa: |
| @@ -42,7 +43,7 @@ NvResult nvhost_vic::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> inpu | |||
| 42 | case 'H': | 43 | case 'H': |
| 43 | switch (command.cmd) { | 44 | switch (command.cmd) { |
| 44 | case 0x1: | 45 | case 0x1: |
| 45 | return SetNVMAPfd(input); | 46 | return Wrap1(&nvhost_vic::SetNVMAPfd, input, output); |
| 46 | default: | 47 | default: |
| 47 | break; | 48 | break; |
| 48 | } | 49 | } |