Add Y2R::GetStandardCoefficientParams

This commit is contained in:
wheremyfoodat 2023-11-01 22:49:50 +02:00
parent 5a2e554a6c
commit 171733870d
2 changed files with 33 additions and 1 deletions

View file

@ -24,6 +24,7 @@ namespace Y2RCommands {
SetInputLines = 0x001C0040,
GetInputLines = 0x001D0000,
SetStandardCoeff = 0x00200040,
GetStandardCoefficientParams = 0x00210040,
SetAlpha = 0x00220040,
StartConversion = 0x00260000,
StopConversion = 0x00270000,
@ -62,6 +63,7 @@ void Y2RService::handleSyncRequest(u32 messagePointer) {
case Y2RCommands::GetInputLineWidth: getInputLineWidth(messagePointer); break;
case Y2RCommands::GetOutputFormat: getOutputFormat(messagePointer); break;
case Y2RCommands::GetTransferEndEvent: getTransferEndEvent(messagePointer); break;
case Y2RCommands::GetStandardCoefficientParams: getStandardCoefficientParams(messagePointer); break;
case Y2RCommands::IsBusyConversion: isBusyConversion(messagePointer); break;
case Y2RCommands::PingProcess: pingProcess(messagePointer); break;
case Y2RCommands::SetAlpha: setAlpha(messagePointer); break;
@ -306,7 +308,7 @@ void Y2RService::setStandardCoeff(u32 messagePointer) {
log("Y2R::SetStandardCoeff (coefficient = %d)\n", coeff);
mem.write32(messagePointer, IPC::responseHeader(0x20, 1, 0));
if (coeff > 3) {
if (coeff > 3) { // Invalid coefficient, should have an error code
Helpers::panic("Y2R: Invalid standard coefficient (coefficient = %d)\n", coeff);
}
@ -316,6 +318,25 @@ void Y2RService::setStandardCoeff(u32 messagePointer) {
}
}
void Y2RService::getStandardCoefficientParams(u32 messagePointer) {
const u32 coefficientIndex = mem.read32(messagePointer + 4);
log("Y2R::GetStandardCoefficientParams (coefficient = %d)\n", coefficientIndex);
if (coefficientIndex > 3) { // Invalid coefficient, should have an error code
Helpers::panic("Y2R: Invalid standard coefficient (coefficient = %d)\n", coefficientIndex);
} else {
mem.write32(messagePointer, IPC::responseHeader(0x21, 5, 0));
mem.write32(messagePointer + 4, Result::Success);
const auto& coeff = standardCoefficients[coefficientIndex];
// Write standard coefficient parameters to output buffer
for (int i = 0; i < 8; i++) {
const u32 pointer = messagePointer + 8 + i * sizeof(u16); // Pointer to write parameter to
mem.write16(pointer, coeff[i]);
}
}
}
void Y2RService::setSendingY(u32 messagePointer) {
log("Y2R::SetSendingY\n");
Helpers::warn("Unimplemented Y2R::SetSendingY");