Update and align the code of service y2r!
This commit is contained in:
parent
2e13b7f3ca
commit
0b636d1fd1
2 changed files with 271 additions and 71 deletions
|
@ -28,7 +28,7 @@ struct ConversionParameters {
|
|||
u16 input_line_width;
|
||||
u16 input_lines;
|
||||
StandardCoefficient standard_coefficient;
|
||||
u8 reserved;
|
||||
u8 padding;
|
||||
u16 alpha;
|
||||
};
|
||||
static_assert(sizeof(ConversionParameters) == 12, "ConversionParameters struct has incorrect size");
|
||||
|
@ -82,6 +82,9 @@ ResultCode ConversionConfiguration::SetStandardCoefficient(StandardCoefficient s
|
|||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetInputFormat service function
|
||||
*/
|
||||
static void SetInputFormat(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -91,6 +94,21 @@ static void SetInputFormat(Service::Interface* self) {
|
|||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::GetInputFormat service function
|
||||
*/
|
||||
static void GetInputFormat(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
LOG_DEBUG(Service_Y2R, "Get input_format=%hhu", conversion.input_format);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
cmd_buff[2] = static_cast<u32>(conversion.input_format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetOutputFormat service function
|
||||
*/
|
||||
static void SetOutputFormat(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -100,6 +118,21 @@ static void SetOutputFormat(Service::Interface* self) {
|
|||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::GetOutputFormat service function
|
||||
*/
|
||||
static void GetOutputFormat(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
LOG_DEBUG(Service_Y2R, "Get output_format=%hhu", conversion.output_format);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
cmd_buff[2] = static_cast<u32>(conversion.output_format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetRotation service function
|
||||
*/
|
||||
static void SetRotation(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -109,15 +142,45 @@ static void SetRotation(Service::Interface* self) {
|
|||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::GetRotation service function
|
||||
*/
|
||||
static void GetRotation(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
LOG_DEBUG(Service_Y2R, "Get rotation=%hhu", conversion.rotation);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
cmd_buff[2] = static_cast<u32>(conversion.rotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetBlockAlignment service function
|
||||
*/
|
||||
static void SetBlockAlignment(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
conversion.block_alignment = static_cast<BlockAlignment>(cmd_buff[1]);
|
||||
LOG_DEBUG(Service_Y2R, "called alignment=%hhu", conversion.block_alignment);
|
||||
LOG_DEBUG(Service_Y2R, "called block_alignment=%hhu", conversion.block_alignment);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::GetBlockAlignment service function
|
||||
*/
|
||||
static void GetBlockAlignment(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
LOG_DEBUG(Service_Y2R, "called Get block_alignment=%hhu", conversion.block_alignment);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
cmd_buff[2] = static_cast<u32>(conversion.block_alignment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetTransferEndInterrupt service function
|
||||
*/
|
||||
static void SetTransferEndInterrupt(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -140,6 +203,9 @@ static void GetTransferEndEvent(Service::Interface* self) {
|
|||
LOG_DEBUG(Service_Y2R, "called");
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetSendingY service function
|
||||
*/
|
||||
static void SetSendingY(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -155,6 +221,9 @@ static void SetSendingY(Service::Interface* self) {
|
|||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetSendingU service function
|
||||
*/
|
||||
static void SetSendingU(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -170,6 +239,9 @@ static void SetSendingU(Service::Interface* self) {
|
|||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetSendingV service function
|
||||
*/
|
||||
static void SetSendingV(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -185,6 +257,9 @@ static void SetSendingV(Service::Interface* self) {
|
|||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetSendingYUYV service function
|
||||
*/
|
||||
static void SetSendingYUYV(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -200,6 +275,9 @@ static void SetSendingYUYV(Service::Interface* self) {
|
|||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetReceiving service function
|
||||
*/
|
||||
static void SetReceiving(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -216,6 +294,9 @@ static void SetReceiving(Service::Interface* self) {
|
|||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetInputLineWidth service function
|
||||
*/
|
||||
static void SetInputLineWidth(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -223,13 +304,43 @@ static void SetInputLineWidth(Service::Interface* self) {
|
|||
cmd_buff[1] = conversion.SetInputLineWidth(cmd_buff[1]).raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::GetInputLineWidth service function
|
||||
*/
|
||||
static void GetInputLineWidth(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
LOG_DEBUG(Service_Y2R, "called input_line_width=%u", conversion.input_line_width);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
cmd_buff[2] = conversion.input_line_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetInputLines service function
|
||||
*/
|
||||
static void SetInputLines(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
LOG_DEBUG(Service_Y2R, "called input_line_number=%u", cmd_buff[1]);
|
||||
LOG_DEBUG(Service_Y2R, "called input_lines=%u", cmd_buff[1]);
|
||||
cmd_buff[1] = conversion.SetInputLines(cmd_buff[1]).raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::GetInputLines service function
|
||||
*/
|
||||
static void GetInputLines(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
LOG_DEBUG(Service_Y2R, "called input_lines=%u", conversion.input_lines);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
cmd_buff[2] = static_cast<u32>(conversion.input_lines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetCoefficient service function
|
||||
*/
|
||||
static void SetCoefficient(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -242,6 +353,20 @@ static void SetCoefficient(Service::Interface* self) {
|
|||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::GetCoefficient service function
|
||||
*/
|
||||
static void GetCoefficient(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
std::memcpy(&cmd_buff[2], conversion.coefficients.data(), sizeof(CoefficientSet));
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetStandardCoefficient service function
|
||||
*/
|
||||
static void SetStandardCoefficient(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -250,6 +375,41 @@ static void SetStandardCoefficient(Service::Interface* self) {
|
|||
cmd_buff[1] = conversion.SetStandardCoefficient((StandardCoefficient)cmd_buff[1]).raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::GetStandardCoefficientParams service function
|
||||
*/
|
||||
static void GetStandardCoefficientParams(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
u32 index = 4;
|
||||
|
||||
switch (static_cast<StandardCoefficient>(cmd_buff[1])) {
|
||||
case StandardCoefficient::ITU_Rec601:
|
||||
index = static_cast<u32>(StandardCoefficient::ITU_Rec601);
|
||||
break;
|
||||
case StandardCoefficient::ITU_Rec709:
|
||||
index = static_cast<u32>(StandardCoefficient::ITU_Rec709);
|
||||
break;
|
||||
case StandardCoefficient::ITU_Rec601_Scaling:
|
||||
index = static_cast<u32>(StandardCoefficient::ITU_Rec601_Scaling);
|
||||
break;
|
||||
case StandardCoefficient::ITU_Rec709_Scaling:
|
||||
index = static_cast<u32>(StandardCoefficient::ITU_Rec709_Scaling);
|
||||
break;
|
||||
}
|
||||
|
||||
if (index >= 0 && index <= 3) {
|
||||
std::memcpy(&cmd_buff[2], reinterpret_cast<const u32*>(&(standard_coefficients[index])), sizeof(CoefficientSet));
|
||||
LOG_WARNING(Service_Y2R, "StandardCoefficient:0x%08X ", cmd_buff[1]);
|
||||
} else {
|
||||
LOG_ERROR(Service_Y2R,"StandardCoefficient:0x%08X The argument is invalid!",cmd_buff[1]);
|
||||
}
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::SetAlpha service function
|
||||
*/
|
||||
static void SetAlpha(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -259,6 +419,21 @@ static void SetAlpha(Service::Interface* self) {
|
|||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::GetAlpha service function
|
||||
*/
|
||||
static void GetAlpha(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
LOG_DEBUG(Service_Y2R, "called Get alpha=%hu", conversion.alpha);
|
||||
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
cmd_buff[2] = static_cast<u32>(conversion.alpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::StartConversion service function
|
||||
*/
|
||||
static void StartConversion(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -276,6 +451,9 @@ static void StartConversion(Service::Interface* self) {
|
|||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::StopConversion service function
|
||||
*/
|
||||
static void StopConversion(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -301,17 +479,17 @@ static void IsBusyConversion(Service::Interface* self) {
|
|||
/**
|
||||
* Y2R_U::SetConversionParams service function
|
||||
*/
|
||||
static void SetConversionParams(Service::Interface* self) {
|
||||
static void SetPackageParameter(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
auto params = reinterpret_cast<const ConversionParameters*>(&cmd_buff[1]);
|
||||
LOG_DEBUG(Service_Y2R,
|
||||
"called input_format=%hhu output_format=%hhu rotation=%hhu block_alignment=%hhu "
|
||||
"input_line_width=%hu input_lines=%hu standard_coefficient=%hhu "
|
||||
"reserved=%hhu alpha=%hX",
|
||||
"padding=%hhu alpha=%hX",
|
||||
params->input_format, params->output_format, params->rotation, params->block_alignment,
|
||||
params->input_line_width, params->input_lines, params->standard_coefficient,
|
||||
params->reserved, params->alpha);
|
||||
params->padding, params->alpha);
|
||||
|
||||
ResultCode result = RESULT_SUCCESS;
|
||||
|
||||
|
@ -325,6 +503,7 @@ static void SetConversionParams(Service::Interface* self) {
|
|||
if (result.IsError()) goto cleanup;
|
||||
result = conversion.SetStandardCoefficient(params->standard_coefficient);
|
||||
if (result.IsError()) goto cleanup;
|
||||
conversion.padding = params->padding;
|
||||
conversion.alpha = params->alpha;
|
||||
|
||||
cleanup:
|
||||
|
@ -332,6 +511,20 @@ cleanup:
|
|||
cmd_buff[1] = result.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::GetConversionParams service function
|
||||
*/
|
||||
static void GetPackageParameter(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
std::memcpy(&cmd_buff[2], reinterpret_cast<const u32*>(&(conversion)), sizeof(ConversionParameters));
|
||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::PingProcess service function
|
||||
*/
|
||||
static void PingProcess(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -340,6 +533,9 @@ static void PingProcess(Service::Interface* self) {
|
|||
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::DriverInitialize service function
|
||||
*/
|
||||
static void DriverInitialize(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -365,6 +561,9 @@ static void DriverInitialize(Service::Interface* self) {
|
|||
LOG_DEBUG(Service_Y2R, "called");
|
||||
}
|
||||
|
||||
/**
|
||||
* Y2R_U::DriverFinalize service function
|
||||
*/
|
||||
static void DriverFinalize(Service::Interface* self) {
|
||||
u32* cmd_buff = Kernel::GetCommandBuffer();
|
||||
|
||||
|
@ -375,13 +574,13 @@ static void DriverFinalize(Service::Interface* self) {
|
|||
|
||||
const Interface::FunctionInfo FunctionTable[] = {
|
||||
{0x00010040, SetInputFormat, "SetInputFormat"},
|
||||
{0x00020000, nullptr, "GetInputFormat"},
|
||||
{0x00020000, GetInputFormat, "GetInputFormat"},
|
||||
{0x00030040, SetOutputFormat, "SetOutputFormat"},
|
||||
{0x00040000, nullptr, "GetOutputFormat"},
|
||||
{0x00040000, GetOutputFormat, "GetOutputFormat"},
|
||||
{0x00050040, SetRotation, "SetRotation"},
|
||||
{0x00060000, nullptr, "GetRotation"},
|
||||
{0x00060000, GetRotation, "GetRotation"},
|
||||
{0x00070040, SetBlockAlignment, "SetBlockAlignment"},
|
||||
{0x00080000, nullptr, "GetBlockAlignment"},
|
||||
{0x00080000, GetBlockAlignment, "GetBlockAlignment"},
|
||||
{0x00090040, nullptr, "SetSpacialDithering"},
|
||||
{0x000A0000, nullptr, "GetSpacialDithering"},
|
||||
{0x000B0040, nullptr, "SetTemporalDithering"},
|
||||
|
@ -399,25 +598,25 @@ const Interface::FunctionInfo FunctionTable[] = {
|
|||
{0x00180102, SetReceiving, "SetReceiving"},
|
||||
{0x00190000, nullptr, "IsFinishedReceiving"},
|
||||
{0x001A0040, SetInputLineWidth, "SetInputLineWidth"},
|
||||
{0x001B0000, nullptr, "GetInputLineWidth"},
|
||||
{0x001B0000, GetInputLineWidth, "GetInputLineWidth"},
|
||||
{0x001C0040, SetInputLines, "SetInputLines"},
|
||||
{0x001D0000, nullptr, "GetInputLines"},
|
||||
{0x001D0000, GetInputLines, "GetInputLines"},
|
||||
{0x001E0100, SetCoefficient, "SetCoefficient"},
|
||||
{0x001F0000, nullptr, "GetCoefficient"},
|
||||
{0x001F0000, GetCoefficient, "GetCoefficient"},
|
||||
{0x00200040, SetStandardCoefficient, "SetStandardCoefficient"},
|
||||
{0x00210040, nullptr, "GetStandardCoefficientParams"},
|
||||
{0x00210040, GetStandardCoefficientParams,"GetStandardCoefficientParams"},
|
||||
{0x00220040, SetAlpha, "SetAlpha"},
|
||||
{0x00230000, nullptr, "GetAlpha"},
|
||||
{0x00230000, GetAlpha, "GetAlpha"},
|
||||
{0x00240200, nullptr, "SetDitheringWeightParams"},
|
||||
{0x00250000, nullptr, "GetDitheringWeightParams"},
|
||||
{0x00260000, StartConversion, "StartConversion"},
|
||||
{0x00270000, StopConversion, "StopConversion"},
|
||||
{0x00280000, IsBusyConversion, "IsBusyConversion"},
|
||||
{0x002901C0, SetConversionParams, "SetConversionParams"},
|
||||
{0x002901C0, SetPackageParameter, "SetPackageParameter"},
|
||||
{0x002A0000, PingProcess, "PingProcess"},
|
||||
{0x002B0000, DriverInitialize, "DriverInitialize"},
|
||||
{0x002C0000, DriverFinalize, "DriverFinalize"},
|
||||
{0x002D0000, nullptr, "GetPackageParameter"},
|
||||
{0x002D0000, GetPackageParameter, "GetPackageParameter"},
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -97,6 +97,7 @@ struct ConversionConfiguration {
|
|||
u16 input_line_width;
|
||||
u16 input_lines;
|
||||
CoefficientSet coefficients;
|
||||
u8 padding;
|
||||
u16 alpha;
|
||||
|
||||
/// Input parameters for the Y (luma) plane
|
||||
|
|
Loading…
Reference in a new issue