Merge pull request #1989 from lioncash/set

service/vi: Unstub IApplicationDisplayService's SetLayerScalingMode
This commit is contained in:
bunnei 2019-01-07 12:59:33 -05:00 committed by GitHub
commit 17a68e5ebe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,6 +32,9 @@
namespace Service::VI { namespace Service::VI {
constexpr ResultCode ERR_OPERATION_FAILED{ErrorModule::VI, 1};
constexpr ResultCode ERR_UNSUPPORTED{ErrorModule::VI, 6};
struct DisplayInfo { struct DisplayInfo {
/// The name of this particular display. /// The name of this particular display.
char display_name[0x40]{"Default"}; char display_name[0x40]{"Default"};
@ -874,6 +877,22 @@ public:
~IApplicationDisplayService() = default; ~IApplicationDisplayService() = default;
private: private:
enum class ConvertedScaleMode : u64 {
Freeze = 0,
ScaleToWindow = 1,
ScaleAndCrop = 2,
None = 3,
PreserveAspectRatio = 4,
};
enum class NintendoScaleMode : u32 {
None = 0,
Freeze = 1,
ScaleToWindow = 2,
ScaleAndCrop = 3,
PreserveAspectRatio = 4,
};
void GetRelayService(Kernel::HLERequestContext& ctx) { void GetRelayService(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_VI, "(STUBBED) called"); LOG_WARNING(Service_VI, "(STUBBED) called");
@ -974,13 +993,27 @@ private:
void SetLayerScalingMode(Kernel::HLERequestContext& ctx) { void SetLayerScalingMode(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
const u32 scaling_mode = rp.Pop<u32>(); const auto scaling_mode = rp.PopEnum<NintendoScaleMode>();
const u64 unknown = rp.Pop<u64>(); const u64 unknown = rp.Pop<u64>();
LOG_WARNING(Service_VI, "(STUBBED) called. scaling_mode=0x{:08X}, unknown=0x{:016X}", LOG_DEBUG(Service_VI, "called. scaling_mode=0x{:08X}, unknown=0x{:016X}",
scaling_mode, unknown); static_cast<u32>(scaling_mode), unknown);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
if (scaling_mode > NintendoScaleMode::PreserveAspectRatio) {
LOG_ERROR(Service_VI, "Invalid scaling mode provided.");
rb.Push(ERR_OPERATION_FAILED);
return;
}
if (scaling_mode != NintendoScaleMode::ScaleToWindow &&
scaling_mode != NintendoScaleMode::PreserveAspectRatio) {
LOG_ERROR(Service_VI, "Unsupported scaling mode supplied.");
rb.Push(ERR_UNSUPPORTED);
return;
}
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
} }
@ -1061,51 +1094,37 @@ private:
rb.PushCopyObjects(vsync_event); rb.PushCopyObjects(vsync_event);
} }
enum class ConvertedScaleMode : u64 {
None = 0, // VI seems to name this as "Unknown" but lots of games pass it, assume it's no
// scaling/default
Freeze = 1,
ScaleToWindow = 2,
Crop = 3,
NoCrop = 4,
};
// This struct is different, currently it's 1:1 but this might change in the future.
enum class NintendoScaleMode : u32 {
None = 0,
Freeze = 1,
ScaleToWindow = 2,
Crop = 3,
NoCrop = 4,
};
void ConvertScalingMode(Kernel::HLERequestContext& ctx) { void ConvertScalingMode(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
auto mode = rp.PopEnum<NintendoScaleMode>(); const auto mode = rp.PopEnum<NintendoScaleMode>();
LOG_DEBUG(Service_VI, "called mode={}", static_cast<u32>(mode)); LOG_DEBUG(Service_VI, "called mode={}", static_cast<u32>(mode));
const auto converted_mode = ConvertScalingModeImpl(mode);
if (converted_mode.Succeeded()) {
IPC::ResponseBuilder rb{ctx, 4}; IPC::ResponseBuilder rb{ctx, 4};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushEnum(*converted_mode);
} else {
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(converted_mode.Code());
}
}
static ResultVal<ConvertedScaleMode> ConvertScalingModeImpl(NintendoScaleMode mode) {
switch (mode) { switch (mode) {
case NintendoScaleMode::None: case NintendoScaleMode::None:
rb.PushEnum(ConvertedScaleMode::None); return MakeResult(ConvertedScaleMode::None);
break;
case NintendoScaleMode::Freeze: case NintendoScaleMode::Freeze:
rb.PushEnum(ConvertedScaleMode::Freeze); return MakeResult(ConvertedScaleMode::Freeze);
break;
case NintendoScaleMode::ScaleToWindow: case NintendoScaleMode::ScaleToWindow:
rb.PushEnum(ConvertedScaleMode::ScaleToWindow); return MakeResult(ConvertedScaleMode::ScaleToWindow);
break; case NintendoScaleMode::ScaleAndCrop:
case NintendoScaleMode::Crop: return MakeResult(ConvertedScaleMode::ScaleAndCrop);
rb.PushEnum(ConvertedScaleMode::Crop); case NintendoScaleMode::PreserveAspectRatio:
break; return MakeResult(ConvertedScaleMode::PreserveAspectRatio);
case NintendoScaleMode::NoCrop:
rb.PushEnum(ConvertedScaleMode::NoCrop);
break;
default: default:
UNIMPLEMENTED_MSG("Unknown scaling mode {}", static_cast<u32>(mode)); return ERR_OPERATION_FAILED;
rb.PushEnum(ConvertedScaleMode::None);
break;
} }
} }