From 40074584ca671d05e94358afbf2082158261414d Mon Sep 17 00:00:00 2001 From: Dragios Date: Sat, 16 Apr 2016 01:32:18 +0800 Subject: [PATCH] Revert "Y2R PR cleanup (#11)" This reverts commit be43acf3d3544f0255c4968710ab620c56e073de. --- src/core/hle/service/y2r_u.cpp | 257 +++++++++------------------------ src/core/hle/service/y2r_u.h | 1 - 2 files changed, 65 insertions(+), 193 deletions(-) diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cpp index 5085e6940..22f373adf 100644 --- a/src/core/hle/service/y2r_u.cpp +++ b/src/core/hle/service/y2r_u.cpp @@ -4,7 +4,6 @@ #include -#include "common/common_funcs.h" #include "common/common_types.h" #include "common/logging/log.h" @@ -29,7 +28,7 @@ struct ConversionParameters { u16 input_line_width; u16 input_lines; StandardCoefficient standard_coefficient; - u8 padding; + u8 reserved; u16 alpha; }; static_assert(sizeof(ConversionParameters) == 12, "ConversionParameters struct has incorrect size"); @@ -74,7 +73,7 @@ ResultCode ConversionConfiguration::SetInputLines(u16 lines) { ResultCode ConversionConfiguration::SetStandardCoefficient(StandardCoefficient standard_coefficient) { size_t index = static_cast(standard_coefficient); - if (index >= ARRAY_SIZE(standard_coefficients)) { + if (index >= 4) { return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM, ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED } @@ -87,76 +86,36 @@ static void SetInputFormat(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); conversion.input_format = static_cast(cmd_buff[1]); - - cmd_buff[1] = RESULT_SUCCESS.raw; - LOG_DEBUG(Service_Y2R, "called input_format=%hhu", conversion.input_format); -} - -static void GetInputFormat(Service::Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); cmd_buff[1] = RESULT_SUCCESS.raw; - cmd_buff[2] = static_cast(conversion.input_format); - - LOG_DEBUG(Service_Y2R, "called Get input_format=%hhu", conversion.input_format); } static void SetOutputFormat(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); conversion.output_format = static_cast(cmd_buff[1]); - - cmd_buff[1] = RESULT_SUCCESS.raw; - LOG_DEBUG(Service_Y2R, "called output_format=%hhu", conversion.output_format); -} - -static void GetOutputFormat(Service::Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); cmd_buff[1] = RESULT_SUCCESS.raw; - cmd_buff[2] = static_cast(conversion.output_format); - - LOG_DEBUG(Service_Y2R, "called Get output_format=%hhu", conversion.output_format); } static void SetRotation(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); conversion.rotation = static_cast(cmd_buff[1]); - - cmd_buff[1] = RESULT_SUCCESS.raw; - LOG_DEBUG(Service_Y2R, "called rotation=%hhu", conversion.rotation); -} - -static void GetRotation(Service::Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); cmd_buff[1] = RESULT_SUCCESS.raw; - cmd_buff[2] = static_cast(conversion.rotation); - - LOG_DEBUG(Service_Y2R, "called Get rotation=%hhu", conversion.rotation); } static void SetBlockAlignment(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); conversion.block_alignment = static_cast(cmd_buff[1]); + LOG_DEBUG(Service_Y2R, "called alignment=%hhu", conversion.block_alignment); cmd_buff[1] = RESULT_SUCCESS.raw; - - LOG_DEBUG(Service_Y2R, "called block_alignment=%hhu", conversion.block_alignment); -} - -static void GetBlockAlignment(Service::Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); - - cmd_buff[1] = RESULT_SUCCESS.raw; - cmd_buff[2] = static_cast(conversion.block_alignment); - - LOG_DEBUG(Service_Y2R, "called Get block_alignment=%hhu", conversion.block_alignment); } static void SetTransferEndInterrupt(Service::Interface* self) { @@ -164,7 +123,6 @@ static void SetTransferEndInterrupt(Service::Interface* self) { cmd_buff[0] = IPC::MakeHeader(0xD, 1, 0); cmd_buff[1] = RESULT_SUCCESS.raw; - LOG_DEBUG(Service_Y2R, "(STUBBED) called"); } @@ -179,7 +137,6 @@ static void GetTransferEndEvent(Service::Interface* self) { cmd_buff[1] = RESULT_SUCCESS.raw; cmd_buff[3] = Kernel::g_handle_table.Create(completion_event).MoveFrom(); - LOG_DEBUG(Service_Y2R, "called"); } @@ -191,12 +148,11 @@ static void SetSendingY(Service::Interface* self) { conversion.src_Y.transfer_unit = cmd_buff[3]; conversion.src_Y.gap = cmd_buff[4]; u32 src_process_handle = cmd_buff[6]; - - cmd_buff[1] = RESULT_SUCCESS.raw; - 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); + + cmd_buff[1] = RESULT_SUCCESS.raw; } static void SetSendingU(Service::Interface* self) { @@ -207,12 +163,11 @@ static void SetSendingU(Service::Interface* self) { conversion.src_U.transfer_unit = cmd_buff[3]; conversion.src_U.gap = cmd_buff[4]; u32 src_process_handle = cmd_buff[6]; - - cmd_buff[1] = RESULT_SUCCESS.raw; - 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); + + cmd_buff[1] = RESULT_SUCCESS.raw; } static void SetSendingV(Service::Interface* self) { @@ -223,12 +178,11 @@ static void SetSendingV(Service::Interface* self) { conversion.src_V.transfer_unit = cmd_buff[3]; conversion.src_V.gap = cmd_buff[4]; u32 src_process_handle = cmd_buff[6]; - - cmd_buff[1] = RESULT_SUCCESS.raw; - 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); + + cmd_buff[1] = RESULT_SUCCESS.raw; } static void SetSendingYUYV(Service::Interface* self) { @@ -239,12 +193,11 @@ static void SetSendingYUYV(Service::Interface* self) { conversion.src_YUYV.transfer_unit = cmd_buff[3]; conversion.src_YUYV.gap = cmd_buff[4]; u32 src_process_handle = cmd_buff[6]; - - cmd_buff[1] = RESULT_SUCCESS.raw; - 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); + + cmd_buff[1] = RESULT_SUCCESS.raw; } static void SetReceiving(Service::Interface* self) { @@ -255,51 +208,26 @@ static void SetReceiving(Service::Interface* self) { conversion.dst.transfer_unit = cmd_buff[3]; conversion.dst.gap = cmd_buff[4]; u32 dst_process_handle = cmd_buff[6]; - - cmd_buff[1] = RESULT_SUCCESS.raw; - 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, dst_process_handle); + + cmd_buff[1] = RESULT_SUCCESS.raw; } static void SetInputLineWidth(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); - u16 width = cmd_buff[1]; - - cmd_buff[1] = conversion.SetInputLineWidth(width).raw; - LOG_DEBUG(Service_Y2R, "called input_line_width=%u", cmd_buff[1]); -} - -static void GetInputLineWidth(Service::Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); - - cmd_buff[1] = RESULT_SUCCESS.raw; - cmd_buff[2] = conversion.input_line_width; - - LOG_DEBUG(Service_Y2R, "called input_line_width=%u", conversion.input_line_width); + cmd_buff[1] = conversion.SetInputLineWidth(cmd_buff[1]).raw; } static void SetInputLines(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); - u16 lines = cmd_buff[1]; - - cmd_buff[1] = conversion.SetInputLines(lines).raw; - - LOG_DEBUG(Service_Y2R, "called input_lines=%u", cmd_buff[1]); -} - -static void GetInputLines(Service::Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); - - cmd_buff[1] = RESULT_SUCCESS.raw; - cmd_buff[2] = conversion.input_lines; - - LOG_DEBUG(Service_Y2R, "called Get input_lines=%u", conversion.input_lines); + LOG_DEBUG(Service_Y2R, "called input_line_number=%u", cmd_buff[1]); + cmd_buff[1] = conversion.SetInputLines(cmd_buff[1]).raw; } static void SetCoefficient(Service::Interface* self) { @@ -307,68 +235,28 @@ static void SetCoefficient(Service::Interface* self) { const u16* coefficients = reinterpret_cast(&cmd_buff[1]); std::memcpy(conversion.coefficients.data(), coefficients, sizeof(CoefficientSet)); - - cmd_buff[1] = RESULT_SUCCESS.raw; - LOG_DEBUG(Service_Y2R, "called coefficients=[%hX, %hX, %hX, %hX, %hX, %hX, %hX, %hX]", coefficients[0], coefficients[1], coefficients[2], coefficients[3], coefficients[4], coefficients[5], coefficients[6], coefficients[7]); -} - -static void GetCoefficient(Service::Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); cmd_buff[1] = RESULT_SUCCESS.raw; - - u16* coefficients = reinterpret_cast(&cmd_buff[2]); - std::memcpy(coefficients, conversion.coefficients.data(), sizeof(CoefficientSet)); - - LOG_DEBUG(Service_Y2R, "called Get coefficients=[%hX, %hX, %hX, %hX, %hX, %hX, %hX, %hX]", - coefficients[0], coefficients[1], coefficients[2], coefficients[3], - coefficients[4], coefficients[5], coefficients[6], coefficients[7]); } static void SetStandardCoefficient(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); - StandardCoefficient index = static_cast(cmd_buff[1]); + LOG_DEBUG(Service_Y2R, "called standard_coefficient=%u", cmd_buff[1]); - cmd_buff[1] = conversion.SetStandardCoefficient(index).raw; - - LOG_DEBUG(Service_Y2R, "called standard_coefficient=%hu", index); -} - -static void GetStandardCoefficientParams(Service::Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); - - u32 index = cmd_buff[1]; - - if (index < ARRAY_SIZE(standard_coefficients)) { - cmd_buff[1] = RESULT_SUCCESS.raw; - std::memcpy(&cmd_buff[2], &standard_coefficients[index], sizeof(CoefficientSet)); - LOG_DEBUG(Service_Y2R, "called Get standard_coefficient:0x%08X ", index); - } else { - cmd_buff[1] = -1; - LOG_ERROR(Service_Y2R, "called Get standard_coefficient:0x%08X The argument is invalid!", index); - } + cmd_buff[1] = conversion.SetStandardCoefficient((StandardCoefficient)cmd_buff[1]).raw; } static void SetAlpha(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); conversion.alpha = cmd_buff[1]; - cmd_buff[1] = RESULT_SUCCESS.raw; - LOG_DEBUG(Service_Y2R, "called alpha=%hu", conversion.alpha); -} - -static void GetAlpha(Service::Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); cmd_buff[1] = RESULT_SUCCESS.raw; - cmd_buff[2] = conversion.alpha; - - LOG_DEBUG(Service_Y2R, "called Get alpha=%hu", conversion.alpha); } static void StartConversion(Service::Interface* self) { @@ -393,7 +281,6 @@ static void StopConversion(Service::Interface* self) { cmd_buff[0] = IPC::MakeHeader(0x27, 1, 0); cmd_buff[1] = RESULT_SUCCESS.raw; - LOG_DEBUG(Service_Y2R, "called"); } @@ -408,24 +295,23 @@ static void IsBusyConversion(Service::Interface* self) { cmd_buff[1] = RESULT_SUCCESS.raw; cmd_buff[2] = 0; // StartConversion always finishes immediately - LOG_DEBUG(Service_Y2R, "called"); } /** * Y2R_U::SetConversionParams service function */ -static void SetPackageParameter(Service::Interface* self) { +static void SetConversionParams(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); auto params = reinterpret_cast(&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 " - "padding=%hhu alpha=%hX", + "reserved=%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->padding, params->alpha); + params->reserved, params->alpha); ResultCode result = RESULT_SUCCESS; @@ -439,7 +325,6 @@ static void SetPackageParameter(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: @@ -447,21 +332,11 @@ cleanup: cmd_buff[1] = result.raw; } -static void GetPackageParameter(Service::Interface* self) { - u32* cmd_buff = Kernel::GetCommandBuffer(); - - cmd_buff[1] = RESULT_SUCCESS.raw; - std::memcpy(&cmd_buff[2], &conversion, sizeof(ConversionParameters)); - - LOG_DEBUG(Service_Y2R, "called"); -} - static void PingProcess(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); cmd_buff[1] = RESULT_SUCCESS.raw; cmd_buff[2] = 0; - LOG_WARNING(Service_Y2R, "(STUBBED) called"); } @@ -487,7 +362,6 @@ static void DriverInitialize(Service::Interface* self) { cmd_buff[0] = IPC::MakeHeader(0x2B, 1, 0); cmd_buff[1] = RESULT_SUCCESS.raw; - LOG_DEBUG(Service_Y2R, "called"); } @@ -496,55 +370,54 @@ static void DriverFinalize(Service::Interface* self) { cmd_buff[0] = IPC::MakeHeader(0x2C, 1, 0); cmd_buff[1] = RESULT_SUCCESS.raw; - LOG_DEBUG(Service_Y2R, "called"); } const Interface::FunctionInfo FunctionTable[] = { - {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"}, + {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"}, }; //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/hle/service/y2r_u.h b/src/core/hle/service/y2r_u.h index f3a1d2205..3965a5545 100644 --- a/src/core/hle/service/y2r_u.h +++ b/src/core/hle/service/y2r_u.h @@ -97,7 +97,6 @@ struct ConversionConfiguration { u16 input_line_width; u16 input_lines; CoefficientSet coefficients; - u8 padding; u16 alpha; /// Input parameters for the Y (luma) plane