Add Y2R::GetCoefficientParams

This commit is contained in:
wheremyfoodat 2023-11-01 23:01:38 +02:00
parent 171733870d
commit cc130d52e9
2 changed files with 25 additions and 0 deletions

View file

@ -60,6 +60,8 @@ class Y2RService {
{{0x12A, 0x1CA, 0x88, 0x36, 0x21C, -0x1F04, 0x99C, -0x2421}}, // ITU_Rec709_Scaling
}};
CoefficientSet conversionCoefficients; // Current conversion coefficients
InputFormat inputFmt;
OutputFormat outputFmt;
Rotation rotation;
@ -98,6 +100,7 @@ class Y2RService {
void setSpacialDithering(u32 messagePointer);
void setStandardCoeff(u32 messagePointer);
void setTemporalDithering(u32 messagePointer);
void getCoefficientParams(u32 messagePointer);
void getStandardCoefficientParams(u32 messagePointer);
void startConversion(u32 messagePointer);

View file

@ -23,6 +23,7 @@ namespace Y2RCommands {
GetInputLineWidth = 0x001B0000,
SetInputLines = 0x001C0040,
GetInputLines = 0x001D0000,
GetCoefficientParams = 0x001F0000,
SetStandardCoeff = 0x00200040,
GetStandardCoefficientParams = 0x00210040,
SetAlpha = 0x00220040,
@ -51,6 +52,8 @@ void Y2RService::reset() {
alpha = 0xFFFF;
inputLines = 69;
inputLineWidth = 420;
conversionCoefficients.fill(0);
}
void Y2RService::handleSyncRequest(u32 messagePointer) {
@ -84,6 +87,9 @@ void Y2RService::handleSyncRequest(u32 messagePointer) {
case Y2RCommands::SetTransferEndInterrupt: setTransferEndInterrupt(messagePointer); break;
case Y2RCommands::StartConversion: [[likely]] startConversion(messagePointer); break;
case Y2RCommands::StopConversion: stopConversion(messagePointer); break;
// Intentionally break ordering a bit for less-used Y2R functions
case Y2RCommands::GetCoefficientParams: getCoefficientParams(messagePointer); break;
default: Helpers::panic("Y2R service requested. Command: %08X\n", command);
}
}
@ -99,6 +105,8 @@ void Y2RService::driverInitialize(u32 messagePointer) {
log("Y2R::DriverInitialize\n");
mem.write32(messagePointer, IPC::responseHeader(0x2B, 1, 0));
mem.write32(messagePointer + 4, Result::Success);
conversionCoefficients.fill(0);
}
void Y2RService::driverFinalize(u32 messagePointer) {
@ -337,6 +345,20 @@ void Y2RService::getStandardCoefficientParams(u32 messagePointer) {
}
}
void Y2RService::getCoefficientParams(u32 messagePointer) {
log("Y2R::GetCoefficientParams\n");
mem.write32(messagePointer, IPC::responseHeader(0x1F, 5, 0));
mem.write32(messagePointer + 4, Result::Success);
const auto& coeff = conversionCoefficients;
// Write 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");