Merge pull request #247 from georgemoralis/master

added some y2r service calls
This commit is contained in:
wheremyfoodat 2023-09-01 18:34:19 +03:00 committed by GitHub
commit 5261a4c927
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 9 deletions

View file

@ -64,10 +64,14 @@ class Y2RService {
// Service commands
void driverInitialize(u32 messagePointer);
void driverFinalize(u32 messagePointer);
void getTransferEndEvent(u32 messagePointer);
void getBlockAlignment(u32 messagePointer);
void getInputLines(u32 messagePointer);
void getInputLineWidth(u32 messagePointer);
void getOutputFormat(u32 messagePointer);
void isBusyConversion(u32 messagePointer);
void pingProcess(u32 messagePointer);
void setTransferEndInterrupt(u32 messagePointer);
void getTransferEndEvent(u32 messagePointer);
void setAlpha(u32 messagePointer);
void setBlockAlignment(u32 messagePointer);

View file

@ -1,4 +1,5 @@
#include "services/y2r.hpp"
#include "ipc.hpp"
#include "kernel.hpp"
@ -6,8 +7,10 @@ namespace Y2RCommands {
enum : u32 {
SetInputFormat = 0x00010040,
SetOutputFormat = 0x00030040,
GetOutputFormat = 0x00040000,
SetRotation = 0x00050040,
SetBlockAlignment = 0x00070040,
GetBlockAlignment = 0x00080000,
SetSpacialDithering = 0x00090040,
SetTemporalDithering = 0x000B0040,
SetTransferEndInterrupt = 0x000D0040,
@ -17,7 +20,9 @@ namespace Y2RCommands {
SetSendingV = 0x00120102,
SetReceiving = 0x00180102,
SetInputLineWidth = 0x001A0040,
GetInputLineWidth = 0x001B0000,
SetInputLines = 0x001C0040,
GetInputLines = 0x001D0000,
SetStandardCoeff = 0x00200040,
SetAlpha = 0x00220040,
StartConversion = 0x00260000,
@ -26,7 +31,7 @@ namespace Y2RCommands {
SetPackageParameter = 0x002901C0,
PingProcess = 0x002A0000,
DriverInitialize = 0x002B0000,
DriverFinalize = 0x002C0000
DriverFinalize = 0x002C0000,
};
}
@ -73,6 +78,10 @@ void Y2RService::handleSyncRequest(u32 messagePointer) {
case Y2RCommands::SetTransferEndInterrupt: setTransferEndInterrupt(messagePointer); break;
case Y2RCommands::StartConversion: [[likely]] startConversion(messagePointer); break;
case Y2RCommands::StopConversion: stopConversion(messagePointer); break;
case Y2RCommands::GetBlockAlignment: getBlockAlignment(messagePointer); break;
case Y2RCommands::GetInputLines: getInputLines(messagePointer); break;
case Y2RCommands::GetInputLineWidth: getInputLineWidth(messagePointer); break;
case Y2RCommands::GetOutputFormat: getOutputFormat(messagePointer); break;
default: Helpers::panic("Y2R service requested. Command: %08X\n", command);
}
}
@ -81,7 +90,7 @@ void Y2RService::pingProcess(u32 messagePointer) {
log("Y2R::PingProcess\n");
mem.write32(messagePointer, IPC::responseHeader(0x2A, 2, 0));
mem.write32(messagePointer + 4, Result::Success);
mem.write32(messagePointer + 8, 0); // Connected number
mem.write32(messagePointer + 8, 0); // Connected number
}
void Y2RService::driverInitialize(u32 messagePointer) {
@ -98,8 +107,7 @@ void Y2RService::driverFinalize(u32 messagePointer) {
void Y2RService::getTransferEndEvent(u32 messagePointer) {
log("Y2R::GetTransferEndEvent\n");
if (!transferEndEvent.has_value())
transferEndEvent = kernel.makeEvent(ResetType::OneShot);
if (!transferEndEvent.has_value()) transferEndEvent = kernel.makeEvent(ResetType::OneShot);
mem.write32(messagePointer, IPC::responseHeader(0xF, 1, 2));
mem.write32(messagePointer + 4, Result::Success);
@ -150,6 +158,14 @@ void Y2RService::setBlockAlignment(u32 messagePointer) {
mem.write32(messagePointer + 4, Result::Success);
}
void Y2RService::getBlockAlignment(u32 messagePointer) {
log("Y2R::GetBlockAlignment\n");
mem.write32(messagePointer, IPC::responseHeader(0x8, 2, 0));
mem.write32(messagePointer + 4, Result::Success);
mem.write32(messagePointer + 8, static_cast<u32>(alignment));
}
void Y2RService::setInputFormat(u32 messagePointer) {
const u32 format = mem.read32(messagePointer + 4);
log("Y2R::SetInputFormat (format = %d)\n", format);
@ -178,6 +194,14 @@ void Y2RService::setOutputFormat(u32 messagePointer) {
mem.write32(messagePointer + 4, Result::Success);
}
void Y2RService::getOutputFormat(u32 messagePointer) {
log("Y2R::GetOutputFormat\n");
mem.write32(messagePointer, IPC::responseHeader(0x4, 2, 0));
mem.write32(messagePointer + 4, Result::Success);
mem.write32(messagePointer + 8, static_cast<u32>(outputFmt));
}
void Y2RService::setPackageParameter(u32 messagePointer) {
// Package parameter is 3 words
const u32 word1 = mem.read32(messagePointer + 4);
@ -243,6 +267,13 @@ void Y2RService::setInputLineWidth(u32 messagePointer) {
}
}
void Y2RService::getInputLineWidth(u32 messagePointer) {
log("Y2R::GetInputLineWidth\n");
mem.write32(messagePointer, IPC::responseHeader(0x1B, 2, 0));
mem.write32(messagePointer + 4, Result::Success);
mem.write32(messagePointer + 8, inputLineWidth);
}
void Y2RService::setInputLines(u32 messagePointer) {
const u16 lines = mem.read16(messagePointer + 4);
log("Y2R::SetInputLines (lines = %d)\n", lines);
@ -253,19 +284,28 @@ void Y2RService::setInputLines(u32 messagePointer) {
Helpers::panic("Y2R: Invalid input line count");
} else {
// According to Citra, the Y2R module seems to accidentally skip setting the line # if it's 1024
if (lines != 1024)
inputLines = lines;
if (lines != 1024) inputLines = lines;
mem.write32(messagePointer + 4, Result::Success);
}
}
void Y2RService::getInputLines(u32 messagePointer) {
log("Y2R::GetInputLines\n");
mem.write32(messagePointer, IPC::responseHeader(0x1D, 2, 0));
mem.write32(messagePointer + 4, Result::Success);
mem.write32(messagePointer + 8, inputLines);
}
void Y2RService::setStandardCoeff(u32 messagePointer) {
const u32 coeff = mem.read32(messagePointer + 4);
log("Y2R::SetStandardCoeff (coefficient = %d)\n", coeff);
mem.write32(messagePointer, IPC::responseHeader(0x20, 1, 0));
if (coeff > 3)
Helpers::panic("Y2R: Invalid standard coefficient");
if (coeff > 3) {
Helpers::panic("Y2R: Invalid standard coefficient (coefficient = %d)\n", coeff);
}
else {
Helpers::warn("Unimplemented: Y2R standard coefficient");
mem.write32(messagePointer + 4, Result::Success);