diff options
Diffstat (limited to 'src/core/hle/service/gsp_gpu.cpp')
-rw-r--r-- | src/core/hle/service/gsp_gpu.cpp | 68 |
1 files changed, 57 insertions, 11 deletions
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index c56475ae..4b0b4229 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp @@ -167,7 +167,7 @@ static void WriteHWRegsWithMask(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); u32 reg_addr = cmd_buff[1]; u32 size = cmd_buff[2]; - + u32* src_data = (u32*)Memory::GetPointer(cmd_buff[4]); u32* mask_data = (u32*)Memory::GetPointer(cmd_buff[6]); @@ -208,21 +208,21 @@ static void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { PAddr phys_address_left = Memory::VirtualToPhysicalAddress(info.address_left); PAddr phys_address_right = Memory::VirtualToPhysicalAddress(info.address_right); if (info.active_fb == 0) { - WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left1)), 4, + WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left1)), 4, &phys_address_left); - WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right1)), 4, + WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right1)), 4, &phys_address_right); } else { - WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left2)), 4, + WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left2)), 4, &phys_address_left); - WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right2)), 4, + WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right2)), 4, &phys_address_right); } - WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].stride)), 4, + WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].stride)), 4, &info.stride); - WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].color_format)), 4, + WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].color_format)), 4, &info.format); - WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].active_fb)), 4, + WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].active_fb)), 4, &info.shown_fb); } @@ -374,7 +374,7 @@ static void ExecuteCommand(const Command& command, u32 thread_id) { { auto& params = command.set_command_list_last; - WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.address)), + WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.address)), Memory::VirtualToPhysicalAddress(params.address) >> 3); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.size)), params.size); @@ -470,7 +470,7 @@ static void SetLcdForceBlack(Service::Interface* self) { LCD::Write(HW::VADDR_LCD + 4 * LCD_REG_INDEX(color_fill_top), data.raw); // Top LCD LCD::Write(HW::VADDR_LCD + 4 * LCD_REG_INDEX(color_fill_bottom), data.raw); // Bottom LCD - + cmd_buff[1] = RESULT_SUCCESS.raw; } @@ -496,6 +496,52 @@ static void TriggerCmdReqQueue(Service::Interface* self) { cmd_buff[1] = 0; // No error } +/** + * GSP_GPU::ImportDisplayCaptureInfo service function + * + * Returns information about the current framebuffer state + * + * Inputs: + * 0: Header 0x00180000 + * Outputs: + * 1: Result code + * 2: Left framebuffer virtual address for the main screen + * 3: Right framebuffer virtual address for the main screen + * 4: Main screen framebuffer format + * 5: Main screen framebuffer width + * 6: Left framebuffer virtual address for the bottom screen + * 7: Right framebuffer virtual address for the bottom screen + * 8: Bottom screen framebuffer format + * 9: Bottom screen framebuffer width + */ +static void ImportDisplayCaptureInfo(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + // TODO(Subv): We're always returning the framebuffer structures for thread_id = 0, + // because we only support a single running application at a time. + // This should always return the framebuffer data that is currently displayed on the screen. + + u32 thread_id = 0; + + FrameBufferUpdate* top_screen = GetFrameBufferInfo(thread_id, 0); + FrameBufferUpdate* bottom_screen = GetFrameBufferInfo(thread_id, 1); + + cmd_buff[2] = top_screen->framebuffer_info[top_screen->index].address_left; + cmd_buff[3] = top_screen->framebuffer_info[top_screen->index].address_right; + cmd_buff[4] = top_screen->framebuffer_info[top_screen->index].format; + cmd_buff[5] = top_screen->framebuffer_info[top_screen->index].stride; + + cmd_buff[6] = bottom_screen->framebuffer_info[bottom_screen->index].address_left; + cmd_buff[7] = bottom_screen->framebuffer_info[bottom_screen->index].address_right; + cmd_buff[8] = bottom_screen->framebuffer_info[bottom_screen->index].format; + cmd_buff[9] = bottom_screen->framebuffer_info[bottom_screen->index].stride; + + cmd_buff[1] = RESULT_SUCCESS.raw; + + LOG_WARNING(Service_GSP, "called"); +} + + const Interface::FunctionInfo FunctionTable[] = { {0x00010082, WriteHWRegs, "WriteHWRegs"}, {0x00020084, WriteHWRegsWithMask, "WriteHWRegsWithMask"}, @@ -520,7 +566,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00150002, nullptr, "TryAcquireRight"}, {0x00160042, nullptr, "AcquireRight"}, {0x00170000, nullptr, "ReleaseRight"}, - {0x00180000, nullptr, "ImportDisplayCaptureInfo"}, + {0x00180000, ImportDisplayCaptureInfo, "ImportDisplayCaptureInfo"}, {0x00190000, nullptr, "SaveVramSysArea"}, {0x001A0000, nullptr, "RestoreVramSysArea"}, {0x001B0000, nullptr, "ResetGpuCore"}, |