From 16e6effed4bc82fabf8f54c705b4543fbf256689 Mon Sep 17 00:00:00 2001 From: mailwl Date: Thu, 3 Sep 2015 15:58:22 +0300 Subject: [PATCH] Service/CAM: Dummy implementation of some functions --- src/common/logging/backend.cpp | 1 + src/common/logging/log.h | 1 + src/core/hle/service/cam/cam.cpp | 220 ++++++++++++++++++++++++++++ src/core/hle/service/cam/cam.h | 19 +++ src/core/hle/service/cam/cam_u.cpp | 36 ++--- src/core/hle/service/fs/fs_user.cpp | 9 +- 6 files changed, 267 insertions(+), 19 deletions(-) diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 92e8e742d..5ff60d92c 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -43,6 +43,7 @@ namespace Log { SUB(Service, LDR) \ SUB(Service, NIM) \ SUB(Service, NWM) \ + SUB(Service, CAM) \ SUB(Service, CFG) \ SUB(Service, DSP) \ SUB(Service, HID) \ diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 5fd3bd7f5..54333f365 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -58,6 +58,7 @@ enum class Class : ClassType { Service_LDR, ///< The LDR (3ds dll loader) service Service_NIM, ///< The NIM (Network interface manager) service Service_NWM, ///< The NWM (Network wlan manager) service + Service_CAM, ///< The CAM (Camera) service Service_CFG, ///< The CFG (Configuration) service Service_DSP, ///< The DSP (DSP control) service Service_HID, ///< The HID (Human interface device) service diff --git a/src/core/hle/service/cam/cam.cpp b/src/core/hle/service/cam/cam.cpp index 4f34b699b..fa3c5b3e4 100644 --- a/src/core/hle/service/cam/cam.cpp +++ b/src/core/hle/service/cam/cam.cpp @@ -18,6 +18,219 @@ namespace Service { namespace CAM { +static const u32 TRANSFER_BYTES = 5 * 1024; + +static Kernel::SharedPtr completion_event; +static Kernel::SharedPtr interrupt_error_event; +static Kernel::SharedPtr vsync_interrupt_error_event; + +void DriverInitialize(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called"); +} + +void DriverFinalize(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called"); +} + +void SetTransferLines(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 port = cmd_buff[1] & 0xFF; + u16 transfer_lines = cmd_buff[2] & 0xFFFF; + u16 width = cmd_buff[3] & 0xFFFF; + u16 height = cmd_buff[4] & 0xFFFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d, lines=%d, width=%d, height=%d", + port, transfer_lines, width, height); +} + +void GetMaxLines(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u16 width = cmd_buff[1] & 0xFFFF; + u16 height = cmd_buff[2] & 0xFFFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = TRANSFER_BYTES / (2 * width); + + LOG_WARNING(Service_CAM, "(STUBBED) called, width=%d, height=%d, lines = %d", + width, height, cmd_buff[2]); +} + +void GetBufferErrorInterruptEvent(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 port = cmd_buff[1] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[3] = Kernel::g_handle_table.Create(interrupt_error_event).MoveFrom(); + + LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d", port); +} + +void GetVsyncInterruptEvent(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 port = cmd_buff[1] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[3] = Kernel::g_handle_table.Create(vsync_interrupt_error_event).MoveFrom(); + + LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d", port); +} + +void SetSize(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 cam_select = cmd_buff[1] & 0xFF; + u8 size = cmd_buff[2] & 0xFF; + u8 context = cmd_buff[3] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, size=%d, context=%d", + cam_select, size, context); +} + +void Activate(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 cam_select = cmd_buff[1] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d", + cam_select); +} + +void SetTrimming(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 port = cmd_buff[1] & 0xFF; + bool trim = cmd_buff[2] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d, trim=%d", port, trim); +} + +void SetTrimmingParamsCenter(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 port = cmd_buff[1] & 0xFF; + s16 trimW = cmd_buff[2] & 0xFFFF; + s16 trimH = cmd_buff[3] & 0xFFFF; + s16 camW = cmd_buff[4] & 0xFFFF; + s16 camH = cmd_buff[5] & 0xFFFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d, trimW=%d, trimH=%d, camW=%d, camH=%d", + port, trimW, trimH, camW, camH); +} + +void FlipImage(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 cam_select = cmd_buff[1] & 0xFF; + u8 flip = cmd_buff[2] & 0xFF; + u8 context = cmd_buff[3] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, flip=%d, context=%d", + cam_select, flip, context); +} + +void SetFrameRate(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 cam_select = cmd_buff[1] & 0xFF; + u8 frame_rate = cmd_buff[2] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called, cam_select=%d, frame_rate=%d", + cam_select, frame_rate); +} + +void GetSuitableY2rStandardCoefficient(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = 0; + + LOG_WARNING(Service_CAM, "(STUBBED) called"); +} + +void GetTransferBytes(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 port = cmd_buff[1] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = TRANSFER_BYTES; + + LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d", port); +} + +void SetReceiving(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u32 dest = cmd_buff[1]; // void* + u8 port = cmd_buff[2] & 0xFF; + u32 image_size = cmd_buff[3]; + u16 trans_unit = cmd_buff[4] & 0xFFFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[3] = Kernel::g_handle_table.Create(completion_event).MoveFrom(); + + LOG_WARNING(Service_CAM, "(STUBBED) called, addr=0x%X, port=%d, image_size=%d, trans_unit=%d", + dest, port, image_size, trans_unit); +} + +void StartCapture(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 port = cmd_buff[1] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d", port); +} + +void StopCapture(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 port = cmd_buff[1] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called, port=%d", port); +} + +void PlayShutterSound(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + u8 sound_id = cmd_buff[1] & 0xFF; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_CAM, "(STUBBED) called, sound_id=%d", sound_id); +} + + + void Init() { using namespace Kernel; @@ -25,9 +238,16 @@ void Init() { AddService(new CAM_Q_Interface); AddService(new CAM_S_Interface); AddService(new CAM_U_Interface); + + completion_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "CAM_U::completion_event"); + interrupt_error_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "CAM_U::interrupt_error_event"); + vsync_interrupt_error_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "CAM_U::vsync_interrupt_error_event"); } void Shutdown() { + completion_event = nullptr; + interrupt_error_event = nullptr; + vsync_interrupt_error_event = nullptr; } } // namespace CAM diff --git a/src/core/hle/service/cam/cam.h b/src/core/hle/service/cam/cam.h index edd524841..8071ce7d1 100644 --- a/src/core/hle/service/cam/cam.h +++ b/src/core/hle/service/cam/cam.h @@ -10,6 +10,25 @@ namespace Service { namespace CAM { +void DriverInitialize(Service::Interface* self); +void DriverFinalize(Service::Interface* self); +void GetMaxLines(Service::Interface* self); +void SetTransferLines(Service::Interface* self); +void GetBufferErrorInterruptEvent(Service::Interface* self); +void GetVsyncInterruptEvent(Service::Interface* self); +void SetSize(Service::Interface* self); +void Activate(Service::Interface* self); +void SetTrimming(Service::Interface* self); +void SetTrimmingParamsCenter(Service::Interface* self); +void FlipImage(Service::Interface* self); +void SetFrameRate(Service::Interface* self); +void GetSuitableY2rStandardCoefficient(Service::Interface* self); +void GetTransferBytes(Service::Interface* self); +void SetReceiving(Service::Interface* self); +void StartCapture(Service::Interface* self); +void StopCapture(Service::Interface* self); +void PlayShutterSound(Service::Interface* self); + /// Initialize CAM service(s) void Init(); diff --git a/src/core/hle/service/cam/cam_u.cpp b/src/core/hle/service/cam/cam_u.cpp index 55083e0c7..2183096b9 100644 --- a/src/core/hle/service/cam/cam_u.cpp +++ b/src/core/hle/service/cam/cam_u.cpp @@ -10,25 +10,25 @@ namespace Service { namespace CAM { const Interface::FunctionInfo FunctionTable[] = { - {0x00010040, nullptr, "StartCapture"}, - {0x00020040, nullptr, "StopCapture"}, + {0x00010040, StartCapture, "StartCapture"}, + {0x00020040, StopCapture, "StopCapture"}, {0x00030040, nullptr, "IsBusy"}, {0x00040040, nullptr, "ClearBuffer"}, - {0x00050040, nullptr, "GetVsyncInterruptEvent"}, - {0x00060040, nullptr, "GetBufferErrorInterruptEvent"}, - {0x00070102, nullptr, "SetReceiving"}, + {0x00050040, GetVsyncInterruptEvent, "GetVsyncInterruptEvent"}, + {0x00060040, GetBufferErrorInterruptEvent, "GetBufferErrorInterruptEvent"}, + {0x00070102, SetReceiving, "SetReceiving"}, {0x00080040, nullptr, "IsFinishedReceiving"}, - {0x00090100, nullptr, "SetTransferLines"}, - {0x000A0080, nullptr, "GetMaxLines"}, + {0x00090100, SetTransferLines, "SetTransferLines"}, + {0x000A0080, GetMaxLines, "GetMaxLines"}, {0x000B0100, nullptr, "SetTransferBytes"}, - {0x000C0040, nullptr, "GetTransferBytes"}, + {0x000C0040, GetTransferBytes, "GetTransferBytes"}, {0x000D0080, nullptr, "GetMaxBytes"}, - {0x000E0080, nullptr, "SetTrimming"}, + {0x000E0080, SetTrimming, "SetTrimming"}, {0x000F0040, nullptr, "IsTrimming"}, {0x00100140, nullptr, "SetTrimmingParams"}, {0x00110040, nullptr, "GetTrimmingParams"}, - {0x00120140, nullptr, "SetTrimmingParamsCenter"}, - {0x00130040, nullptr, "Activate"}, + {0x00120140, SetTrimmingParamsCenter, "SetTrimmingParamsCenter"}, + {0x00130040, Activate, "Activate"}, {0x00140080, nullptr, "SwitchContext"}, {0x00150080, nullptr, "SetExposure"}, {0x00160080, nullptr, "SetWhiteBalance"}, @@ -38,10 +38,10 @@ const Interface::FunctionInfo FunctionTable[] = { {0x001A0040, nullptr, "IsAutoExposure"}, {0x001B0080, nullptr, "SetAutoWhiteBalance"}, {0x001C0040, nullptr, "IsAutoWhiteBalance"}, - {0x001D00C0, nullptr, "FlipImage"}, + {0x001D00C0, FlipImage, "FlipImage"}, {0x001E0200, nullptr, "SetDetailSize"}, - {0x001F00C0, nullptr, "SetSize"}, - {0x00200080, nullptr, "SetFrameRate"}, + {0x001F00C0, SetSize, "SetSize"}, + {0x00200080, SetFrameRate, "SetFrameRate"}, {0x00210080, nullptr, "SetPhotoMode"}, {0x002200C0, nullptr, "SetEffect"}, {0x00230080, nullptr, "SetContrast"}, @@ -59,10 +59,10 @@ const Interface::FunctionInfo FunctionTable[] = { {0x003302C0, nullptr, "SetPackageParameterWithoutContext"}, {0x00340140, nullptr, "SetPackageParameterWithContext"}, {0x003501C0, nullptr, "SetPackageParameterWithContextDetail"}, - {0x00360000, nullptr, "GetSuitableY2rStandardCoefficient"}, - {0x00380040, nullptr, "PlayShutterSound"}, - {0x00390000, nullptr, "DriverInitialize"}, - {0x003A0000, nullptr, "DriverFinalize"}, + {0x00360000, GetSuitableY2rStandardCoefficient, "GetSuitableY2rStandardCoefficient"}, + {0x00380040, PlayShutterSound, "PlayShutterSound"}, + {0x00390000, DriverInitialize, "DriverInitialize"}, + {0x003A0000, DriverFinalize, "DriverFinalize"}, {0x003B0000, nullptr, "GetActivatedCamera"}, {0x003C0000, nullptr, "GetSleepCamera"}, {0x003D0040, nullptr, "SetSleepCamera"}, diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index ae52083f9..37d7116c0 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -680,6 +680,13 @@ static void GetPriority(Service::Interface* self) { LOG_DEBUG(Service_FS, "called priority=0x%X", priority); } +static void GetFreeBytes(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = 0x1000000; +} + const Interface::FunctionInfo FunctionTable[] = { {0x000100C6, nullptr, "Dummy1"}, {0x040100C4, nullptr, "Control"}, @@ -700,7 +707,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x080F0180, FormatThisUserSaveData,"FormatThisUserSaveData"}, {0x08100200, nullptr, "CreateSystemSaveData"}, {0x08110040, nullptr, "DeleteSystemSaveData"}, - {0x08120080, nullptr, "GetFreeBytes"}, + {0x08120080, GetFreeBytes, "GetFreeBytes"}, {0x08130000, nullptr, "GetCardType"}, {0x08140000, nullptr, "GetSdmcArchiveResource"}, {0x08150000, nullptr, "GetNandArchiveResource"},