From a07f0883b91daaee37fd995b2c78d5714c95b05f Mon Sep 17 00:00:00 2001 From: german77 Date: Sat, 17 Feb 2024 16:08:22 -0600 Subject: service: vi: Implement ListDisplayMode --- src/core/hle/service/vi/system_display_service.cpp | 39 ++++++++++++++++------ src/core/hle/service/vi/system_display_service.h | 6 ++-- src/core/hle/service/vi/vi_types.h | 8 +++++ 3 files changed, 41 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/vi/system_display_service.cpp b/src/core/hle/service/vi/system_display_service.cpp index 9e28fdda3..c3c50b07b 100644 --- a/src/core/hle/service/vi/system_display_service.cpp +++ b/src/core/hle/service/vi/system_display_service.cpp @@ -29,7 +29,7 @@ ISystemDisplayService::ISystemDisplayService(Core::System& system_, {2400, nullptr, "OpenIndirectLayer"}, {2401, nullptr, "CloseIndirectLayer"}, {2402, nullptr, "FlipIndirectLayer"}, - {3000, nullptr, "ListDisplayModes"}, + {3000, C<&ISystemDisplayService::ListDisplayModes>, "ListDisplayModes"}, {3001, nullptr, "ListDisplayRgbRanges"}, {3002, nullptr, "ListDisplayContentTypes"}, {3200, C<&ISystemDisplayService::GetDisplayMode>, "GetDisplayMode"}, @@ -80,20 +80,39 @@ Result ISystemDisplayService::SetLayerVisibility(bool visible, u64 layer_id) { R_SUCCEED(); } -Result ISystemDisplayService::GetDisplayMode(Out out_width, Out out_height, - Out out_refresh_rate, Out out_unknown) { - LOG_WARNING(Service_VI, "(STUBBED) called"); +Result ISystemDisplayService::ListDisplayModes( + Out out_count, u64 display_id, + OutArray out_display_modes) { + LOG_WARNING(Service_VI, "(STUBBED) called, display_id={}", display_id); + + if (!out_display_modes.empty()) { + out_display_modes[0] = { + .width = 1920, + .height = 1080, + .refresh_rate = 60.f, + .unknown = {}, + }; + *out_count = 1; + } else { + *out_count = 0; + } + + R_SUCCEED(); +} + +Result ISystemDisplayService::GetDisplayMode(Out out_display_mode, u64 display_id) { + LOG_WARNING(Service_VI, "(STUBBED) called, display_id={}", display_id); if (Settings::IsDockedMode()) { - *out_width = static_cast(DisplayResolution::DockedWidth); - *out_height = static_cast(DisplayResolution::DockedHeight); + out_display_mode->width = static_cast(DisplayResolution::DockedWidth); + out_display_mode->height = static_cast(DisplayResolution::DockedHeight); } else { - *out_width = static_cast(DisplayResolution::UndockedWidth); - *out_height = static_cast(DisplayResolution::UndockedHeight); + out_display_mode->width = static_cast(DisplayResolution::UndockedWidth); + out_display_mode->height = static_cast(DisplayResolution::UndockedHeight); } - *out_refresh_rate = 60.f; // This wouldn't seem to be correct for 30 fps games. - *out_unknown = 0; + out_display_mode->refresh_rate = 60.f; // This wouldn't seem to be correct for 30 fps games. + out_display_mode->unknown = 0; R_SUCCEED(); } diff --git a/src/core/hle/service/vi/system_display_service.h b/src/core/hle/service/vi/system_display_service.h index 63c1a4dc5..7228d826e 100644 --- a/src/core/hle/service/vi/system_display_service.h +++ b/src/core/hle/service/vi/system_display_service.h @@ -8,6 +8,7 @@ #include "core/hle/service/vi/shared_buffer_manager.h" namespace Service::VI { +struct DisplayMode; class Container; @@ -19,8 +20,9 @@ public: private: Result SetLayerZ(u32 z_value, u64 layer_id); Result SetLayerVisibility(bool visible, u64 layer_id); - Result GetDisplayMode(Out out_width, Out out_height, Out out_refresh_rate, - Out out_unknown); + Result ListDisplayModes(Out out_count, u64 display_id, + OutArray out_display_modes); + Result GetDisplayMode(Out out_display_mode, u64 display_id); Result GetSharedBufferMemoryHandleId( Out out_nvmap_handle, Out out_size, diff --git a/src/core/hle/service/vi/vi_types.h b/src/core/hle/service/vi/vi_types.h index 7f2c70aef..95ff66358 100644 --- a/src/core/hle/service/vi/vi_types.h +++ b/src/core/hle/service/vi/vi_types.h @@ -66,6 +66,14 @@ struct DisplayInfo { }; static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size"); +struct DisplayMode { + u32 width; + u32 height; + f32 refresh_rate; + u32 unknown; +}; +static_assert(sizeof(DisplayMode) == 0x10, "DisplayMode has wrong size"); + class NativeWindow final { public: constexpr explicit NativeWindow(s32 id_) : id{static_cast(id_)} {} -- cgit v1.2.3