diff options
Diffstat (limited to 'src/core/hle/service')
24 files changed, 285 insertions, 100 deletions
diff --git a/src/core/hle/service/am/applets/error.cpp b/src/core/hle/service/am/applets/error.cpp index 23e30aa45..0dd6ec68e 100644 --- a/src/core/hle/service/am/applets/error.cpp +++ b/src/core/hle/service/am/applets/error.cpp @@ -158,11 +158,11 @@ void Error::Execute() { break; case ErrorAppletMode::ShowSystemError: case ErrorAppletMode::ShowApplicationError: { - const auto system = mode == ErrorAppletMode::ShowSystemError; + const auto is_system = mode == ErrorAppletMode::ShowSystemError; const auto& main_text = - system ? args->system_error.main_text : args->application_error.main_text; + is_system ? args->system_error.main_text : args->application_error.main_text; const auto& detail_text = - system ? args->system_error.detail_text : args->application_error.detail_text; + is_system ? args->system_error.detail_text : args->application_error.detail_text; const auto main_text_string = Common::StringFromFixedZeroTerminatedBuffer(main_text.data(), main_text.size()); diff --git a/src/core/hle/service/am/applets/general_backend.cpp b/src/core/hle/service/am/applets/general_backend.cpp index b26abad36..b7483261e 100644 --- a/src/core/hle/service/am/applets/general_backend.cpp +++ b/src/core/hle/service/am/applets/general_backend.cpp @@ -96,7 +96,7 @@ void Auth::Execute() { switch (type) { case AuthAppletType::ShowParentalAuthentication: { - const auto callback = [this](bool successful) { AuthFinished(successful); }; + const auto callback = [this](bool is_successful) { AuthFinished(is_successful); }; if (arg0 == 1 && arg1 == 0 && arg2 == 1) { // ShowAuthenticatorForConfiguration diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp index 78c047bd2..cee1774d1 100644 --- a/src/core/hle/service/bcat/backend/boxcat.cpp +++ b/src/core/hle/service/bcat/backend/boxcat.cpp @@ -415,9 +415,9 @@ std::optional<std::vector<u8>> Boxcat::GetLaunchParameter(TitleIDVersion title) if (Settings::values.bcat_boxcat_local) { LOG_INFO(Service_BCAT, "Boxcat using local data by override, skipping download."); } else { - Boxcat::Client client{path, title.title_id, title.build_id}; + Client launch_client{path, title.title_id, title.build_id}; - const auto res = client.DownloadLaunchParam(); + const auto res = launch_client.DownloadLaunchParam(); if (res != DownloadResult::Success) { LOG_ERROR(Service_BCAT, "Boxcat synchronization failed with error '{}'!", res); diff --git a/src/core/hle/service/bcat/module.cpp b/src/core/hle/service/bcat/module.cpp index c7dd04a6e..285085f2a 100644 --- a/src/core/hle/service/bcat/module.cpp +++ b/src/core/hle/service/bcat/module.cpp @@ -174,9 +174,9 @@ private: }; std::shared_ptr<IDeliveryCacheProgressService> CreateProgressService(SyncType type) { - auto& backend{progress.at(static_cast<std::size_t>(type))}; - return std::make_shared<IDeliveryCacheProgressService>(system, backend.GetEvent(), - backend.GetImpl()); + auto& progress_backend{GetProgressBackend(type)}; + return std::make_shared<IDeliveryCacheProgressService>(system, progress_backend.GetEvent(), + progress_backend.GetImpl()); } void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) { @@ -184,7 +184,7 @@ private: backend.Synchronize({system.CurrentProcess()->GetTitleID(), GetCurrentBuildID(system.GetCurrentProcessBuildID())}, - progress.at(static_cast<std::size_t>(SyncType::Normal))); + GetProgressBackend(SyncType::Normal)); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); @@ -201,8 +201,7 @@ private: backend.SynchronizeDirectory({system.CurrentProcess()->GetTitleID(), GetCurrentBuildID(system.GetCurrentProcessBuildID())}, - name, - progress.at(static_cast<std::size_t>(SyncType::Directory))); + name, GetProgressBackend(SyncType::Directory)); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); @@ -265,9 +264,16 @@ private: rb.Push(RESULT_SUCCESS); } - Backend& backend; + ProgressServiceBackend& GetProgressBackend(SyncType type) { + return progress.at(static_cast<size_t>(type)); + } - std::array<ProgressServiceBackend, static_cast<std::size_t>(SyncType::Count)> progress; + const ProgressServiceBackend& GetProgressBackend(SyncType type) const { + return progress.at(static_cast<size_t>(type)); + } + + Backend& backend; + std::array<ProgressServiceBackend, static_cast<size_t>(SyncType::Count)> progress; }; void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index a0215c4d7..7dc487e48 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -337,13 +337,14 @@ public: const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); - const u64 mode = rp.Pop<u64>(); - const u32 size = rp.Pop<u32>(); + const u64 file_mode = rp.Pop<u64>(); + const u32 file_size = rp.Pop<u32>(); - LOG_DEBUG(Service_FS, "called. file={}, mode=0x{:X}, size=0x{:08X}", name, mode, size); + LOG_DEBUG(Service_FS, "called. file={}, mode=0x{:X}, size=0x{:08X}", name, file_mode, + file_size); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(backend.CreateFile(name, size)); + rb.Push(backend.CreateFile(name, file_size)); } void DeleteFile(Kernel::HLERequestContext& ctx) { @@ -935,8 +936,8 @@ void FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute( void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); - auto romfs = fsc.OpenRomFSCurrentProcess(); - if (romfs.Failed()) { + auto current_romfs = fsc.OpenRomFSCurrentProcess(); + if (current_romfs.Failed()) { // TODO (bunnei): Find the right error code to use here LOG_CRITICAL(Service_FS, "no file system interface available!"); IPC::ResponseBuilder rb{ctx, 2}; @@ -944,7 +945,7 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { return; } - auto storage = std::make_shared<IStorage>(system, std::move(romfs.Unwrap())); + auto storage = std::make_shared<IStorage>(system, std::move(current_romfs.Unwrap())); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); @@ -1010,10 +1011,10 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called, program_index={}", program_index); - auto romfs = fsc.OpenPatchedRomFSWithProgramIndex( + auto patched_romfs = fsc.OpenPatchedRomFSWithProgramIndex( system.CurrentProcess()->GetTitleID(), program_index, FileSys::ContentRecordType::Program); - if (romfs.Failed()) { + if (patched_romfs.Failed()) { // TODO: Find the right error code to use here LOG_ERROR(Service_FS, "could not open storage with program_index={}", program_index); @@ -1022,7 +1023,7 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) { return; } - auto storage = std::make_shared<IStorage>(system, std::move(romfs.Unwrap())); + auto storage = std::make_shared<IStorage>(system, std::move(patched_romfs.Unwrap())); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.cpp b/src/core/hle/service/hid/controllers/console_sixaxis.cpp new file mode 100644 index 000000000..913768fab --- /dev/null +++ b/src/core/hle/service/hid/controllers/console_sixaxis.cpp @@ -0,0 +1,90 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "common/settings.h" +#include "core/core_timing.h" +#include "core/hle/service/hid/controllers/console_sixaxis.h" + +namespace Service::HID { +constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C200; + +Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::System& system) + : ControllerBase(system) {} +Controller_ConsoleSixAxis::~Controller_ConsoleSixAxis() = default; + +void Controller_ConsoleSixAxis::OnInit() {} + +void Controller_ConsoleSixAxis::OnRelease() {} + +void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, + std::size_t size) { + seven_six_axis.header.timestamp = core_timing.GetCPUTicks(); + seven_six_axis.header.total_entry_count = 17; + + if (!IsControllerActivated() || !is_transfer_memory_set) { + seven_six_axis.header.entry_count = 0; + seven_six_axis.header.last_entry_index = 0; + return; + } + seven_six_axis.header.entry_count = 16; + + const auto& last_entry = + seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; + seven_six_axis.header.last_entry_index = (seven_six_axis.header.last_entry_index + 1) % 17; + auto& cur_entry = seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; + + cur_entry.sampling_number = last_entry.sampling_number + 1; + cur_entry.sampling_number2 = cur_entry.sampling_number; + + // Try to read sixaxis sensor states + MotionDevice motion_device{}; + const auto& device = motions[0]; + if (device) { + std::tie(motion_device.accel, motion_device.gyro, motion_device.rotation, + motion_device.orientation, motion_device.quaternion) = device->GetStatus(); + console_six_axis.is_seven_six_axis_sensor_at_rest = motion_device.gyro.Length2() < 0.0001f; + } + + cur_entry.accel = motion_device.accel; + // Zero gyro values as they just mess up with the camera + // Note: Probably a correct sensivity setting must be set + cur_entry.gyro = {}; + cur_entry.quaternion = { + { + motion_device.quaternion.xyz.y, + motion_device.quaternion.xyz.x, + -motion_device.quaternion.w, + }, + -motion_device.quaternion.xyz.z, + }; + + console_six_axis.sampling_number++; + // TODO(German77): Find the purpose of those values + console_six_axis.verticalization_error = 0.0f; + console_six_axis.gyro_bias = {0.0f, 0.0f, 0.0f}; + + // Update console six axis shared memory + std::memcpy(data + SHARED_MEMORY_OFFSET, &console_six_axis, sizeof(console_six_axis)); + // Update seven six axis transfer memory + std::memcpy(transfer_memory, &seven_six_axis, sizeof(seven_six_axis)); +} + +void Controller_ConsoleSixAxis::OnLoadInputDevices() { + const auto player = Settings::values.players.GetValue()[0]; + std::transform(player.motions.begin() + Settings::NativeMotion::MOTION_HID_BEGIN, + player.motions.begin() + Settings::NativeMotion::MOTION_HID_END, motions.begin(), + Input::CreateDevice<Input::MotionDevice>); +} + +void Controller_ConsoleSixAxis::SetTransferMemoryPointer(u8* t_mem) { + is_transfer_memory_set = true; + transfer_memory = t_mem; +} + +void Controller_ConsoleSixAxis::ResetTimestamp() { + auto& cur_entry = seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; + cur_entry.sampling_number = 0; + cur_entry.sampling_number2 = 0; +} +} // namespace Service::HID diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.h b/src/core/hle/service/hid/controllers/console_sixaxis.h new file mode 100644 index 000000000..1fae98e94 --- /dev/null +++ b/src/core/hle/service/hid/controllers/console_sixaxis.h @@ -0,0 +1,80 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <array> +#include "common/bit_field.h" +#include "common/common_types.h" +#include "common/quaternion.h" +#include "core/frontend/input.h" +#include "core/hle/service/hid/controllers/controller_base.h" + +namespace Service::HID { +class Controller_ConsoleSixAxis final : public ControllerBase { +public: + explicit Controller_ConsoleSixAxis(Core::System& system); + ~Controller_ConsoleSixAxis() override; + + // Called when the controller is initialized + void OnInit() override; + + // When the controller is released + void OnRelease() override; + + // When the controller is requesting an update for the shared memory + void OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, size_t size) override; + + // Called when input devices should be loaded + void OnLoadInputDevices() override; + + // Called on InitializeSevenSixAxisSensor + void SetTransferMemoryPointer(u8* t_mem); + + // Called on ResetSevenSixAxisSensorTimestamp + void ResetTimestamp(); + +private: + struct SevenSixAxisState { + INSERT_PADDING_WORDS(4); // unused + s64_le sampling_number{}; + s64_le sampling_number2{}; + u64 unknown{}; + Common::Vec3f accel{}; + Common::Vec3f gyro{}; + Common::Quaternion<f32> quaternion{}; + }; + static_assert(sizeof(SevenSixAxisState) == 0x50, "SevenSixAxisState is an invalid size"); + + struct SevenSixAxisMemory { + CommonHeader header{}; + std::array<SevenSixAxisState, 0x21> sevensixaxis_states{}; + }; + static_assert(sizeof(SevenSixAxisMemory) == 0xA70, "SevenSixAxisMemory is an invalid size"); + + struct ConsoleSharedMemory { + u64_le sampling_number{}; + bool is_seven_six_axis_sensor_at_rest{}; + f32 verticalization_error{}; + Common::Vec3f gyro_bias{}; + }; + static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size"); + + struct MotionDevice { + Common::Vec3f accel; + Common::Vec3f gyro; + Common::Vec3f rotation; + std::array<Common::Vec3f, 3> orientation; + Common::Quaternion<f32> quaternion; + }; + + using MotionArray = + std::array<std::unique_ptr<Input::MotionDevice>, Settings::NativeMotion::NUM_MOTIONS_HID>; + MotionArray motions; + u8* transfer_memory = nullptr; + bool is_transfer_memory_set = false; + ConsoleSharedMemory console_six_axis{}; + SevenSixAxisMemory seven_six_axis{}; +}; +} // namespace Service::HID diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index 155808f6a..71545bf1f 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp @@ -33,7 +33,7 @@ void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u shared_memory.header.timestamp = core_timing.GetCPUTicks(); shared_memory.header.total_entry_count = 17; - if (!IsControllerActivated()) { + if (!IsControllerActivated() || !Settings::values.touchscreen.enabled) { shared_memory.header.entry_count = 0; shared_memory.header.last_entry_index = 0; return; diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 113a41254..249c300f6 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -654,8 +654,8 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing const auto& device = motions[i][e]; if (device) { std::tie(motion_devices[e].accel, motion_devices[e].gyro, - motion_devices[e].rotation, motion_devices[e].orientation) = - device->GetStatus(); + motion_devices[e].rotation, motion_devices[e].orientation, + motion_devices[e].quaternion) = device->GetStatus(); sixaxis_at_rest = sixaxis_at_rest && motion_devices[e].gyro.Length2() < 0.0001f; } } diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index c3b07bd41..085f42c48 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -8,6 +8,7 @@ #include <atomic> #include "common/bit_field.h" #include "common/common_types.h" +#include "common/quaternion.h" #include "common/settings.h" #include "core/frontend/input.h" #include "core/hle/kernel/object.h" @@ -467,6 +468,7 @@ private: Common::Vec3f gyro; Common::Vec3f rotation; std::array<Common::Vec3f, 3> orientation; + Common::Quaternion<f32> quaternion; }; struct NfcXcdHandle { diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index b5f8077be..8f56a0255 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -33,7 +33,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin shared_memory.header.timestamp = core_timing.GetCPUTicks(); shared_memory.header.total_entry_count = 17; - if (!IsControllerActivated()) { + if (!IsControllerActivated() || !Settings::values.touchscreen.enabled) { shared_memory.header.entry_count = 0; shared_memory.header.last_entry_index = 0; return; diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 2aa1942cb..9c4bf6d16 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -26,6 +26,7 @@ #include "core/hle/service/hid/xcd.h" #include "core/hle/service/service.h" +#include "core/hle/service/hid/controllers/console_sixaxis.h" #include "core/hle/service/hid/controllers/controller_base.h" #include "core/hle/service/hid/controllers/debug_pad.h" #include "core/hle/service/hid/controllers/gesture.h" @@ -67,7 +68,7 @@ IAppletResource::IAppletResource(Core::System& system_) MakeController<Controller_Stubbed>(HidController::UniquePad); MakeController<Controller_NPad>(HidController::NPad); MakeController<Controller_Gesture>(HidController::Gesture); - MakeController<Controller_Stubbed>(HidController::ConsoleSixAxisSensor); + MakeController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor); // Homebrew doesn't try to activate some controllers, so we activate them by default GetController<Controller_NPad>(HidController::NPad).ActivateController(); @@ -78,8 +79,6 @@ IAppletResource::IAppletResource(Core::System& system_) GetController<Controller_Stubbed>(HidController::CaptureButton).SetCommonHeaderOffset(0x5000); GetController<Controller_Stubbed>(HidController::InputDetector).SetCommonHeaderOffset(0x5200); GetController<Controller_Stubbed>(HidController::UniquePad).SetCommonHeaderOffset(0x5A00); - GetController<Controller_Stubbed>(HidController::ConsoleSixAxisSensor) - .SetCommonHeaderOffset(0x3C200); // Register update callbacks pad_update_event = Core::Timing::CreateEvent( @@ -1404,8 +1403,9 @@ void Hid::ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; - LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", - applet_resource_user_id); + applet_resource->ActivateController(HidController::ConsoleSixAxisSensor); + + LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); @@ -1455,8 +1455,9 @@ void Hid::ActivateSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; - LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", - applet_resource_user_id); + applet_resource->ActivateController(HidController::ConsoleSixAxisSensor); + + LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); @@ -1518,8 +1519,15 @@ void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { ASSERT_MSG(t_mem_1->GetSize() == 0x1000, "t_mem_1 has incorrect size"); ASSERT_MSG(t_mem_2->GetSize() == 0x7F000, "t_mem_2 has incorrect size"); + // Activate console six axis controller + applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) + .ActivateController(); + + applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) + .SetTransferMemoryPointer(t_mem_1->GetPointer()); + LOG_WARNING(Service_HID, - "(STUBBED) called, t_mem_1_handle=0x{:08X}, t_mem_2_handle=0x{:08X}, " + "called, t_mem_1_handle=0x{:08X}, t_mem_2_handle=0x{:08X}, " "applet_resource_user_id={}", t_mem_1_handle, t_mem_2_handle, applet_resource_user_id); @@ -1542,8 +1550,10 @@ void Hid::ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; - LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", - applet_resource_user_id); + applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) + .ResetTimestamp(); + + LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index 4e58b9b80..e2f671d8e 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp @@ -31,9 +31,8 @@ NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& return SetSubmitTimeout(input, output); case 0x9: return MapBuffer(input, output); - case 0xa: { + case 0xa: return UnmapBuffer(input, output); - } default: break; } @@ -67,7 +66,8 @@ NvResult nvhost_nvdec::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& void nvhost_nvdec::OnOpen(DeviceFD fd) {} void nvhost_nvdec::OnClose(DeviceFD fd) { - system.GPU().ClearCommandBuffer(); + LOG_INFO(Service_NVDRV, "NVDEC video stream ended"); + system.GPU().ClearCdmaInstance(); } } // 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 0421fb956..301efe8a1 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp @@ -29,13 +29,8 @@ NvResult nvhost_vic::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& i return GetWaitbase(input, output); case 0x9: return MapBuffer(input, output); - case 0xa: { - if (command.length == 0x1c) { - Tegra::ChCommandHeaderList cmdlist{{0xDEADB33F}}; - system.GPU().PushCommandBuffer(cmdlist); - } + case 0xa: return UnmapBuffer(input, output); - } default: break; } @@ -69,6 +64,9 @@ NvResult nvhost_vic::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& i } void nvhost_vic::OnOpen(DeviceFD fd) {} -void nvhost_vic::OnClose(DeviceFD fd) {} + +void nvhost_vic::OnClose(DeviceFD fd) { + system.GPU().ClearCdmaInstance(); +} } // namespace Service::Nvidia::Devices diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 539b02bc4..c43593e7f 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -72,7 +72,7 @@ NVFlinger::NVFlinger(Core::System& system) : system(system) { // Schedule the screen composition events composition_event = Core::Timing::CreateEvent( "ScreenComposition", [this](std::uintptr_t, std::chrono::nanoseconds ns_late) { - const auto guard = Lock(); + const auto lock_guard = Lock(); Compose(); const auto ticks = std::chrono::nanoseconds{GetNextTicks()}; @@ -112,7 +112,7 @@ void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { } std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) { - const auto guard = Lock(); + const auto lock_guard = Lock(); LOG_DEBUG(Service, "Opening \"{}\" display", name); @@ -131,7 +131,7 @@ std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) { } std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { - const auto guard = Lock(); + const auto lock_guard = Lock(); auto* const display = FindDisplay(display_id); if (display == nullptr) { @@ -147,7 +147,7 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { } void NVFlinger::CloseLayer(u64 layer_id) { - const auto guard = Lock(); + const auto lock_guard = Lock(); for (auto& display : displays) { display.CloseLayer(layer_id); @@ -155,7 +155,7 @@ void NVFlinger::CloseLayer(u64 layer_id) { } std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const { - const auto guard = Lock(); + const auto lock_guard = Lock(); const auto* const layer = FindLayer(display_id, layer_id); if (layer == nullptr) { @@ -166,7 +166,7 @@ std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) co } std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id) const { - const auto guard = Lock(); + const auto lock_guard = Lock(); auto* const display = FindDisplay(display_id); if (display == nullptr) { @@ -177,7 +177,7 @@ std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id } BufferQueue* NVFlinger::FindBufferQueue(u32 id) { - const auto guard = Lock(); + const auto lock_guard = Lock(); const auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(), [id](const auto& queue) { return queue->GetId() == id; }); diff --git a/src/core/hle/service/time/standard_user_system_clock_core.cpp b/src/core/hle/service/time/standard_user_system_clock_core.cpp index b9faa474e..3172acc5a 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.cpp +++ b/src/core/hle/service/time/standard_user_system_clock_core.cpp @@ -45,12 +45,12 @@ ResultCode StandardUserSystemClockCore::GetClockContext(Core::System& system, return local_system_clock_core.GetClockContext(system, context); } -ResultCode StandardUserSystemClockCore::Flush(const SystemClockContext& context) { +ResultCode StandardUserSystemClockCore::Flush(const SystemClockContext&) { UNREACHABLE(); return ERROR_NOT_IMPLEMENTED; } -ResultCode StandardUserSystemClockCore::SetClockContext(const SystemClockContext& context) { +ResultCode StandardUserSystemClockCore::SetClockContext(const SystemClockContext&) { UNREACHABLE(); return ERROR_NOT_IMPLEMENTED; } diff --git a/src/core/hle/service/time/standard_user_system_clock_core.h b/src/core/hle/service/time/standard_user_system_clock_core.h index aac44d72f..5bc8bf5c2 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.h +++ b/src/core/hle/service/time/standard_user_system_clock_core.h @@ -39,7 +39,7 @@ public: } protected: - ResultCode Flush(const SystemClockContext& context) override; + ResultCode Flush(const SystemClockContext&) override; ResultCode SetClockContext(const SystemClockContext&) override; diff --git a/src/core/hle/service/time/system_clock_core.cpp b/src/core/hle/service/time/system_clock_core.cpp index d31d4e2ca..46fc8c6c3 100644 --- a/src/core/hle/service/time/system_clock_core.cpp +++ b/src/core/hle/service/time/system_clock_core.cpp @@ -45,18 +45,18 @@ ResultCode SystemClockCore::SetCurrentTime(Core::System& system, s64 posix_time) return Flush(clock_context); } -ResultCode SystemClockCore::Flush(const SystemClockContext& context) { +ResultCode SystemClockCore::Flush(const SystemClockContext& clock_context) { if (!system_clock_context_update_callback) { return RESULT_SUCCESS; } - return system_clock_context_update_callback->Update(context); + return system_clock_context_update_callback->Update(clock_context); } -ResultCode SystemClockCore::SetSystemClockContext(const SystemClockContext& context) { - if (const ResultCode result{SetClockContext(context)}; result != RESULT_SUCCESS) { +ResultCode SystemClockCore::SetSystemClockContext(const SystemClockContext& clock_context) { + if (const ResultCode result{SetClockContext(clock_context)}; result != RESULT_SUCCESS) { return result; } - return Flush(context); + return Flush(clock_context); } bool SystemClockCore::IsClockSetup(Core::System& system) const { diff --git a/src/core/hle/service/time/system_clock_core.h b/src/core/hle/service/time/system_clock_core.h index 608dd3b2e..82a8b79ff 100644 --- a/src/core/hle/service/time/system_clock_core.h +++ b/src/core/hle/service/time/system_clock_core.h @@ -43,7 +43,7 @@ public: return RESULT_SUCCESS; } - virtual ResultCode Flush(const SystemClockContext& context); + virtual ResultCode Flush(const SystemClockContext& clock_context); void SetUpdateCallbackInstance(std::shared_ptr<SystemClockContextUpdateCallback> callback) { system_clock_context_update_callback = std::move(callback); diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp index f89c5aaad..fe01a3739 100644 --- a/src/core/hle/service/time/time_manager.cpp +++ b/src/core/hle/service/time/time_manager.cpp @@ -129,7 +129,7 @@ struct TimeManager::Impl final { return 0; } - void SetupStandardSteadyClock(Core::System& system, Common::UUID clock_source_id, + void SetupStandardSteadyClock(Core::System& system_, Common::UUID clock_source_id, Clock::TimeSpanType setup_value, Clock::TimeSpanType internal_offset, bool is_rtc_reset_detected) { standard_steady_clock_core.SetClockSourceId(clock_source_id); @@ -137,21 +137,21 @@ struct TimeManager::Impl final { standard_steady_clock_core.SetInternalOffset(internal_offset); standard_steady_clock_core.MarkAsInitialized(); - const auto current_time_point{standard_steady_clock_core.GetCurrentRawTimePoint(system)}; - shared_memory.SetupStandardSteadyClock(system, clock_source_id, current_time_point); + const auto current_time_point{standard_steady_clock_core.GetCurrentRawTimePoint(system_)}; + shared_memory.SetupStandardSteadyClock(clock_source_id, current_time_point); } - void SetupStandardLocalSystemClock(Core::System& system, + void SetupStandardLocalSystemClock(Core::System& system_, Clock::SystemClockContext clock_context, s64 posix_time) { standard_local_system_clock_core.SetUpdateCallbackInstance( local_system_clock_context_writer); const auto current_time_point{ - standard_local_system_clock_core.GetSteadyClockCore().GetCurrentTimePoint(system)}; + standard_local_system_clock_core.GetSteadyClockCore().GetCurrentTimePoint(system_)}; if (current_time_point.clock_source_id == clock_context.steady_time_point.clock_source_id) { standard_local_system_clock_core.SetSystemClockContext(clock_context); } else { - if (standard_local_system_clock_core.SetCurrentTime(system, posix_time) != + if (standard_local_system_clock_core.SetCurrentTime(system_, posix_time) != RESULT_SUCCESS) { UNREACHABLE(); return; @@ -177,10 +177,10 @@ struct TimeManager::Impl final { standard_network_system_clock_core.MarkAsInitialized(); } - void SetupStandardUserSystemClock(Core::System& system, bool is_automatic_correction_enabled, + void SetupStandardUserSystemClock(Core::System& system_, bool is_automatic_correction_enabled, Clock::SteadyClockTimePoint steady_clock_time_point) { if (standard_user_system_clock_core.SetAutomaticCorrectionEnabled( - system, is_automatic_correction_enabled) != RESULT_SUCCESS) { + system_, is_automatic_correction_enabled) != RESULT_SUCCESS) { UNREACHABLE(); return; } @@ -196,10 +196,10 @@ struct TimeManager::Impl final { ephemeral_network_system_clock_core.MarkAsInitialized(); } - void UpdateLocalSystemClockTime(Core::System& system, s64 posix_time) { - const auto timespan{Service::Time::Clock::TimeSpanType::FromSeconds(posix_time)}; + void UpdateLocalSystemClockTime(Core::System& system_, s64 posix_time) { + const auto timespan{Clock::TimeSpanType::FromSeconds(posix_time)}; if (GetStandardLocalSystemClockCore() - .SetCurrentTime(system, timespan.ToSeconds()) + .SetCurrentTime(system_, timespan.ToSeconds()) .IsError()) { UNREACHABLE(); return; diff --git a/src/core/hle/service/time/time_sharedmemory.cpp b/src/core/hle/service/time/time_sharedmemory.cpp index 4d8de81be..018ce94ed 100644 --- a/src/core/hle/service/time/time_sharedmemory.cpp +++ b/src/core/hle/service/time/time_sharedmemory.cpp @@ -26,8 +26,7 @@ std::shared_ptr<Kernel::KSharedMemory> SharedMemory::GetSharedMemoryHolder() con return shared_memory_holder; } -void SharedMemory::SetupStandardSteadyClock(Core::System& system, - const Common::UUID& clock_source_id, +void SharedMemory::SetupStandardSteadyClock(const Common::UUID& clock_source_id, Clock::TimeSpanType current_time_point) { const Clock::TimeSpanType ticks_time_span{Clock::TimeSpanType::FromTicks( system.CoreTiming().GetClockTicks(), Core::Hardware::CNTFREQ)}; diff --git a/src/core/hle/service/time/time_sharedmemory.h b/src/core/hle/service/time/time_sharedmemory.h index 299680517..3bc749114 100644 --- a/src/core/hle/service/time/time_sharedmemory.h +++ b/src/core/hle/service/time/time_sharedmemory.h @@ -56,8 +56,8 @@ public: }; static_assert(sizeof(Format) == 0xd8, "Format is an invalid size"); - void SetupStandardSteadyClock(Core::System& system, const Common::UUID& clock_source_id, - Clock::TimeSpanType currentTimePoint); + void SetupStandardSteadyClock(const Common::UUID& clock_source_id, + Clock::TimeSpanType current_time_point); void UpdateLocalSystemClockContext(const Clock::SystemClockContext& context); void UpdateNetworkSystemClockContext(const Clock::SystemClockContext& context); void SetAutomaticCorrectionEnabled(bool is_enabled); diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index 7f42aa4a0..ac9e87338 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -41,24 +41,22 @@ void Display::SignalVSyncEvent() { vsync_event->GetWritableEvent()->Signal(); } -void Display::CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue) { +void Display::CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue) { // TODO(Subv): Support more than 1 layer. ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment"); - layers.emplace_back(std::make_shared<Layer>(id, buffer_queue)); + layers.emplace_back(std::make_shared<Layer>(layer_id, buffer_queue)); } -void Display::CloseLayer(u64 id) { - layers.erase( - std::remove_if(layers.begin(), layers.end(), - [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; }), - layers.end()); +void Display::CloseLayer(u64 layer_id) { + std::erase_if(layers, [layer_id](const auto& layer) { return layer->GetID() == layer_id; }); } -Layer* Display::FindLayer(u64 id) { +Layer* Display::FindLayer(u64 layer_id) { const auto itr = - std::find_if(layers.begin(), layers.end(), - [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; }); + std::find_if(layers.begin(), layers.end(), [layer_id](const std::shared_ptr<Layer>& layer) { + return layer->GetID() == layer_id; + }); if (itr == layers.end()) { return nullptr; @@ -67,10 +65,11 @@ Layer* Display::FindLayer(u64 id) { return itr->get(); } -const Layer* Display::FindLayer(u64 id) const { +const Layer* Display::FindLayer(u64 layer_id) const { const auto itr = - std::find_if(layers.begin(), layers.end(), - [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; }); + std::find_if(layers.begin(), layers.end(), [layer_id](const std::shared_ptr<Layer>& layer) { + return layer->GetID() == layer_id; + }); if (itr == layers.end()) { return nullptr; diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 931c898f6..8340059de 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -68,34 +68,34 @@ public: /// Creates and adds a layer to this display with the given ID. /// - /// @param id The ID to assign to the created layer. + /// @param layer_id The ID to assign to the created layer. /// @param buffer_queue The buffer queue for the layer instance to use. /// - void CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue); + void CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue); /// Closes and removes a layer from this display with the given ID. /// - /// @param id The ID assigned to the layer to close. + /// @param layer_id The ID assigned to the layer to close. /// - void CloseLayer(u64 id); + void CloseLayer(u64 layer_id); /// Attempts to find a layer with the given ID. /// - /// @param id The layer ID. + /// @param layer_id The layer ID. /// /// @returns If found, the Layer instance with the given ID. /// If not found, then nullptr is returned. /// - Layer* FindLayer(u64 id); + Layer* FindLayer(u64 layer_id); /// Attempts to find a layer with the given ID. /// - /// @param id The layer ID. + /// @param layer_id The layer ID. /// /// @returns If found, the Layer instance with the given ID. /// If not found, then nullptr is returned. /// - const Layer* FindLayer(u64 id) const; + const Layer* FindLayer(u64 layer_id) const; private: u64 id; |