early-access version 4118
This commit is contained in:
parent
9e61037e01
commit
e0f3149c76
@ -1,7 +1,7 @@
|
||||
yuzu emulator early access
|
||||
=============
|
||||
|
||||
This is the source code for early-access 4117.
|
||||
This is the source code for early-access 4118.
|
||||
|
||||
## Legal Notice
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/hid/hid_debug_server.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "hid_core/hid_types.h"
|
||||
@ -11,7 +12,6 @@
|
||||
|
||||
#include "hid_core/resources/touch_screen/gesture.h"
|
||||
#include "hid_core/resources/touch_screen/touch_screen.h"
|
||||
#include "hid_core/resources/touch_screen/touch_types.h"
|
||||
|
||||
namespace Service::HID {
|
||||
|
||||
@ -24,14 +24,14 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource
|
||||
{0, nullptr, "DeactivateDebugPad"},
|
||||
{1, nullptr, "SetDebugPadAutoPilotState"},
|
||||
{2, nullptr, "UnsetDebugPadAutoPilotState"},
|
||||
{10, &IHidDebugServer::DeactivateTouchScreen, "DeactivateTouchScreen"},
|
||||
{11, &IHidDebugServer::SetTouchScreenAutoPilotState, "SetTouchScreenAutoPilotState"},
|
||||
{12, &IHidDebugServer::UnsetTouchScreenAutoPilotState, "UnsetTouchScreenAutoPilotState"},
|
||||
{13, &IHidDebugServer::GetTouchScreenConfiguration, "GetTouchScreenConfiguration"},
|
||||
{14, &IHidDebugServer::ProcessTouchScreenAutoTune, "ProcessTouchScreenAutoTune"},
|
||||
{15, &IHidDebugServer::ForceStopTouchScreenManagement, "ForceStopTouchScreenManagement"},
|
||||
{16, &IHidDebugServer::ForceRestartTouchScreenManagement, "ForceRestartTouchScreenManagement"},
|
||||
{17, &IHidDebugServer::IsTouchScreenManaged, "IsTouchScreenManaged"},
|
||||
{10, C<&IHidDebugServer::DeactivateTouchScreen>, "DeactivateTouchScreen"},
|
||||
{11, C<&IHidDebugServer::SetTouchScreenAutoPilotState>, "SetTouchScreenAutoPilotState"},
|
||||
{12, C<&IHidDebugServer::UnsetTouchScreenAutoPilotState>, "UnsetTouchScreenAutoPilotState"},
|
||||
{13, C<&IHidDebugServer::GetTouchScreenConfiguration>, "GetTouchScreenConfiguration"},
|
||||
{14, C<&IHidDebugServer::ProcessTouchScreenAutoTune>, "ProcessTouchScreenAutoTune"},
|
||||
{15, C<&IHidDebugServer::ForceStopTouchScreenManagement>, "ForceStopTouchScreenManagement"},
|
||||
{16, C<&IHidDebugServer::ForceRestartTouchScreenManagement>, "ForceRestartTouchScreenManagement"},
|
||||
{17, C<&IHidDebugServer::IsTouchScreenManaged>, "IsTouchScreenManaged"},
|
||||
{20, nullptr, "DeactivateMouse"},
|
||||
{21, nullptr, "SetMouseAutoPilotState"},
|
||||
{22, nullptr, "UnsetMouseAutoPilotState"},
|
||||
@ -47,7 +47,7 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource
|
||||
{60, nullptr, "ClearNpadSystemCommonPolicy"},
|
||||
{61, nullptr, "DeactivateNpad"},
|
||||
{62, nullptr, "ForceDisconnectNpad"},
|
||||
{91, &IHidDebugServer::DeactivateGesture, "DeactivateGesture"},
|
||||
{91, C<&IHidDebugServer::DeactivateGesture>, "DeactivateGesture"},
|
||||
{110, nullptr, "DeactivateHomeButton"},
|
||||
{111, nullptr, "SetHomeButtonAutoPilotState"},
|
||||
{112, nullptr, "UnsetHomeButtonAutoPilotState"},
|
||||
@ -160,169 +160,122 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource
|
||||
}
|
||||
|
||||
IHidDebugServer::~IHidDebugServer() = default;
|
||||
void IHidDebugServer::DeactivateTouchScreen(HLERequestContext& ctx) {
|
||||
|
||||
Result IHidDebugServer::DeactivateTouchScreen() {
|
||||
LOG_INFO(Service_HID, "called");
|
||||
|
||||
Result result = ResultSuccess;
|
||||
|
||||
if (!firmware_settings->IsDeviceManaged()) {
|
||||
result = GetResourceManager()->GetTouchScreen()->Deactivate();
|
||||
R_RETURN(GetResourceManager()->GetTouchScreen()->Deactivate());
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IHidDebugServer::SetTouchScreenAutoPilotState(HLERequestContext& ctx) {
|
||||
Result IHidDebugServer::SetTouchScreenAutoPilotState(
|
||||
InArray<TouchState, BufferAttr_HipcMapAlias> auto_pilot_buffer) {
|
||||
AutoPilotState auto_pilot{};
|
||||
auto_pilot.count = ctx.GetReadBufferNumElements<TouchState>();
|
||||
const auto buffer = ctx.ReadBuffer();
|
||||
|
||||
auto_pilot.count = std::min(auto_pilot.count, static_cast<u64>(auto_pilot.state.size()));
|
||||
memcpy(auto_pilot.state.data(), buffer.data(), auto_pilot.count * sizeof(TouchState));
|
||||
auto_pilot.count =
|
||||
static_cast<u64>(std::min(auto_pilot_buffer.size(), auto_pilot.state.size()));
|
||||
memcpy(auto_pilot.state.data(), auto_pilot_buffer.data(),
|
||||
auto_pilot.count * sizeof(TouchState));
|
||||
|
||||
LOG_INFO(Service_HID, "called, auto_pilot_count={}", auto_pilot.count);
|
||||
|
||||
const Result result =
|
||||
GetResourceManager()->GetTouchScreen()->SetTouchScreenAutoPilotState(auto_pilot);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_RETURN(GetResourceManager()->GetTouchScreen()->SetTouchScreenAutoPilotState(auto_pilot));
|
||||
}
|
||||
|
||||
void IHidDebugServer::UnsetTouchScreenAutoPilotState(HLERequestContext& ctx) {
|
||||
Result IHidDebugServer::UnsetTouchScreenAutoPilotState() {
|
||||
LOG_INFO(Service_HID, "called");
|
||||
|
||||
const Result result = GetResourceManager()->GetTouchScreen()->UnsetTouchScreenAutoPilotState();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_RETURN(GetResourceManager()->GetTouchScreen()->UnsetTouchScreenAutoPilotState());
|
||||
}
|
||||
|
||||
void IHidDebugServer::GetTouchScreenConfiguration(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
Result IHidDebugServer::GetTouchScreenConfiguration(
|
||||
Out<Core::HID::TouchScreenConfigurationForNx> out_touchscreen_config,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
|
||||
|
||||
LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||
R_TRY(GetResourceManager()->GetTouchScreen()->GetTouchScreenConfiguration(
|
||||
*out_touchscreen_config, aruid.pid));
|
||||
|
||||
Core::HID::TouchScreenConfigurationForNx touchscreen_config{};
|
||||
const Result result = GetResourceManager()->GetTouchScreen()->GetTouchScreenConfiguration(
|
||||
touchscreen_config, applet_resource_user_id);
|
||||
|
||||
if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
|
||||
touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
|
||||
touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
|
||||
if (out_touchscreen_config->mode != Core::HID::TouchScreenModeForNx::Heat2 &&
|
||||
out_touchscreen_config->mode != Core::HID::TouchScreenModeForNx::Finger) {
|
||||
out_touchscreen_config->mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 6};
|
||||
rb.Push(result);
|
||||
rb.PushRaw(touchscreen_config);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IHidDebugServer::ProcessTouchScreenAutoTune(HLERequestContext& ctx) {
|
||||
Result IHidDebugServer::ProcessTouchScreenAutoTune() {
|
||||
LOG_INFO(Service_HID, "called");
|
||||
|
||||
Result result = GetResourceManager()->GetTouchScreen()->ProcessTouchScreenAutoTune();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_RETURN(GetResourceManager()->GetTouchScreen()->ProcessTouchScreenAutoTune());
|
||||
}
|
||||
|
||||
void IHidDebugServer::ForceStopTouchScreenManagement(HLERequestContext& ctx) {
|
||||
Result IHidDebugServer::ForceStopTouchScreenManagement() {
|
||||
LOG_INFO(Service_HID, "called");
|
||||
|
||||
if (!firmware_settings->IsDeviceManaged()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
return;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result result = ResultSuccess;
|
||||
bool is_touch_active{};
|
||||
bool is_gesture_active{};
|
||||
auto touch_screen = GetResourceManager()->GetTouchScreen();
|
||||
auto gesture = GetResourceManager()->GetGesture();
|
||||
|
||||
if (firmware_settings->IsTouchI2cManaged()) {
|
||||
result = touch_screen->IsActive(is_touch_active);
|
||||
if (result.IsSuccess()) {
|
||||
result = gesture->IsActive(is_gesture_active);
|
||||
bool is_touch_active{};
|
||||
bool is_gesture_active{};
|
||||
R_TRY(touch_screen->IsActive(is_touch_active));
|
||||
R_TRY(gesture->IsActive(is_gesture_active));
|
||||
|
||||
if (is_touch_active) {
|
||||
R_TRY(touch_screen->Deactivate());
|
||||
}
|
||||
if (result.IsSuccess() && is_touch_active) {
|
||||
result = touch_screen->Deactivate();
|
||||
}
|
||||
if (result.IsSuccess() && is_gesture_active) {
|
||||
result = gesture->Deactivate();
|
||||
if (is_gesture_active) {
|
||||
R_TRY(gesture->Deactivate());
|
||||
}
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IHidDebugServer::ForceRestartTouchScreenManagement(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
u32 basic_gesture_id;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
Result IHidDebugServer::ForceRestartTouchScreenManagement(u32 basic_gesture_id,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_INFO(Service_HID, "called, basic_gesture_id={}, applet_resource_user_id={}",
|
||||
parameters.basic_gesture_id, parameters.applet_resource_user_id);
|
||||
basic_gesture_id, aruid.pid);
|
||||
|
||||
Result result = ResultSuccess;
|
||||
auto touch_screen = GetResourceManager()->GetTouchScreen();
|
||||
auto gesture = GetResourceManager()->GetGesture();
|
||||
|
||||
if (firmware_settings->IsDeviceManaged() && firmware_settings->IsTouchI2cManaged()) {
|
||||
result = gesture->Activate();
|
||||
if (result.IsSuccess()) {
|
||||
result =
|
||||
gesture->Activate(parameters.applet_resource_user_id, parameters.basic_gesture_id);
|
||||
}
|
||||
if (result.IsSuccess()) {
|
||||
result = touch_screen->Activate();
|
||||
}
|
||||
if (result.IsSuccess()) {
|
||||
result = touch_screen->Activate(parameters.applet_resource_user_id);
|
||||
}
|
||||
R_TRY(gesture->Activate());
|
||||
R_TRY(gesture->Activate(aruid.pid, basic_gesture_id));
|
||||
R_TRY(touch_screen->Activate());
|
||||
R_TRY(touch_screen->Activate(aruid.pid));
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IHidDebugServer::IsTouchScreenManaged(HLERequestContext& ctx) {
|
||||
Result IHidDebugServer::IsTouchScreenManaged(Out<bool> out_is_managed) {
|
||||
LOG_INFO(Service_HID, "called");
|
||||
|
||||
bool is_touch_active{};
|
||||
bool is_gesture_active{};
|
||||
R_TRY(GetResourceManager()->GetTouchScreen()->IsActive(is_touch_active));
|
||||
R_TRY(GetResourceManager()->GetGesture()->IsActive(is_gesture_active));
|
||||
|
||||
Result result = GetResourceManager()->GetTouchScreen()->IsActive(is_touch_active);
|
||||
if (result.IsSuccess()) {
|
||||
result = GetResourceManager()->GetGesture()->IsActive(is_gesture_active);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(result);
|
||||
rb.Push(is_touch_active | is_gesture_active);
|
||||
*out_is_managed = is_touch_active || is_gesture_active;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IHidDebugServer::DeactivateGesture(HLERequestContext& ctx) {
|
||||
Result IHidDebugServer::DeactivateGesture() {
|
||||
LOG_INFO(Service_HID, "called");
|
||||
|
||||
Result result = ResultSuccess;
|
||||
|
||||
if (!firmware_settings->IsDeviceManaged()) {
|
||||
result = GetResourceManager()->GetGesture()->Deactivate();
|
||||
R_RETURN(GetResourceManager()->GetGesture()->Deactivate());
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
std::shared_ptr<ResourceManager> IHidDebugServer::GetResourceManager() {
|
||||
|
@ -3,7 +3,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
#include "hid_core/resources/touch_screen/touch_types.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
@ -20,15 +22,19 @@ public:
|
||||
~IHidDebugServer() override;
|
||||
|
||||
private:
|
||||
void DeactivateTouchScreen(HLERequestContext& ctx);
|
||||
void SetTouchScreenAutoPilotState(HLERequestContext& ctx);
|
||||
void UnsetTouchScreenAutoPilotState(HLERequestContext& ctx);
|
||||
void GetTouchScreenConfiguration(HLERequestContext& ctx);
|
||||
void ProcessTouchScreenAutoTune(HLERequestContext& ctx);
|
||||
void ForceStopTouchScreenManagement(HLERequestContext& ctx);
|
||||
void ForceRestartTouchScreenManagement(HLERequestContext& ctx);
|
||||
void IsTouchScreenManaged(HLERequestContext& ctx);
|
||||
void DeactivateGesture(HLERequestContext& ctx);
|
||||
Result DeactivateTouchScreen();
|
||||
Result SetTouchScreenAutoPilotState(
|
||||
InArray<TouchState, BufferAttr_HipcMapAlias> auto_pilot_buffer);
|
||||
Result UnsetTouchScreenAutoPilotState();
|
||||
Result GetTouchScreenConfiguration(
|
||||
Out<Core::HID::TouchScreenConfigurationForNx> out_touchscreen_config,
|
||||
ClientAppletResourceUserId aruid);
|
||||
Result ProcessTouchScreenAutoTune();
|
||||
Result ForceStopTouchScreenManagement();
|
||||
Result ForceRestartTouchScreenManagement(u32 basic_gesture_id,
|
||||
ClientAppletResourceUserId aruid);
|
||||
Result IsTouchScreenManaged(Out<bool> out_is_managed);
|
||||
Result DeactivateGesture();
|
||||
|
||||
std::shared_ptr<ResourceManager> GetResourceManager();
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "core/hle/kernel/k_shared_memory.h"
|
||||
#include "core/hle/kernel/k_transfer_memory.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/hid/irs.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/memory.h"
|
||||
@ -28,24 +29,24 @@ namespace Service::IRS {
|
||||
IRS::IRS(Core::System& system_) : ServiceFramework{system_, "irs"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{302, &IRS::ActivateIrsensor, "ActivateIrsensor"},
|
||||
{303, &IRS::DeactivateIrsensor, "DeactivateIrsensor"},
|
||||
{304, &IRS::GetIrsensorSharedMemoryHandle, "GetIrsensorSharedMemoryHandle"},
|
||||
{305, &IRS::StopImageProcessor, "StopImageProcessor"},
|
||||
{306, &IRS::RunMomentProcessor, "RunMomentProcessor"},
|
||||
{307, &IRS::RunClusteringProcessor, "RunClusteringProcessor"},
|
||||
{308, &IRS::RunImageTransferProcessor, "RunImageTransferProcessor"},
|
||||
{309, &IRS::GetImageTransferProcessorState, "GetImageTransferProcessorState"},
|
||||
{310, &IRS::RunTeraPluginProcessor, "RunTeraPluginProcessor"},
|
||||
{311, &IRS::GetNpadIrCameraHandle, "GetNpadIrCameraHandle"},
|
||||
{312, &IRS::RunPointingProcessor, "RunPointingProcessor"},
|
||||
{313, &IRS::SuspendImageProcessor, "SuspendImageProcessor"},
|
||||
{314, &IRS::CheckFirmwareVersion, "CheckFirmwareVersion"},
|
||||
{315, &IRS::SetFunctionLevel, "SetFunctionLevel"},
|
||||
{316, &IRS::RunImageTransferExProcessor, "RunImageTransferExProcessor"},
|
||||
{317, &IRS::RunIrLedProcessor, "RunIrLedProcessor"},
|
||||
{318, &IRS::StopImageProcessorAsync, "StopImageProcessorAsync"},
|
||||
{319, &IRS::ActivateIrsensorWithFunctionLevel, "ActivateIrsensorWithFunctionLevel"},
|
||||
{302, C<&IRS::ActivateIrsensor>, "ActivateIrsensor"},
|
||||
{303, C<&IRS::DeactivateIrsensor>, "DeactivateIrsensor"},
|
||||
{304, C<&IRS::GetIrsensorSharedMemoryHandle>, "GetIrsensorSharedMemoryHandle"},
|
||||
{305, C<&IRS::StopImageProcessor>, "StopImageProcessor"},
|
||||
{306, C<&IRS::RunMomentProcessor>, "RunMomentProcessor"},
|
||||
{307, C<&IRS::RunClusteringProcessor>, "RunClusteringProcessor"},
|
||||
{308, C<&IRS::RunImageTransferProcessor>, "RunImageTransferProcessor"},
|
||||
{309, C<&IRS::GetImageTransferProcessorState>, "GetImageTransferProcessorState"},
|
||||
{310, C<&IRS::RunTeraPluginProcessor>, "RunTeraPluginProcessor"},
|
||||
{311, C<&IRS::GetNpadIrCameraHandle>, "GetNpadIrCameraHandle"},
|
||||
{312, C<&IRS::RunPointingProcessor>, "RunPointingProcessor"},
|
||||
{313, C<&IRS::SuspendImageProcessor>, "SuspendImageProcessor"},
|
||||
{314, C<&IRS::CheckFirmwareVersion>, "CheckFirmwareVersion"},
|
||||
{315, C<&IRS::SetFunctionLevel>, "SetFunctionLevel"},
|
||||
{316, C<&IRS::RunImageTransferExProcessor>, "RunImageTransferExProcessor"},
|
||||
{317, C<&IRS::RunIrLedProcessor>, "RunIrLedProcessor"},
|
||||
{318, C<&IRS::StopImageProcessorAsync>, "StopImageProcessorAsync"},
|
||||
{319, C<&IRS::ActivateIrsensorWithFunctionLevel>, "ActivateIrsensorWithFunctionLevel"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@ -57,489 +58,292 @@ IRS::IRS(Core::System& system_) : ServiceFramework{system_, "irs"} {
|
||||
}
|
||||
IRS::~IRS() = default;
|
||||
|
||||
void IRS::ActivateIrsensor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}",
|
||||
applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
Result IRS::ActivateIrsensor(ClientAppletResourceUserId aruid) {
|
||||
LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}", aruid.pid);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::DeactivateIrsensor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}",
|
||||
applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
Result IRS::DeactivateIrsensor(ClientAppletResourceUserId aruid) {
|
||||
LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}", aruid.pid);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::GetIrsensorSharedMemoryHandle(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
Result IRS::GetIrsensorSharedMemoryHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_DEBUG(Service_IRS, "called, applet_resource_user_id={}", aruid.pid);
|
||||
|
||||
LOG_DEBUG(Service_IRS, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushCopyObjects(&system.Kernel().GetIrsSharedMem());
|
||||
*out_shared_memory = &system.Kernel().GetIrsSharedMem();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::StopImageProcessor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
Core::IrSensor::IrCameraHandle camera_handle;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
Result IRS::StopImageProcessor(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_WARNING(Service_IRS,
|
||||
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
|
||||
parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
|
||||
parameters.applet_resource_user_id);
|
||||
camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
|
||||
|
||||
auto result = IsIrCameraHandleValid(parameters.camera_handle);
|
||||
if (result.IsSuccess()) {
|
||||
// TODO: Stop Image processor
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::Active);
|
||||
result = ResultSuccess;
|
||||
}
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
// TODO: Stop Image processor
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::Active);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::RunMomentProcessor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
Core::IrSensor::IrCameraHandle camera_handle;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
Core::IrSensor::PackedMomentProcessorConfig processor_config;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x30, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
Result IRS::RunMomentProcessor(
|
||||
Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
|
||||
const Core::IrSensor::PackedMomentProcessorConfig& processor_config) {
|
||||
LOG_WARNING(Service_IRS,
|
||||
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
|
||||
parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
|
||||
parameters.applet_resource_user_id);
|
||||
camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
|
||||
|
||||
const auto result = IsIrCameraHandleValid(parameters.camera_handle);
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
|
||||
MakeProcessorWithCoreContext<MomentProcessor>(parameters.camera_handle, device);
|
||||
auto& image_transfer_processor = GetProcessor<MomentProcessor>(parameters.camera_handle);
|
||||
image_transfer_processor.SetConfig(parameters.processor_config);
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
}
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
|
||||
MakeProcessorWithCoreContext<MomentProcessor>(camera_handle, device);
|
||||
auto& image_transfer_processor = GetProcessor<MomentProcessor>(camera_handle);
|
||||
image_transfer_processor.SetConfig(processor_config);
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::RunClusteringProcessor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
Core::IrSensor::IrCameraHandle camera_handle;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
Core::IrSensor::PackedClusteringProcessorConfig processor_config;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x38, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
Result IRS::RunClusteringProcessor(
|
||||
Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
|
||||
const Core::IrSensor::PackedClusteringProcessorConfig& processor_config) {
|
||||
LOG_WARNING(Service_IRS,
|
||||
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
|
||||
parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
|
||||
parameters.applet_resource_user_id);
|
||||
camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
|
||||
|
||||
auto result = IsIrCameraHandleValid(parameters.camera_handle);
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
|
||||
MakeProcessorWithCoreContext<ClusteringProcessor>(parameters.camera_handle, device);
|
||||
auto& image_transfer_processor =
|
||||
GetProcessor<ClusteringProcessor>(parameters.camera_handle);
|
||||
image_transfer_processor.SetConfig(parameters.processor_config);
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
}
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
|
||||
MakeProcessorWithCoreContext<ClusteringProcessor>(camera_handle, device);
|
||||
auto& image_transfer_processor = GetProcessor<ClusteringProcessor>(camera_handle);
|
||||
image_transfer_processor.SetConfig(processor_config);
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::RunImageTransferProcessor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
Core::IrSensor::IrCameraHandle camera_handle;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
Core::IrSensor::PackedImageTransferProcessorConfig processor_config;
|
||||
u32 transfer_memory_size;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x30, "Parameters has incorrect size.");
|
||||
Result IRS::RunImageTransferProcessor(
|
||||
Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
|
||||
const Core::IrSensor::PackedImageTransferProcessorConfig& processor_config,
|
||||
u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem) {
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
const auto t_mem_handle{ctx.GetCopyHandle(0)};
|
||||
|
||||
auto t_mem = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(t_mem_handle);
|
||||
|
||||
if (t_mem.IsNull()) {
|
||||
LOG_ERROR(Service_IRS, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultUnknown);
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT_MSG(t_mem->GetSize() == parameters.transfer_memory_size, "t_mem has incorrect size");
|
||||
ASSERT_MSG(t_mem->GetSize() == transfer_memory_size, "t_mem has incorrect size");
|
||||
|
||||
LOG_INFO(Service_IRS,
|
||||
"called, npad_type={}, npad_id={}, transfer_memory_size={}, transfer_memory_size={}, "
|
||||
"applet_resource_user_id={}",
|
||||
parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
|
||||
parameters.transfer_memory_size, t_mem->GetSize(), parameters.applet_resource_user_id);
|
||||
camera_handle.npad_type, camera_handle.npad_id, transfer_memory_size, t_mem->GetSize(),
|
||||
aruid.pid);
|
||||
|
||||
const auto result = IsIrCameraHandleValid(parameters.camera_handle);
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
|
||||
MakeProcessorWithCoreContext<ImageTransferProcessor>(parameters.camera_handle, device);
|
||||
auto& image_transfer_processor =
|
||||
GetProcessor<ImageTransferProcessor>(parameters.camera_handle);
|
||||
image_transfer_processor.SetConfig(parameters.processor_config);
|
||||
image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress());
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
}
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
|
||||
MakeProcessorWithCoreContext<ImageTransferProcessor>(camera_handle, device);
|
||||
auto& image_transfer_processor = GetProcessor<ImageTransferProcessor>(camera_handle);
|
||||
image_transfer_processor.SetConfig(processor_config);
|
||||
image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress());
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::GetImageTransferProcessorState(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
Core::IrSensor::IrCameraHandle camera_handle;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
Result IRS::GetImageTransferProcessorState(
|
||||
Out<Core::IrSensor::ImageTransferProcessorState> out_state,
|
||||
Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
|
||||
OutBuffer<BufferAttr_HipcMapAlias> out_buffer_data) {
|
||||
LOG_DEBUG(Service_IRS, "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
|
||||
parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
|
||||
parameters.applet_resource_user_id);
|
||||
camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
|
||||
|
||||
const auto result = IsIrCameraHandleValid(parameters.camera_handle);
|
||||
if (result.IsError()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
return;
|
||||
}
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
const auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
|
||||
const auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
|
||||
|
||||
if (device.mode != Core::IrSensor::IrSensorMode::ImageTransferProcessor) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(InvalidProcessorState);
|
||||
return;
|
||||
}
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
R_UNLESS(device.mode == Core::IrSensor::IrSensorMode::ImageTransferProcessor,
|
||||
InvalidProcessorState);
|
||||
|
||||
std::vector<u8> data{};
|
||||
const auto& image_transfer_processor =
|
||||
GetProcessor<ImageTransferProcessor>(parameters.camera_handle);
|
||||
const auto& state = image_transfer_processor.GetState(data);
|
||||
*out_state = GetProcessor<ImageTransferProcessor>(camera_handle).GetState(out_buffer_data);
|
||||
|
||||
ctx.WriteBuffer(data);
|
||||
IPC::ResponseBuilder rb{ctx, 6};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(state);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::RunTeraPluginProcessor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
Core::IrSensor::IrCameraHandle camera_handle;
|
||||
Core::IrSensor::PackedTeraPluginProcessorConfig processor_config;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
|
||||
Result IRS::RunTeraPluginProcessor(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
Core::IrSensor::PackedTeraPluginProcessorConfig processor_config,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_WARNING(Service_IRS,
|
||||
"(STUBBED) called, npad_type={}, npad_id={}, mode={}, mcu_version={}.{}, "
|
||||
"applet_resource_user_id={}",
|
||||
camera_handle.npad_type, camera_handle.npad_id, processor_config.mode,
|
||||
processor_config.required_mcu_version.major,
|
||||
processor_config.required_mcu_version.minor, aruid.pid);
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
LOG_WARNING(
|
||||
Service_IRS,
|
||||
"(STUBBED) called, npad_type={}, npad_id={}, mode={}, mcu_version={}.{}, "
|
||||
"applet_resource_user_id={}",
|
||||
parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
|
||||
parameters.processor_config.mode, parameters.processor_config.required_mcu_version.major,
|
||||
parameters.processor_config.required_mcu_version.minor, parameters.applet_resource_user_id);
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
|
||||
MakeProcessor<TeraPluginProcessor>(camera_handle, device);
|
||||
auto& image_transfer_processor = GetProcessor<TeraPluginProcessor>(camera_handle);
|
||||
image_transfer_processor.SetConfig(processor_config);
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
|
||||
const auto result = IsIrCameraHandleValid(parameters.camera_handle);
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
|
||||
MakeProcessor<TeraPluginProcessor>(parameters.camera_handle, device);
|
||||
auto& image_transfer_processor =
|
||||
GetProcessor<TeraPluginProcessor>(parameters.camera_handle);
|
||||
image_transfer_processor.SetConfig(parameters.processor_config);
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::GetNpadIrCameraHandle(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()};
|
||||
Result IRS::GetNpadIrCameraHandle(Out<Core::IrSensor::IrCameraHandle> out_camera_handle,
|
||||
Core::HID::NpadIdType npad_id) {
|
||||
R_UNLESS(HID::IsNpadIdValid(npad_id), HID::ResultInvalidNpadId);
|
||||
|
||||
if (npad_id > Core::HID::NpadIdType::Player8 && npad_id != Core::HID::NpadIdType::Invalid &&
|
||||
npad_id != Core::HID::NpadIdType::Handheld) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(Service::HID::ResultInvalidNpadId);
|
||||
return;
|
||||
}
|
||||
|
||||
Core::IrSensor::IrCameraHandle camera_handle{
|
||||
*out_camera_handle = {
|
||||
.npad_id = static_cast<u8>(HID::NpadIdTypeToIndex(npad_id)),
|
||||
.npad_type = Core::HID::NpadStyleIndex::None,
|
||||
};
|
||||
|
||||
LOG_INFO(Service_IRS, "called, npad_id={}, camera_npad_id={}, camera_npad_type={}", npad_id,
|
||||
camera_handle.npad_id, camera_handle.npad_type);
|
||||
out_camera_handle->npad_id, out_camera_handle->npad_type);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(camera_handle);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::RunPointingProcessor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()};
|
||||
const auto processor_config{rp.PopRaw<Core::IrSensor::PackedPointingProcessorConfig>()};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
Result IRS::RunPointingProcessor(
|
||||
Core::IrSensor::IrCameraHandle camera_handle,
|
||||
const Core::IrSensor::PackedPointingProcessorConfig& processor_config,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_WARNING(
|
||||
Service_IRS,
|
||||
"(STUBBED) called, npad_type={}, npad_id={}, mcu_version={}.{}, applet_resource_user_id={}",
|
||||
camera_handle.npad_type, camera_handle.npad_id, processor_config.required_mcu_version.major,
|
||||
processor_config.required_mcu_version.minor, applet_resource_user_id);
|
||||
processor_config.required_mcu_version.minor, aruid.pid);
|
||||
|
||||
auto result = IsIrCameraHandleValid(camera_handle);
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
|
||||
MakeProcessor<PointingProcessor>(camera_handle, device);
|
||||
auto& image_transfer_processor = GetProcessor<PointingProcessor>(camera_handle);
|
||||
image_transfer_processor.SetConfig(processor_config);
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
}
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
|
||||
MakeProcessor<PointingProcessor>(camera_handle, device);
|
||||
auto& image_transfer_processor = GetProcessor<PointingProcessor>(camera_handle);
|
||||
image_transfer_processor.SetConfig(processor_config);
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::SuspendImageProcessor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
Core::IrSensor::IrCameraHandle camera_handle;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
Result IRS::SuspendImageProcessor(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_WARNING(Service_IRS,
|
||||
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
|
||||
parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
|
||||
parameters.applet_resource_user_id);
|
||||
camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
|
||||
|
||||
auto result = IsIrCameraHandleValid(parameters.camera_handle);
|
||||
if (result.IsSuccess()) {
|
||||
// TODO: Suspend image processor
|
||||
result = ResultSuccess;
|
||||
}
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
// TODO: Suspend image processor
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::CheckFirmwareVersion(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()};
|
||||
const auto mcu_version{rp.PopRaw<Core::IrSensor::PackedMcuVersion>()};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
Result IRS::CheckFirmwareVersion(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
Core::IrSensor::PackedMcuVersion mcu_version,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_WARNING(
|
||||
Service_IRS,
|
||||
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}, mcu_version={}.{}",
|
||||
camera_handle.npad_type, camera_handle.npad_id, applet_resource_user_id, mcu_version.major,
|
||||
camera_handle.npad_type, camera_handle.npad_id, aruid.pid, mcu_version.major,
|
||||
mcu_version.minor);
|
||||
|
||||
auto result = IsIrCameraHandleValid(camera_handle);
|
||||
if (result.IsSuccess()) {
|
||||
// TODO: Check firmware version
|
||||
result = ResultSuccess;
|
||||
}
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
// TODO: Check firmware version
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::SetFunctionLevel(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()};
|
||||
const auto function_level{rp.PopRaw<Core::IrSensor::PackedFunctionLevel>()};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
Result IRS::SetFunctionLevel(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
Core::IrSensor::PackedFunctionLevel function_level,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_WARNING(
|
||||
Service_IRS,
|
||||
"(STUBBED) called, npad_type={}, npad_id={}, function_level={}, applet_resource_user_id={}",
|
||||
camera_handle.npad_type, camera_handle.npad_id, function_level.function_level,
|
||||
applet_resource_user_id);
|
||||
camera_handle.npad_type, camera_handle.npad_id, function_level.function_level, aruid.pid);
|
||||
|
||||
auto result = IsIrCameraHandleValid(camera_handle);
|
||||
if (result.IsSuccess()) {
|
||||
// TODO: Set Function level
|
||||
result = ResultSuccess;
|
||||
}
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
// TODO: Set Function level
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::RunImageTransferExProcessor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
Core::IrSensor::IrCameraHandle camera_handle;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
Core::IrSensor::PackedImageTransferProcessorExConfig processor_config;
|
||||
u64 transfer_memory_size;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x38, "Parameters has incorrect size.");
|
||||
Result IRS::RunImageTransferExProcessor(
|
||||
Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
|
||||
const Core::IrSensor::PackedImageTransferProcessorExConfig& processor_config,
|
||||
u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem) {
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
const auto t_mem_handle{ctx.GetCopyHandle(0)};
|
||||
|
||||
auto t_mem = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(t_mem_handle);
|
||||
ASSERT_MSG(t_mem->GetSize() == transfer_memory_size, "t_mem has incorrect size");
|
||||
|
||||
LOG_INFO(Service_IRS,
|
||||
"called, npad_type={}, npad_id={}, transfer_memory_size={}, "
|
||||
"applet_resource_user_id={}",
|
||||
parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
|
||||
parameters.transfer_memory_size, parameters.applet_resource_user_id);
|
||||
camera_handle.npad_type, camera_handle.npad_id, transfer_memory_size, aruid.pid);
|
||||
|
||||
auto result = IsIrCameraHandleValid(parameters.camera_handle);
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
|
||||
MakeProcessorWithCoreContext<ImageTransferProcessor>(parameters.camera_handle, device);
|
||||
auto& image_transfer_processor =
|
||||
GetProcessor<ImageTransferProcessor>(parameters.camera_handle);
|
||||
image_transfer_processor.SetConfig(parameters.processor_config);
|
||||
image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress());
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
}
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
|
||||
MakeProcessorWithCoreContext<ImageTransferProcessor>(camera_handle, device);
|
||||
auto& image_transfer_processor = GetProcessor<ImageTransferProcessor>(camera_handle);
|
||||
image_transfer_processor.SetConfig(processor_config);
|
||||
image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress());
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::RunIrLedProcessor(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()};
|
||||
const auto processor_config{rp.PopRaw<Core::IrSensor::PackedIrLedProcessorConfig>()};
|
||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||
|
||||
Result IRS::RunIrLedProcessor(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
Core::IrSensor::PackedIrLedProcessorConfig processor_config,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_WARNING(Service_IRS,
|
||||
"(STUBBED) called, npad_type={}, npad_id={}, light_target={}, mcu_version={}.{} "
|
||||
"applet_resource_user_id={}",
|
||||
camera_handle.npad_type, camera_handle.npad_id, processor_config.light_target,
|
||||
processor_config.required_mcu_version.major,
|
||||
processor_config.required_mcu_version.minor, applet_resource_user_id);
|
||||
processor_config.required_mcu_version.minor, aruid.pid);
|
||||
|
||||
auto result = IsIrCameraHandleValid(camera_handle);
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
if (result.IsSuccess()) {
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
|
||||
MakeProcessor<IrLedProcessor>(camera_handle, device);
|
||||
auto& image_transfer_processor = GetProcessor<IrLedProcessor>(camera_handle);
|
||||
image_transfer_processor.SetConfig(processor_config);
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
}
|
||||
auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
|
||||
MakeProcessor<IrLedProcessor>(camera_handle, device);
|
||||
auto& image_transfer_processor = GetProcessor<IrLedProcessor>(camera_handle);
|
||||
image_transfer_processor.SetConfig(processor_config);
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::IR);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::StopImageProcessorAsync(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
Core::IrSensor::IrCameraHandle camera_handle;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
Result IRS::StopImageProcessorAsync(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_WARNING(Service_IRS,
|
||||
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
|
||||
parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
|
||||
parameters.applet_resource_user_id);
|
||||
camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
|
||||
|
||||
auto result = IsIrCameraHandleValid(parameters.camera_handle);
|
||||
if (result.IsSuccess()) {
|
||||
// TODO: Stop image processor async
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::Active);
|
||||
result = ResultSuccess;
|
||||
}
|
||||
R_TRY(IsIrCameraHandleValid(camera_handle));
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(result);
|
||||
// TODO: Stop image processor async
|
||||
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
|
||||
Common::Input::PollingMode::Active);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void IRS::ActivateIrsensorWithFunctionLevel(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
Core::IrSensor::PackedFunctionLevel function_level;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
u64 applet_resource_user_id;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
Result IRS::ActivateIrsensorWithFunctionLevel(Core::IrSensor::PackedFunctionLevel function_level,
|
||||
ClientAppletResourceUserId aruid) {
|
||||
LOG_WARNING(Service_IRS, "(STUBBED) called, function_level={}, applet_resource_user_id={}",
|
||||
parameters.function_level.function_level, parameters.applet_resource_user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
function_level.function_level, aruid.pid);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result IRS::IsIrCameraHandleValid(const Core::IrSensor::IrCameraHandle& camera_handle) const {
|
||||
|
@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
#include "hid_core/hid_types.h"
|
||||
#include "hid_core/irsensor/irs_types.h"
|
||||
@ -35,26 +36,73 @@ private:
|
||||
};
|
||||
static_assert(sizeof(StatusManager) == 0x8000, "StatusManager is an invalid size");
|
||||
|
||||
void ActivateIrsensor(HLERequestContext& ctx);
|
||||
void DeactivateIrsensor(HLERequestContext& ctx);
|
||||
void GetIrsensorSharedMemoryHandle(HLERequestContext& ctx);
|
||||
void StopImageProcessor(HLERequestContext& ctx);
|
||||
void RunMomentProcessor(HLERequestContext& ctx);
|
||||
void RunClusteringProcessor(HLERequestContext& ctx);
|
||||
void RunImageTransferProcessor(HLERequestContext& ctx);
|
||||
void GetImageTransferProcessorState(HLERequestContext& ctx);
|
||||
void RunTeraPluginProcessor(HLERequestContext& ctx);
|
||||
void GetNpadIrCameraHandle(HLERequestContext& ctx);
|
||||
void RunPointingProcessor(HLERequestContext& ctx);
|
||||
void SuspendImageProcessor(HLERequestContext& ctx);
|
||||
void CheckFirmwareVersion(HLERequestContext& ctx);
|
||||
void SetFunctionLevel(HLERequestContext& ctx);
|
||||
void RunImageTransferExProcessor(HLERequestContext& ctx);
|
||||
void RunIrLedProcessor(HLERequestContext& ctx);
|
||||
void StopImageProcessorAsync(HLERequestContext& ctx);
|
||||
void ActivateIrsensorWithFunctionLevel(HLERequestContext& ctx);
|
||||
Result ActivateIrsensor(ClientAppletResourceUserId aruid);
|
||||
|
||||
Result DeactivateIrsensor(ClientAppletResourceUserId aruid);
|
||||
|
||||
Result GetIrsensorSharedMemoryHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory,
|
||||
ClientAppletResourceUserId aruid);
|
||||
Result StopImageProcessor(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
ClientAppletResourceUserId aruid);
|
||||
|
||||
Result RunMomentProcessor(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
ClientAppletResourceUserId aruid,
|
||||
const Core::IrSensor::PackedMomentProcessorConfig& processor_config);
|
||||
|
||||
Result RunClusteringProcessor(
|
||||
Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
|
||||
const Core::IrSensor::PackedClusteringProcessorConfig& processor_config);
|
||||
|
||||
Result RunImageTransferProcessor(
|
||||
Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
|
||||
const Core::IrSensor::PackedImageTransferProcessorConfig& processor_config,
|
||||
u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem);
|
||||
|
||||
Result GetImageTransferProcessorState(
|
||||
Out<Core::IrSensor::ImageTransferProcessorState> out_state,
|
||||
Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
|
||||
OutBuffer<BufferAttr_HipcMapAlias> out_buffer_data);
|
||||
|
||||
Result RunTeraPluginProcessor(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
Core::IrSensor::PackedTeraPluginProcessorConfig processor_config,
|
||||
ClientAppletResourceUserId aruid);
|
||||
|
||||
Result GetNpadIrCameraHandle(Out<Core::IrSensor::IrCameraHandle> out_camera_handle,
|
||||
Core::HID::NpadIdType npad_id);
|
||||
|
||||
Result RunPointingProcessor(
|
||||
Core::IrSensor::IrCameraHandle camera_handle,
|
||||
const Core::IrSensor::PackedPointingProcessorConfig& processor_config,
|
||||
ClientAppletResourceUserId aruid);
|
||||
|
||||
Result SuspendImageProcessor(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
ClientAppletResourceUserId aruid);
|
||||
|
||||
Result CheckFirmwareVersion(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
Core::IrSensor::PackedMcuVersion mcu_version,
|
||||
ClientAppletResourceUserId aruid);
|
||||
|
||||
Result SetFunctionLevel(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
Core::IrSensor::PackedFunctionLevel function_level,
|
||||
ClientAppletResourceUserId aruid);
|
||||
|
||||
Result RunImageTransferExProcessor(
|
||||
Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
|
||||
const Core::IrSensor::PackedImageTransferProcessorExConfig& processor_config,
|
||||
u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem);
|
||||
|
||||
Result RunIrLedProcessor(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
Core::IrSensor::PackedIrLedProcessorConfig processor_config,
|
||||
ClientAppletResourceUserId aruid);
|
||||
|
||||
Result StopImageProcessorAsync(Core::IrSensor::IrCameraHandle camera_handle,
|
||||
ClientAppletResourceUserId aruid);
|
||||
|
||||
Result ActivateIrsensorWithFunctionLevel(Core::IrSensor::PackedFunctionLevel function_level,
|
||||
ClientAppletResourceUserId aruid);
|
||||
|
||||
Result IsIrCameraHandleValid(const Core::IrSensor::IrCameraHandle& camera_handle) const;
|
||||
|
||||
Core::IrSensor::DeviceFormat& GetIrCameraSharedMemoryDeviceEntry(
|
||||
const Core::IrSensor::IrCameraHandle& camera_handle);
|
||||
|
||||
|
@ -123,8 +123,6 @@ NvResult nvhost_as_gpu::AllocAsEx(IoctlAllocAsEx& params) {
|
||||
vm.va_range_end = params.va_range_end;
|
||||
}
|
||||
|
||||
const u64 max_big_page_bits = Common::Log2Ceil64(vm.va_range_end);
|
||||
|
||||
const auto start_pages{static_cast<u32>(vm.va_range_start >> VM::PAGE_SIZE_BITS)};
|
||||
const auto end_pages{static_cast<u32>(vm.va_range_split >> VM::PAGE_SIZE_BITS)};
|
||||
vm.small_page_allocator = std::make_shared<VM::Allocator>(start_pages, end_pages);
|
||||
@ -134,8 +132,8 @@ NvResult nvhost_as_gpu::AllocAsEx(IoctlAllocAsEx& params) {
|
||||
static_cast<u32>((vm.va_range_end - vm.va_range_split) >> vm.big_page_size_bits)};
|
||||
vm.big_page_allocator = std::make_unique<VM::Allocator>(start_big_pages, end_big_pages);
|
||||
|
||||
gmmu = std::make_shared<Tegra::MemoryManager>(system, max_big_page_bits, vm.va_range_split,
|
||||
vm.big_page_size_bits, VM::PAGE_SIZE_BITS);
|
||||
gmmu = std::make_shared<Tegra::MemoryManager>(system, 40, vm.big_page_size_bits,
|
||||
VM::PAGE_SIZE_BITS);
|
||||
system.GPU().InitAddressSpace(*gmmu);
|
||||
vm.initialised = true;
|
||||
|
||||
|
@ -145,9 +145,8 @@ void ImageTransferProcessor::SetTransferMemoryAddress(Common::ProcessAddress t_m
|
||||
}
|
||||
|
||||
Core::IrSensor::ImageTransferProcessorState ImageTransferProcessor::GetState(
|
||||
std::vector<u8>& data) const {
|
||||
const auto size = GetDataSize(current_config.trimming_format);
|
||||
data.resize(size);
|
||||
std::span<u8> data) const {
|
||||
const auto size = std::min(GetDataSize(current_config.trimming_format), data.size());
|
||||
system.ApplicationMemory().ReadBlock(transfer_memory, data.data(), size);
|
||||
return processor_state;
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <span>
|
||||
|
||||
#include "common/typed_address.h"
|
||||
#include "hid_core/irsensor/irs_types.h"
|
||||
#include "hid_core/irsensor/processor_base.h"
|
||||
@ -39,7 +41,7 @@ public:
|
||||
// Transfer memory where the image data will be stored
|
||||
void SetTransferMemoryAddress(Common::ProcessAddress t_mem);
|
||||
|
||||
Core::IrSensor::ImageTransferProcessorState GetState(std::vector<u8>& data) const;
|
||||
Core::IrSensor::ImageTransferProcessorState GetState(std::span<u8> data) const;
|
||||
|
||||
private:
|
||||
// This is nn::irsensor::ImageTransferProcessorConfig
|
||||
|
@ -13,102 +13,20 @@ Scheduler::Scheduler(GPU& gpu_) : gpu{gpu_} {}
|
||||
|
||||
Scheduler::~Scheduler() = default;
|
||||
|
||||
void Scheduler::Init() {
|
||||
master_control = Common::Fiber::ThreadToFiber();
|
||||
}
|
||||
|
||||
void Scheduler::Resume() {
|
||||
bool nothing_pending;
|
||||
do {
|
||||
nothing_pending = true;
|
||||
current_fifo = nullptr;
|
||||
{
|
||||
std::unique_lock lk(scheduling_guard);
|
||||
size_t num_iters = gpfifos.size();
|
||||
for (size_t i = 0; i < num_iters; i++) {
|
||||
size_t current_id = (current_fifo_rotation_id + i) % gpfifos.size();
|
||||
auto& fifo = gpfifos[current_id];
|
||||
if (!fifo.is_active) {
|
||||
continue;
|
||||
}
|
||||
std::scoped_lock lk2(fifo.guard);
|
||||
if (!fifo.pending_work.empty() || fifo.working.load(std::memory_order_acquire)) {
|
||||
current_fifo = &fifo;
|
||||
current_fifo_rotation_id = current_id;
|
||||
nothing_pending = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (current_fifo) {
|
||||
Common::Fiber::YieldTo(master_control, *current_fifo->context);
|
||||
current_fifo = nullptr;
|
||||
}
|
||||
} while (!nothing_pending);
|
||||
}
|
||||
|
||||
void Scheduler::Yield() {
|
||||
ASSERT(current_fifo != nullptr);
|
||||
Common::Fiber::YieldTo(current_fifo->context, *master_control);
|
||||
gpu.BindChannel(current_fifo->bind_id);
|
||||
}
|
||||
|
||||
void Scheduler::Push(s32 channel, CommandList&& entries) {
|
||||
std::unique_lock lk(scheduling_guard);
|
||||
auto it = channel_gpfifo_ids.find(channel);
|
||||
ASSERT(it != channel_gpfifo_ids.end());
|
||||
auto gpfifo_id = it->second;
|
||||
auto& fifo = gpfifos[gpfifo_id];
|
||||
{
|
||||
std::scoped_lock lk2(fifo.guard);
|
||||
fifo.pending_work.emplace_back(std::move(entries));
|
||||
}
|
||||
}
|
||||
|
||||
void Scheduler::ChannelLoop(size_t gpfifo_id, s32 channel_id) {
|
||||
gpu.BindChannel(channel_id);
|
||||
auto& fifo = gpfifos[gpfifo_id];
|
||||
while (true) {
|
||||
auto* channel_state = channels[channel_id].get();
|
||||
fifo.guard.lock();
|
||||
while (!fifo.pending_work.empty()) {
|
||||
{
|
||||
|
||||
fifo.working.store(true, std::memory_order_release);
|
||||
CommandList&& entries = std::move(fifo.pending_work.front());
|
||||
channel_state->dma_pusher->Push(std::move(entries));
|
||||
fifo.pending_work.pop_front();
|
||||
}
|
||||
fifo.guard.unlock();
|
||||
channel_state->dma_pusher->DispatchCalls();
|
||||
fifo.guard.lock();
|
||||
}
|
||||
fifo.working.store(false, std::memory_order_relaxed);
|
||||
fifo.guard.unlock();
|
||||
Common::Fiber::YieldTo(fifo.context, *master_control);
|
||||
gpu.BindChannel(channel_id);
|
||||
}
|
||||
auto it = channels.find(channel);
|
||||
ASSERT(it != channels.end());
|
||||
auto channel_state = it->second;
|
||||
gpu.BindChannel(channel_state->bind_id);
|
||||
channel_state->dma_pusher->Push(std::move(entries));
|
||||
channel_state->dma_pusher->DispatchCalls();
|
||||
}
|
||||
|
||||
void Scheduler::DeclareChannel(std::shared_ptr<ChannelState> new_channel) {
|
||||
s32 channel = new_channel->bind_id;
|
||||
std::unique_lock lk(scheduling_guard);
|
||||
channels.emplace(channel, new_channel);
|
||||
size_t new_fifo_id;
|
||||
if (!free_fifos.empty()) {
|
||||
new_fifo_id = free_fifos.front();
|
||||
free_fifos.pop_front();
|
||||
} else {
|
||||
new_fifo_id = gpfifos.size();
|
||||
gpfifos.emplace_back();
|
||||
}
|
||||
auto& new_fifo = gpfifos[new_fifo_id];
|
||||
channel_gpfifo_ids[channel] = new_fifo_id;
|
||||
new_fifo.is_active = true;
|
||||
new_fifo.bind_id = channel;
|
||||
new_fifo.pending_work.clear();
|
||||
std::function<void()> callback = std::bind(&Scheduler::ChannelLoop, this, new_fifo_id, channel);
|
||||
new_fifo.context = std::make_shared<Common::Fiber>(std::move(callback));
|
||||
}
|
||||
|
||||
} // namespace Tegra::Control
|
||||
|
@ -3,13 +3,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "common/fiber.h"
|
||||
#include "video_core/dma_pusher.h"
|
||||
|
||||
namespace Tegra {
|
||||
@ -25,36 +22,14 @@ public:
|
||||
explicit Scheduler(GPU& gpu_);
|
||||
~Scheduler();
|
||||
|
||||
void Init();
|
||||
|
||||
void Resume();
|
||||
|
||||
void Yield();
|
||||
|
||||
void Push(s32 channel, CommandList&& entries);
|
||||
|
||||
void DeclareChannel(std::shared_ptr<ChannelState> new_channel);
|
||||
|
||||
private:
|
||||
void ChannelLoop(size_t gpfifo_id, s32 channel_id);
|
||||
|
||||
std::unordered_map<s32, std::shared_ptr<ChannelState>> channels;
|
||||
std::unordered_map<s32, size_t> channel_gpfifo_ids;
|
||||
std::mutex scheduling_guard;
|
||||
std::shared_ptr<Common::Fiber> master_control;
|
||||
struct GPFifoContext {
|
||||
bool is_active;
|
||||
std::shared_ptr<Common::Fiber> context;
|
||||
std::deque<CommandList> pending_work;
|
||||
std::atomic<bool> working{};
|
||||
std::mutex guard;
|
||||
s32 bind_id;
|
||||
};
|
||||
std::deque<GPFifoContext> gpfifos;
|
||||
std::deque<size_t> free_fifos;
|
||||
GPU& gpu;
|
||||
size_t current_fifo_rotation_id{};
|
||||
GPFifoContext* current_fifo{};
|
||||
};
|
||||
|
||||
} // namespace Control
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "video_core/control/channel_state.h"
|
||||
#include "video_core/control/scheduler.h"
|
||||
#include "video_core/dma_pusher.h"
|
||||
#include "video_core/engines/fermi_2d.h"
|
||||
#include "video_core/engines/kepler_compute.h"
|
||||
@ -15,8 +14,6 @@
|
||||
#include "video_core/engines/maxwell_dma.h"
|
||||
#include "video_core/engines/puller.h"
|
||||
#include "video_core/gpu.h"
|
||||
#include "video_core/host1x/host1x.h"
|
||||
#include "video_core/host1x/syncpoint_manager.h"
|
||||
#include "video_core/memory_manager.h"
|
||||
#include "video_core/rasterizer_interface.h"
|
||||
|
||||
@ -63,14 +60,11 @@ void Puller::ProcessBindMethod(const MethodCall& method_call) {
|
||||
}
|
||||
|
||||
void Puller::ProcessFenceActionMethod() {
|
||||
auto& syncpoint_manager = gpu.Host1x().GetSyncpointManager();
|
||||
switch (regs.fence_action.op) {
|
||||
case Puller::FenceOperation::Acquire:
|
||||
while (regs.fence_value >
|
||||
syncpoint_manager.GetGuestSyncpointValue(regs.fence_action.syncpoint_id)) {
|
||||
rasterizer->ReleaseFences();
|
||||
gpu.Scheduler().Yield();
|
||||
}
|
||||
// UNIMPLEMENTED_MSG("Channel Scheduling pending.");
|
||||
// WaitFence(regs.fence_action.syncpoint_id, regs.fence_value);
|
||||
rasterizer->ReleaseFences();
|
||||
break;
|
||||
case Puller::FenceOperation::Increment:
|
||||
rasterizer->SignalSyncPoint(regs.fence_action.syncpoint_id);
|
||||
|
@ -387,14 +387,6 @@ std::shared_ptr<Control::ChannelState> GPU::AllocateChannel() {
|
||||
return impl->AllocateChannel();
|
||||
}
|
||||
|
||||
Tegra::Control::Scheduler& GPU::Scheduler() {
|
||||
return *impl->scheduler;
|
||||
}
|
||||
|
||||
const Tegra::Control::Scheduler& GPU::Scheduler() const {
|
||||
return *impl->scheduler;
|
||||
}
|
||||
|
||||
void GPU::InitChannel(Control::ChannelState& to_init) {
|
||||
impl->InitChannel(to_init);
|
||||
}
|
||||
|
@ -124,8 +124,7 @@ class KeplerCompute;
|
||||
|
||||
namespace Control {
|
||||
struct ChannelState;
|
||||
class Scheduler;
|
||||
} // namespace Control
|
||||
}
|
||||
|
||||
namespace Host1x {
|
||||
class Host1x;
|
||||
@ -205,12 +204,6 @@ public:
|
||||
/// Returns a const reference to the shader notifier.
|
||||
[[nodiscard]] const VideoCore::ShaderNotify& ShaderNotify() const;
|
||||
|
||||
/// Returns GPU Channel Scheduler.
|
||||
[[nodiscard]] Tegra::Control::Scheduler& Scheduler();
|
||||
|
||||
/// Returns GPU Channel Scheduler.
|
||||
[[nodiscard]] const Tegra::Control::Scheduler& Scheduler() const;
|
||||
|
||||
[[nodiscard]] u64 GetTicks() const;
|
||||
|
||||
[[nodiscard]] bool IsAsync() const;
|
||||
|
@ -34,15 +34,13 @@ static void RunThread(std::stop_token stop_token, Core::System& system,
|
||||
|
||||
CommandDataContainer next;
|
||||
|
||||
scheduler.Init();
|
||||
|
||||
while (!stop_token.stop_requested()) {
|
||||
state.queue.PopWait(next, stop_token);
|
||||
if (stop_token.stop_requested()) {
|
||||
break;
|
||||
}
|
||||
if (std::holds_alternative<SubmitListCommand>(next.data)) {
|
||||
scheduler.Resume();
|
||||
if (auto* submit_list = std::get_if<SubmitListCommand>(&next.data)) {
|
||||
scheduler.Push(submit_list->channel, std::move(submit_list->entries));
|
||||
} else if (std::holds_alternative<GPUTickCommand>(next.data)) {
|
||||
system.GPU().TickWork();
|
||||
} else if (const auto* flush = std::get_if<FlushRegionCommand>(&next.data)) {
|
||||
@ -69,16 +67,14 @@ ThreadManager::~ThreadManager() = default;
|
||||
|
||||
void ThreadManager::StartThread(VideoCore::RendererBase& renderer,
|
||||
Core::Frontend::GraphicsContext& context,
|
||||
Tegra::Control::Scheduler& scheduler_) {
|
||||
Tegra::Control::Scheduler& scheduler) {
|
||||
rasterizer = renderer.ReadRasterizer();
|
||||
scheduler = &scheduler_;
|
||||
thread = std::jthread(RunThread, std::ref(system), std::ref(renderer), std::ref(context),
|
||||
std::ref(scheduler_), std::ref(state));
|
||||
std::ref(scheduler), std::ref(state));
|
||||
}
|
||||
|
||||
void ThreadManager::SubmitList(s32 channel, Tegra::CommandList&& entries) {
|
||||
scheduler->Push(channel, std::move(entries));
|
||||
PushCommand(SubmitListCommand());
|
||||
PushCommand(SubmitListCommand(channel, std::move(entries)));
|
||||
}
|
||||
|
||||
void ThreadManager::FlushRegion(DAddr addr, u64 size) {
|
||||
|
@ -36,7 +36,13 @@ class RendererBase;
|
||||
namespace VideoCommon::GPUThread {
|
||||
|
||||
/// Command to signal to the GPU thread that a command list is ready for processing
|
||||
struct SubmitListCommand final {};
|
||||
struct SubmitListCommand final {
|
||||
explicit SubmitListCommand(s32 channel_, Tegra::CommandList&& entries_)
|
||||
: channel{channel_}, entries{std::move(entries_)} {}
|
||||
|
||||
s32 channel;
|
||||
Tegra::CommandList entries;
|
||||
};
|
||||
|
||||
/// Command to signal to the GPU thread to flush a region
|
||||
struct FlushRegionCommand final {
|
||||
@ -118,7 +124,6 @@ public:
|
||||
private:
|
||||
/// Pushes a command to be executed by the GPU thread
|
||||
u64 PushCommand(CommandData&& command_data, bool block = false);
|
||||
Tegra::Control::Scheduler* scheduler;
|
||||
|
||||
Core::System& system;
|
||||
const bool is_async;
|
||||
|
@ -10,7 +10,7 @@ namespace Tegra::Host1x {
|
||||
|
||||
Host1x::Host1x(Core::System& system_)
|
||||
: system{system_}, syncpoint_manager{},
|
||||
memory_manager(system.DeviceMemory()), gmmu_manager{system, memory_manager, 32, 0, 12},
|
||||
memory_manager(system.DeviceMemory()), gmmu_manager{system, memory_manager, 32, 12},
|
||||
allocator{std::make_unique<Common::FlatAllocator<u32, 0, 32>>(1 << 12)} {}
|
||||
|
||||
Host1x::~Host1x() = default;
|
||||
|
@ -22,12 +22,11 @@ using Tegra::Memory::GuestMemoryFlags;
|
||||
std::atomic<size_t> MemoryManager::unique_identifier_generator{};
|
||||
|
||||
MemoryManager::MemoryManager(Core::System& system_, MaxwellDeviceMemoryManager& memory_,
|
||||
u64 address_space_bits_, GPUVAddr split_address_, u64 big_page_bits_,
|
||||
u64 page_bits_)
|
||||
u64 address_space_bits_, u64 big_page_bits_, u64 page_bits_)
|
||||
: system{system_}, memory{memory_}, address_space_bits{address_space_bits_},
|
||||
split_address{split_address_}, page_bits{page_bits_}, big_page_bits{big_page_bits_},
|
||||
entries{}, big_entries{}, page_table{address_space_bits, address_space_bits + page_bits - 38,
|
||||
page_bits != big_page_bits ? page_bits : 0},
|
||||
page_bits{page_bits_}, big_page_bits{big_page_bits_}, entries{}, big_entries{},
|
||||
page_table{address_space_bits, address_space_bits + page_bits - 38,
|
||||
page_bits != big_page_bits ? page_bits : 0},
|
||||
kind_map{PTEKind::INVALID}, unique_identifier{unique_identifier_generator.fetch_add(
|
||||
1, std::memory_order_acq_rel)},
|
||||
accumulator{std::make_unique<VideoCommon::InvalidationAccumulator>()} {
|
||||
@ -49,10 +48,10 @@ MemoryManager::MemoryManager(Core::System& system_, MaxwellDeviceMemoryManager&
|
||||
entries.resize(page_table_size / 32, 0);
|
||||
}
|
||||
|
||||
MemoryManager::MemoryManager(Core::System& system_, u64 address_space_bits_,
|
||||
GPUVAddr split_address_, u64 big_page_bits_, u64 page_bits_)
|
||||
: MemoryManager(system_, system_.Host1x().MemoryManager(), address_space_bits_, split_address_,
|
||||
big_page_bits_, page_bits_) {}
|
||||
MemoryManager::MemoryManager(Core::System& system_, u64 address_space_bits_, u64 big_page_bits_,
|
||||
u64 page_bits_)
|
||||
: MemoryManager(system_, system_.Host1x().MemoryManager(), address_space_bits_, big_page_bits_,
|
||||
page_bits_) {}
|
||||
|
||||
MemoryManager::~MemoryManager() = default;
|
||||
|
||||
|
@ -36,11 +36,10 @@ namespace Tegra {
|
||||
class MemoryManager final {
|
||||
public:
|
||||
explicit MemoryManager(Core::System& system_, u64 address_space_bits_ = 40,
|
||||
GPUVAddr split_address = 1ULL << 34, u64 big_page_bits_ = 16,
|
||||
u64 page_bits_ = 12);
|
||||
explicit MemoryManager(Core::System& system_, MaxwellDeviceMemoryManager& memory_,
|
||||
u64 address_space_bits_ = 40, GPUVAddr split_address = 1ULL << 34,
|
||||
u64 big_page_bits_ = 16, u64 page_bits_ = 12);
|
||||
explicit MemoryManager(Core::System& system_, MaxwellDeviceMemoryManager& memory_,
|
||||
u64 address_space_bits_ = 40, u64 big_page_bits_ = 16,
|
||||
u64 page_bits_ = 12);
|
||||
~MemoryManager();
|
||||
|
||||
static constexpr bool HAS_FLUSH_INVALIDATION = true;
|
||||
@ -195,7 +194,6 @@ private:
|
||||
MaxwellDeviceMemoryManager& memory;
|
||||
|
||||
const u64 address_space_bits;
|
||||
GPUVAddr split_address;
|
||||
const u64 page_bits;
|
||||
u64 address_space_size;
|
||||
u64 page_size;
|
||||
|
@ -45,15 +45,23 @@ ConfigureHotkeys::ConfigureHotkeys(Core::HID::HIDCore& hid_core, QWidget* parent
|
||||
|
||||
controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||
|
||||
connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
|
||||
connect(timeout_timer.get(), &QTimer::timeout, [this] {
|
||||
const bool is_button_pressed = pressed_buttons != Core::HID::NpadButton::None ||
|
||||
pressed_home_button || pressed_capture_button;
|
||||
SetPollingResult(!is_button_pressed);
|
||||
});
|
||||
|
||||
connect(poll_timer.get(), &QTimer::timeout, [this] {
|
||||
const auto buttons = controller->GetNpadButtons();
|
||||
const auto home_pressed = controller->GetHomeButtons().home != 0;
|
||||
const auto capture_pressed = controller->GetCaptureButtons().capture != 0;
|
||||
if (home_pressed || capture_pressed) {
|
||||
SetPollingResult(buttons.raw, false);
|
||||
return;
|
||||
pressed_buttons |= controller->GetNpadButtons().raw;
|
||||
pressed_home_button |= this->controller->GetHomeButtons().home != 0;
|
||||
pressed_capture_button |= this->controller->GetCaptureButtons().capture != 0;
|
||||
if (pressed_buttons != Core::HID::NpadButton::None || pressed_home_button ||
|
||||
pressed_capture_button) {
|
||||
const QString button_name =
|
||||
GetButtonCombinationName(pressed_buttons, pressed_home_button,
|
||||
pressed_capture_button) +
|
||||
QStringLiteral("...");
|
||||
model->setData(button_model_index, button_name);
|
||||
}
|
||||
});
|
||||
RetranslateUI();
|
||||
@ -154,16 +162,14 @@ void ConfigureHotkeys::ConfigureController(QModelIndex index) {
|
||||
|
||||
const auto previous_key = model->data(index);
|
||||
|
||||
input_setter = [this, index, previous_key](const Core::HID::NpadButton button,
|
||||
const bool cancel) {
|
||||
input_setter = [this, index, previous_key](const bool cancel) {
|
||||
if (cancel) {
|
||||
model->setData(index, previous_key);
|
||||
return;
|
||||
}
|
||||
const auto home_pressed = this->controller->GetHomeButtons().home != 0;
|
||||
const auto capture_pressed = this->controller->GetCaptureButtons().capture != 0;
|
||||
|
||||
const QString button_string =
|
||||
GetButtonCombinationName(button, home_pressed, capture_pressed);
|
||||
GetButtonCombinationName(pressed_buttons, pressed_home_button, pressed_capture_button);
|
||||
|
||||
const auto [key_sequence_used, used_action] = IsUsedControllerKey(button_string);
|
||||
|
||||
@ -177,17 +183,22 @@ void ConfigureHotkeys::ConfigureController(QModelIndex index) {
|
||||
}
|
||||
};
|
||||
|
||||
button_model_index = index;
|
||||
pressed_buttons = Core::HID::NpadButton::None;
|
||||
pressed_home_button = false;
|
||||
pressed_capture_button = false;
|
||||
|
||||
model->setData(index, tr("[waiting]"));
|
||||
timeout_timer->start(2500); // Cancel after 2.5 seconds
|
||||
poll_timer->start(200); // Check for new inputs every 200ms
|
||||
poll_timer->start(100); // Check for new inputs every 100ms
|
||||
// We need to disable configuration to be able to read npad buttons
|
||||
controller->DisableConfiguration();
|
||||
}
|
||||
|
||||
void ConfigureHotkeys::SetPollingResult(Core::HID::NpadButton button, const bool cancel) {
|
||||
void ConfigureHotkeys::SetPollingResult(const bool cancel) {
|
||||
timeout_timer->stop();
|
||||
poll_timer->stop();
|
||||
(*input_setter)(button, cancel);
|
||||
(*input_setter)(cancel);
|
||||
// Re-Enable configuration
|
||||
controller->EnableConfiguration();
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <QStandardItemModel>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Common {
|
||||
@ -54,14 +55,20 @@ private:
|
||||
void RestoreControllerHotkey(QModelIndex index);
|
||||
void RestoreHotkey(QModelIndex index);
|
||||
|
||||
void SetPollingResult(bool cancel);
|
||||
QString GetButtonCombinationName(Core::HID::NpadButton button, bool home, bool capture) const;
|
||||
|
||||
std::unique_ptr<Ui::ConfigureHotkeys> ui;
|
||||
|
||||
QStandardItemModel* model;
|
||||
|
||||
void SetPollingResult(Core::HID::NpadButton button, bool cancel);
|
||||
QString GetButtonCombinationName(Core::HID::NpadButton button, bool home, bool capture) const;
|
||||
bool pressed_home_button;
|
||||
bool pressed_capture_button;
|
||||
QModelIndex button_model_index;
|
||||
Core::HID::NpadButton pressed_buttons;
|
||||
|
||||
Core::HID::EmulatedController* controller;
|
||||
std::unique_ptr<QTimer> timeout_timer;
|
||||
std::unique_ptr<QTimer> poll_timer;
|
||||
std::optional<std::function<void(Core::HID::NpadButton, bool)>> input_setter;
|
||||
std::optional<std::function<void(bool)>> input_setter;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user