service: vi: Implement ListDisplayMode

This commit is contained in:
german77 2024-02-17 16:08:22 -06:00 committed by Liam
parent 812f23d05c
commit a07f0883b9
3 changed files with 42 additions and 13 deletions

View File

@ -29,7 +29,7 @@ ISystemDisplayService::ISystemDisplayService(Core::System& system_,
{2400, nullptr, "OpenIndirectLayer"}, {2400, nullptr, "OpenIndirectLayer"},
{2401, nullptr, "CloseIndirectLayer"}, {2401, nullptr, "CloseIndirectLayer"},
{2402, nullptr, "FlipIndirectLayer"}, {2402, nullptr, "FlipIndirectLayer"},
{3000, nullptr, "ListDisplayModes"}, {3000, C<&ISystemDisplayService::ListDisplayModes>, "ListDisplayModes"},
{3001, nullptr, "ListDisplayRgbRanges"}, {3001, nullptr, "ListDisplayRgbRanges"},
{3002, nullptr, "ListDisplayContentTypes"}, {3002, nullptr, "ListDisplayContentTypes"},
{3200, C<&ISystemDisplayService::GetDisplayMode>, "GetDisplayMode"}, {3200, C<&ISystemDisplayService::GetDisplayMode>, "GetDisplayMode"},
@ -80,20 +80,39 @@ Result ISystemDisplayService::SetLayerVisibility(bool visible, u64 layer_id) {
R_SUCCEED(); R_SUCCEED();
} }
Result ISystemDisplayService::GetDisplayMode(Out<u32> out_width, Out<u32> out_height, Result ISystemDisplayService::ListDisplayModes(
Out<f32> out_refresh_rate, Out<u32> out_unknown) { Out<u64> out_count, u64 display_id,
LOG_WARNING(Service_VI, "(STUBBED) called"); OutArray<DisplayMode, BufferAttr_HipcMapAlias> out_display_modes) {
LOG_WARNING(Service_VI, "(STUBBED) called, display_id={}", display_id);
if (Settings::IsDockedMode()) { if (!out_display_modes.empty()) {
*out_width = static_cast<u32>(DisplayResolution::DockedWidth); out_display_modes[0] = {
*out_height = static_cast<u32>(DisplayResolution::DockedHeight); .width = 1920,
.height = 1080,
.refresh_rate = 60.f,
.unknown = {},
};
*out_count = 1;
} else { } else {
*out_width = static_cast<u32>(DisplayResolution::UndockedWidth); *out_count = 0;
*out_height = static_cast<u32>(DisplayResolution::UndockedHeight);
} }
*out_refresh_rate = 60.f; // This wouldn't seem to be correct for 30 fps games. R_SUCCEED();
*out_unknown = 0; }
Result ISystemDisplayService::GetDisplayMode(Out<DisplayMode> out_display_mode, u64 display_id) {
LOG_WARNING(Service_VI, "(STUBBED) called, display_id={}", display_id);
if (Settings::IsDockedMode()) {
out_display_mode->width = static_cast<u32>(DisplayResolution::DockedWidth);
out_display_mode->height = static_cast<u32>(DisplayResolution::DockedHeight);
} else {
out_display_mode->width = static_cast<u32>(DisplayResolution::UndockedWidth);
out_display_mode->height = static_cast<u32>(DisplayResolution::UndockedHeight);
}
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(); R_SUCCEED();
} }

View File

@ -8,6 +8,7 @@
#include "core/hle/service/vi/shared_buffer_manager.h" #include "core/hle/service/vi/shared_buffer_manager.h"
namespace Service::VI { namespace Service::VI {
struct DisplayMode;
class Container; class Container;
@ -19,8 +20,9 @@ public:
private: private:
Result SetLayerZ(u32 z_value, u64 layer_id); Result SetLayerZ(u32 z_value, u64 layer_id);
Result SetLayerVisibility(bool visible, u64 layer_id); Result SetLayerVisibility(bool visible, u64 layer_id);
Result GetDisplayMode(Out<u32> out_width, Out<u32> out_height, Out<f32> out_refresh_rate, Result ListDisplayModes(Out<u64> out_count, u64 display_id,
Out<u32> out_unknown); OutArray<DisplayMode, BufferAttr_HipcMapAlias> out_display_modes);
Result GetDisplayMode(Out<DisplayMode> out_display_mode, u64 display_id);
Result GetSharedBufferMemoryHandleId( Result GetSharedBufferMemoryHandleId(
Out<s32> out_nvmap_handle, Out<u64> out_size, Out<s32> out_nvmap_handle, Out<u64> out_size,

View File

@ -66,6 +66,14 @@ struct DisplayInfo {
}; };
static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size"); 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 { class NativeWindow final {
public: public:
constexpr explicit NativeWindow(s32 id_) : id{static_cast<u64>(id_)} {} constexpr explicit NativeWindow(s32 id_) : id{static_cast<u64>(id_)} {}