Update and align the code of service y2r!

This commit is contained in:
JamePeng 2016-02-27 03:46:02 +08:00
parent 2e13b7f3ca
commit 0b636d1fd1
2 changed files with 271 additions and 71 deletions

View file

@ -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,14 +203,17 @@ 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();
conversion.src_Y.address = cmd_buff[1];
conversion.src_Y.image_size = cmd_buff[2];
conversion.src_Y.address = cmd_buff[1];
conversion.src_Y.image_size = cmd_buff[2];
conversion.src_Y.transfer_unit = cmd_buff[3];
conversion.src_Y.gap = cmd_buff[4];
u32 src_process_handle = cmd_buff[6];
conversion.src_Y.gap = cmd_buff[4];
u32 src_process_handle = cmd_buff[6];
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
"src_process_handle=0x%08X", conversion.src_Y.image_size,
conversion.src_Y.transfer_unit, conversion.src_Y.gap, src_process_handle);
@ -155,14 +221,17 @@ 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();
conversion.src_U.address = cmd_buff[1];
conversion.src_U.image_size = cmd_buff[2];
conversion.src_U.address = cmd_buff[1];
conversion.src_U.image_size = cmd_buff[2];
conversion.src_U.transfer_unit = cmd_buff[3];
conversion.src_U.gap = cmd_buff[4];
u32 src_process_handle = cmd_buff[6];
conversion.src_U.gap = cmd_buff[4];
u32 src_process_handle = cmd_buff[6];
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
"src_process_handle=0x%08X", conversion.src_U.image_size,
conversion.src_U.transfer_unit, conversion.src_U.gap, src_process_handle);
@ -170,14 +239,17 @@ 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();
conversion.src_V.address = cmd_buff[1];
conversion.src_V.image_size = cmd_buff[2];
conversion.src_V.address = cmd_buff[1];
conversion.src_V.image_size = cmd_buff[2];
conversion.src_V.transfer_unit = cmd_buff[3];
conversion.src_V.gap = cmd_buff[4];
u32 src_process_handle = cmd_buff[6];
conversion.src_V.gap = cmd_buff[4];
u32 src_process_handle = cmd_buff[6];
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
"src_process_handle=0x%08X", conversion.src_V.image_size,
conversion.src_V.transfer_unit, conversion.src_V.gap, src_process_handle);
@ -185,14 +257,17 @@ 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();
conversion.src_YUYV.address = cmd_buff[1];
conversion.src_YUYV.image_size = cmd_buff[2];
conversion.src_YUYV.address = cmd_buff[1];
conversion.src_YUYV.image_size = cmd_buff[2];
conversion.src_YUYV.transfer_unit = cmd_buff[3];
conversion.src_YUYV.gap = cmd_buff[4];
u32 src_process_handle = cmd_buff[6];
conversion.src_YUYV.gap = cmd_buff[4];
u32 src_process_handle = cmd_buff[6];
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
"src_process_handle=0x%08X", conversion.src_YUYV.image_size,
conversion.src_YUYV.transfer_unit, conversion.src_YUYV.gap, src_process_handle);
@ -200,14 +275,17 @@ 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();
conversion.dst.address = cmd_buff[1];
conversion.dst.image_size = cmd_buff[2];
conversion.dst.address = cmd_buff[1];
conversion.dst.image_size = cmd_buff[2];
conversion.dst.transfer_unit = cmd_buff[3];
conversion.dst.gap = cmd_buff[4];
u32 dst_process_handle = cmd_buff[6];
conversion.dst.gap = cmd_buff[4];
u32 dst_process_handle = cmd_buff[6];
LOG_DEBUG(Service_Y2R, "called image_size=0x%08X, transfer_unit=%hu, transfer_stride=%hu, "
"dst_process_handle=0x%08X", conversion.dst.image_size,
conversion.dst.transfer_unit, conversion.dst.gap,
@ -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();
@ -356,7 +552,7 @@ static void DriverInitialize(Service::Interface* self) {
conversion.src_Y = zero_buffer;
conversion.src_U = zero_buffer;
conversion.src_V = zero_buffer;
conversion.dst = zero_buffer;
conversion.dst = zero_buffer;
completion_event->Clear();
@ -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();
@ -374,50 +573,50 @@ static void DriverFinalize(Service::Interface* self) {
}
const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, SetInputFormat, "SetInputFormat"},
{0x00020000, nullptr, "GetInputFormat"},
{0x00030040, SetOutputFormat, "SetOutputFormat"},
{0x00040000, nullptr, "GetOutputFormat"},
{0x00050040, SetRotation, "SetRotation"},
{0x00060000, nullptr, "GetRotation"},
{0x00070040, SetBlockAlignment, "SetBlockAlignment"},
{0x00080000, nullptr, "GetBlockAlignment"},
{0x00090040, nullptr, "SetSpacialDithering"},
{0x000A0000, nullptr, "GetSpacialDithering"},
{0x000B0040, nullptr, "SetTemporalDithering"},
{0x000C0000, nullptr, "GetTemporalDithering"},
{0x000D0040, SetTransferEndInterrupt, "SetTransferEndInterrupt"},
{0x000F0000, GetTransferEndEvent, "GetTransferEndEvent"},
{0x00100102, SetSendingY, "SetSendingY"},
{0x00110102, SetSendingU, "SetSendingU"},
{0x00120102, SetSendingV, "SetSendingV"},
{0x00130102, SetSendingYUYV, "SetSendingYUYV"},
{0x00140000, nullptr, "IsFinishedSendingYuv"},
{0x00150000, nullptr, "IsFinishedSendingY"},
{0x00160000, nullptr, "IsFinishedSendingU"},
{0x00170000, nullptr, "IsFinishedSendingV"},
{0x00180102, SetReceiving, "SetReceiving"},
{0x00190000, nullptr, "IsFinishedReceiving"},
{0x001A0040, SetInputLineWidth, "SetInputLineWidth"},
{0x001B0000, nullptr, "GetInputLineWidth"},
{0x001C0040, SetInputLines, "SetInputLines"},
{0x001D0000, nullptr, "GetInputLines"},
{0x001E0100, SetCoefficient, "SetCoefficient"},
{0x001F0000, nullptr, "GetCoefficient"},
{0x00200040, SetStandardCoefficient, "SetStandardCoefficient"},
{0x00210040, nullptr, "GetStandardCoefficientParams"},
{0x00220040, SetAlpha, "SetAlpha"},
{0x00230000, nullptr, "GetAlpha"},
{0x00240200, nullptr, "SetDitheringWeightParams"},
{0x00250000, nullptr, "GetDitheringWeightParams"},
{0x00260000, StartConversion, "StartConversion"},
{0x00270000, StopConversion, "StopConversion"},
{0x00280000, IsBusyConversion, "IsBusyConversion"},
{0x002901C0, SetConversionParams, "SetConversionParams"},
{0x002A0000, PingProcess, "PingProcess"},
{0x002B0000, DriverInitialize, "DriverInitialize"},
{0x002C0000, DriverFinalize, "DriverFinalize"},
{0x002D0000, nullptr, "GetPackageParameter"},
{0x00010040, SetInputFormat, "SetInputFormat"},
{0x00020000, GetInputFormat, "GetInputFormat"},
{0x00030040, SetOutputFormat, "SetOutputFormat"},
{0x00040000, GetOutputFormat, "GetOutputFormat"},
{0x00050040, SetRotation, "SetRotation"},
{0x00060000, GetRotation, "GetRotation"},
{0x00070040, SetBlockAlignment, "SetBlockAlignment"},
{0x00080000, GetBlockAlignment, "GetBlockAlignment"},
{0x00090040, nullptr, "SetSpacialDithering"},
{0x000A0000, nullptr, "GetSpacialDithering"},
{0x000B0040, nullptr, "SetTemporalDithering"},
{0x000C0000, nullptr, "GetTemporalDithering"},
{0x000D0040, SetTransferEndInterrupt, "SetTransferEndInterrupt"},
{0x000F0000, GetTransferEndEvent, "GetTransferEndEvent"},
{0x00100102, SetSendingY, "SetSendingY"},
{0x00110102, SetSendingU, "SetSendingU"},
{0x00120102, SetSendingV, "SetSendingV"},
{0x00130102, SetSendingYUYV, "SetSendingYUYV"},
{0x00140000, nullptr, "IsFinishedSendingYuv"},
{0x00150000, nullptr, "IsFinishedSendingY"},
{0x00160000, nullptr, "IsFinishedSendingU"},
{0x00170000, nullptr, "IsFinishedSendingV"},
{0x00180102, SetReceiving, "SetReceiving"},
{0x00190000, nullptr, "IsFinishedReceiving"},
{0x001A0040, SetInputLineWidth, "SetInputLineWidth"},
{0x001B0000, GetInputLineWidth, "GetInputLineWidth"},
{0x001C0040, SetInputLines, "SetInputLines"},
{0x001D0000, GetInputLines, "GetInputLines"},
{0x001E0100, SetCoefficient, "SetCoefficient"},
{0x001F0000, GetCoefficient, "GetCoefficient"},
{0x00200040, SetStandardCoefficient, "SetStandardCoefficient"},
{0x00210040, GetStandardCoefficientParams,"GetStandardCoefficientParams"},
{0x00220040, SetAlpha, "SetAlpha"},
{0x00230000, GetAlpha, "GetAlpha"},
{0x00240200, nullptr, "SetDitheringWeightParams"},
{0x00250000, nullptr, "GetDitheringWeightParams"},
{0x00260000, StartConversion, "StartConversion"},
{0x00270000, StopConversion, "StopConversion"},
{0x00280000, IsBusyConversion, "IsBusyConversion"},
{0x002901C0, SetPackageParameter, "SetPackageParameter"},
{0x002A0000, PingProcess, "PingProcess"},
{0x002B0000, DriverInitialize, "DriverInitialize"},
{0x002C0000, DriverFinalize, "DriverFinalize"},
{0x002D0000, GetPackageParameter, "GetPackageParameter"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -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