2015-05-22 04:27:48 +02:00
|
|
|
// Copyright 2015 Citra Emulator Project
|
2015-01-02 19:03:40 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2015-05-22 04:27:48 +02:00
|
|
|
#include <cstring>
|
2016-04-20 12:38:01 +02:00
|
|
|
#include "common/common_funcs.h"
|
2016-02-02 07:17:41 +01:00
|
|
|
#include "common/common_types.h"
|
2015-05-06 09:06:12 +02:00
|
|
|
#include "common/logging/log.h"
|
2017-06-06 10:29:46 +02:00
|
|
|
#include "core/hle/ipc.h"
|
|
|
|
#include "core/hle/ipc_helpers.h"
|
2015-01-02 19:03:40 +01:00
|
|
|
#include "core/hle/kernel/event.h"
|
2016-02-02 07:17:41 +01:00
|
|
|
#include "core/hle/kernel/kernel.h"
|
2016-09-21 08:52:38 +02:00
|
|
|
#include "core/hle/service/y2r_u.h"
|
2015-06-08 03:24:03 +02:00
|
|
|
#include "core/hw/y2r.h"
|
2015-05-22 23:49:42 +02:00
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
namespace Service {
|
|
|
|
namespace Y2R {
|
2015-01-02 19:03:40 +01:00
|
|
|
|
2015-05-22 04:27:48 +02:00
|
|
|
struct ConversionParameters {
|
|
|
|
InputFormat input_format;
|
|
|
|
OutputFormat output_format;
|
|
|
|
Rotation rotation;
|
2015-06-03 22:54:24 +02:00
|
|
|
BlockAlignment block_alignment;
|
2015-05-22 04:27:48 +02:00
|
|
|
u16 input_line_width;
|
|
|
|
u16 input_lines;
|
2015-06-03 22:54:24 +02:00
|
|
|
StandardCoefficient standard_coefficient;
|
2016-04-20 12:38:01 +02:00
|
|
|
u8 padding;
|
2015-06-03 22:54:24 +02:00
|
|
|
u16 alpha;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(ConversionParameters) == 12, "ConversionParameters struct has incorrect size");
|
|
|
|
|
2015-06-08 03:24:03 +02:00
|
|
|
static Kernel::SharedPtr<Kernel::Event> completion_event;
|
|
|
|
static ConversionConfiguration conversion;
|
2016-04-20 12:38:01 +02:00
|
|
|
static DitheringWeightParams dithering_weight_params;
|
|
|
|
static u32 temporal_dithering_enabled = 0;
|
|
|
|
static u32 transfer_end_interrupt_enabled = 0;
|
|
|
|
static u32 spacial_dithering_enabled = 0;
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2015-06-08 03:24:03 +02:00
|
|
|
static const CoefficientSet standard_coefficients[4] = {
|
2016-09-18 02:38:01 +02:00
|
|
|
{{0x100, 0x166, 0xB6, 0x58, 0x1C5, -0x166F, 0x10EE, -0x1C5B}}, // ITU_Rec601
|
|
|
|
{{0x100, 0x193, 0x77, 0x2F, 0x1DB, -0x1933, 0xA7C, -0x1D51}}, // ITU_Rec709
|
|
|
|
{{0x12A, 0x198, 0xD0, 0x64, 0x204, -0x1BDE, 0x10F2, -0x229B}}, // ITU_Rec601_Scaling
|
|
|
|
{{0x12A, 0x1CA, 0x88, 0x36, 0x21C, -0x1F04, 0x99C, -0x2421}}, // ITU_Rec709_Scaling
|
2015-05-22 04:27:48 +02:00
|
|
|
};
|
|
|
|
|
2015-06-08 03:24:03 +02:00
|
|
|
ResultCode ConversionConfiguration::SetInputLineWidth(u16 width) {
|
|
|
|
if (width == 0 || width > 1024 || width % 8 != 0) {
|
|
|
|
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
|
2016-09-18 02:38:01 +02:00
|
|
|
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
|
2015-06-08 03:24:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Note: The hardware uses the register value 0 to represent a width of 1024, so for a width of
|
|
|
|
// 1024 the `camera` module would set the value 0 here, but we don't need to emulate this
|
|
|
|
// internal detail.
|
|
|
|
this->input_line_width = width;
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResultCode ConversionConfiguration::SetInputLines(u16 lines) {
|
|
|
|
if (lines == 0 || lines > 1024) {
|
|
|
|
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
|
2016-09-18 02:38:01 +02:00
|
|
|
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
|
2015-06-08 03:24:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Note: In what appears to be a bug, the `camera` module does not set the hardware register at
|
|
|
|
// all if `lines` is 1024, so the conversion uses the last value that was set. The intention
|
|
|
|
// was probably to set it to 0 like in SetInputLineWidth.
|
|
|
|
if (lines != 1024) {
|
|
|
|
this->input_lines = lines;
|
|
|
|
}
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2016-09-19 03:01:46 +02:00
|
|
|
ResultCode ConversionConfiguration::SetStandardCoefficient(
|
|
|
|
StandardCoefficient standard_coefficient) {
|
2015-06-08 03:24:03 +02:00
|
|
|
size_t index = static_cast<size_t>(standard_coefficient);
|
2016-04-20 12:38:01 +02:00
|
|
|
if (index >= ARRAY_SIZE(standard_coefficients)) {
|
2015-06-08 03:24:03 +02:00
|
|
|
return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
|
2016-09-18 02:38:01 +02:00
|
|
|
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED
|
2015-06-08 03:24:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::memcpy(coefficients.data(), standard_coefficients[index].data(), sizeof(coefficients));
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
}
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetInputFormat(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1, 1, 0);
|
2015-01-11 07:46:44 +01:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
conversion.input_format = rp.PopEnum<InputFormat>();
|
2015-01-11 07:46:44 +01:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2017-11-01 11:19:51 +01:00
|
|
|
LOG_DEBUG(Service_Y2R, "called input_format=%hhu", static_cast<u8>(conversion.input_format));
|
2015-05-22 04:27:48 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetInputFormat(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x2, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushEnum(conversion.input_format);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2017-11-01 11:19:51 +01:00
|
|
|
LOG_DEBUG(Service_Y2R, "called input_format=%hhu", static_cast<u8>(conversion.input_format));
|
2016-04-20 12:38:01 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetOutputFormat(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x3, 1, 0);
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
conversion.output_format = rp.PopEnum<OutputFormat>();
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2017-11-01 11:19:51 +01:00
|
|
|
LOG_DEBUG(Service_Y2R, "called output_format=%hhu", static_cast<u8>(conversion.output_format));
|
2015-05-22 04:27:48 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetOutputFormat(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x4, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushEnum(conversion.output_format);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2017-11-01 11:19:51 +01:00
|
|
|
LOG_DEBUG(Service_Y2R, "called output_format=%hhu", static_cast<u8>(conversion.output_format));
|
2016-04-20 12:38:01 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetRotation(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x5, 1, 0);
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
conversion.rotation = rp.PopEnum<Rotation>();
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2017-11-01 11:19:51 +01:00
|
|
|
LOG_DEBUG(Service_Y2R, "called rotation=%hhu", static_cast<u8>(conversion.rotation));
|
2016-04-20 12:38:01 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetRotation(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x6, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushEnum(conversion.rotation);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2017-11-01 11:19:51 +01:00
|
|
|
LOG_DEBUG(Service_Y2R, "called rotation=%hhu", static_cast<u8>(conversion.rotation));
|
2015-05-22 04:27:48 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetBlockAlignment(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x7, 1, 0);
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
conversion.block_alignment = rp.PopEnum<BlockAlignment>();
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2017-11-01 11:19:51 +01:00
|
|
|
LOG_DEBUG(Service_Y2R, "called block_alignment=%hhu",
|
|
|
|
static_cast<u8>(conversion.block_alignment));
|
2016-04-20 12:38:01 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetBlockAlignment(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x8, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushEnum(conversion.block_alignment);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2017-11-01 11:19:51 +01:00
|
|
|
LOG_DEBUG(Service_Y2R, "called block_alignment=%hhu",
|
|
|
|
static_cast<u8>(conversion.block_alignment));
|
2016-04-20 12:38:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Y2R_U::SetSpacialDithering service function
|
|
|
|
* Inputs:
|
|
|
|
* 1 : u8, 0 = Disabled, 1 = Enabled
|
|
|
|
* Outputs:
|
|
|
|
* 1 : Result of function, 0 on success, otherwise error code
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetSpacialDithering(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x9, 1, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
spacial_dithering_enabled = rp.Pop<u8>() & 0xF;
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Y2R_U::GetSpacialDithering service function
|
|
|
|
* Outputs:
|
|
|
|
* 1 : Result of function, 0 on success, otherwise error code
|
|
|
|
* 2 : u8, 0 = Disabled, 1 = Enabled
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetSpacialDithering(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xA, 0, 0);
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
2016-12-30 15:54:40 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2017-02-11 15:07:12 +01:00
|
|
|
rb.Push(spacial_dithering_enabled != 0);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Y2R_U::SetTemporalDithering service function
|
|
|
|
* Inputs:
|
|
|
|
* 1 : u8, 0 = Disabled, 1 = Enabled
|
|
|
|
* Outputs:
|
|
|
|
* 1 : Result of function, 0 on success, otherwise error code
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetTemporalDithering(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xB, 1, 0);
|
|
|
|
temporal_dithering_enabled = rp.Pop<u8>() & 0xF;
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Y2R_U::GetTemporalDithering service function
|
|
|
|
* Outputs:
|
|
|
|
* 1 : Result of function, 0 on success, otherwise error code
|
|
|
|
* 2 : u8, 0 = Disabled, 1 = Enabled
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetTemporalDithering(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xC, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(temporal_dithering_enabled);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
2015-06-08 03:24:03 +02:00
|
|
|
}
|
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
/**
|
|
|
|
* Y2R_U::SetTransferEndInterrupt service function
|
|
|
|
* Inputs:
|
|
|
|
* 1 : u8, 0 = Disabled, 1 = Enabled
|
|
|
|
* Outputs:
|
|
|
|
* 1 : Result of function, 0 on success, otherwise error code
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetTransferEndInterrupt(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xD, 1, 0);
|
|
|
|
transfer_end_interrupt_enabled = rp.Pop<u8>() & 0xF;
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Y2R_U::GetTransferEndInterrupt service function
|
|
|
|
* Outputs:
|
|
|
|
* 1 : Result of function, 0 on success, otherwise error code
|
|
|
|
* 2 : u8, 0 = Disabled, 1 = Enabled
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetTransferEndInterrupt(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xE, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(transfer_end_interrupt_enabled);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
2015-01-11 07:46:44 +01:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:28:36 +01:00
|
|
|
/**
|
2015-06-03 22:54:24 +02:00
|
|
|
* Y2R_U::GetTransferEndEvent service function
|
|
|
|
* Outputs:
|
|
|
|
* 1 : Result of function, 0 on success, otherwise error code
|
|
|
|
* 3 : The handle of the completion event
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetTransferEndEvent(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xF, 0, 0);
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyHandles(Kernel::g_handle_table.Create(completion_event).Unwrap());
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2015-05-22 04:27:48 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called");
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetSendingY(Interface* self) {
|
2016-12-26 13:58:50 +01:00
|
|
|
// The helper should be passed by argument to the function
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x10, 4, 2);
|
2016-12-26 13:58:50 +01:00
|
|
|
conversion.src_Y.address = rp.Pop<u32>();
|
|
|
|
conversion.src_Y.image_size = rp.Pop<u32>();
|
|
|
|
conversion.src_Y.transfer_unit = rp.Pop<u32>();
|
|
|
|
conversion.src_Y.gap = rp.Pop<u32>();
|
|
|
|
Kernel::Handle src_process_handle = rp.PopHandle();
|
2015-06-08 03:24:03 +02:00
|
|
|
|
2016-12-26 13:58:50 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
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,
|
2016-12-26 13:58:50 +01:00
|
|
|
src_process_handle);
|
2015-06-08 03:24:03 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetSendingU(Interface* self) {
|
2016-12-26 13:58:50 +01:00
|
|
|
// The helper should be passed by argument to the function
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x11, 4, 2);
|
2016-12-26 13:58:50 +01:00
|
|
|
conversion.src_U.address = rp.Pop<u32>();
|
|
|
|
conversion.src_U.image_size = rp.Pop<u32>();
|
|
|
|
conversion.src_U.transfer_unit = rp.Pop<u32>();
|
|
|
|
conversion.src_U.gap = rp.Pop<u32>();
|
|
|
|
Kernel::Handle src_process_handle = rp.PopHandle();
|
2015-06-08 03:24:03 +02:00
|
|
|
|
2016-12-26 13:58:50 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
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,
|
2016-12-26 13:58:50 +01:00
|
|
|
src_process_handle);
|
2015-06-08 03:24:03 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetSendingV(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
// The helper should be passed by argument to the function
|
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x12, 4, 2);
|
2015-06-08 03:24:03 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
conversion.src_V.address = rp.Pop<u32>();
|
|
|
|
conversion.src_V.image_size = rp.Pop<u32>();
|
|
|
|
conversion.src_V.transfer_unit = rp.Pop<u32>();
|
|
|
|
conversion.src_V.gap = rp.Pop<u32>();
|
|
|
|
Kernel::Handle src_process_handle = rp.PopHandle();
|
2015-06-08 03:24:03 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
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,
|
2017-12-10 04:25:42 +01:00
|
|
|
static_cast<u32>(src_process_handle));
|
2015-06-08 03:24:03 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetSendingYUYV(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
// The helper should be passed by argument to the function
|
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x13, 4, 2);
|
2015-06-08 03:24:03 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
conversion.src_YUYV.address = rp.Pop<u32>();
|
|
|
|
conversion.src_YUYV.image_size = rp.Pop<u32>();
|
|
|
|
conversion.src_YUYV.transfer_unit = rp.Pop<u32>();
|
|
|
|
conversion.src_YUYV.gap = rp.Pop<u32>();
|
|
|
|
Kernel::Handle src_process_handle = rp.PopHandle();
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
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,
|
2017-12-10 04:25:42 +01:00
|
|
|
conversion.src_YUYV.gap, static_cast<u32>(src_process_handle));
|
2015-05-22 04:27:48 +02:00
|
|
|
}
|
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
/**
|
|
|
|
* Y2R::IsFinishedSendingYuv service function
|
|
|
|
* Output:
|
|
|
|
* 1 : Result of the function, 0 on success, otherwise error code
|
|
|
|
* 2 : u8, 0 = Not Finished, 1 = Finished
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void IsFinishedSendingYuv(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x14, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u8>(1);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Y2R::IsFinishedSendingY service function
|
|
|
|
* Output:
|
|
|
|
* 1 : Result of the function, 0 on success, otherwise error code
|
|
|
|
* 2 : u8, 0 = Not Finished, 1 = Finished
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void IsFinishedSendingY(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x15, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u8>(1);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Y2R::IsFinishedSendingU service function
|
|
|
|
* Output:
|
|
|
|
* 1 : Result of the function, 0 on success, otherwise error code
|
|
|
|
* 2 : u8, 0 = Not Finished, 1 = Finished
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void IsFinishedSendingU(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x16, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u8>(1);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Y2R::IsFinishedSendingV service function
|
|
|
|
* Output:
|
|
|
|
* 1 : Result of the function, 0 on success, otherwise error code
|
|
|
|
* 2 : u8, 0 = Not Finished, 1 = Finished
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void IsFinishedSendingV(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x17, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u8>(1);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetReceiving(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x18, 4, 2);
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
conversion.dst.address = rp.Pop<u32>();
|
|
|
|
conversion.dst.image_size = rp.Pop<u32>();
|
|
|
|
conversion.dst.transfer_unit = rp.Pop<u32>();
|
|
|
|
conversion.dst.gap = rp.Pop<u32>();
|
|
|
|
Kernel::Handle dst_process_handle = rp.PopHandle();
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
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,
|
2017-12-10 04:25:42 +01:00
|
|
|
static_cast<u32>(dst_process_handle));
|
2015-05-22 04:27:48 +02:00
|
|
|
}
|
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
/**
|
|
|
|
* Y2R::IsFinishedReceiving service function
|
|
|
|
* Output:
|
|
|
|
* 1 : Result of the function, 0 on success, otherwise error code
|
|
|
|
* 2 : u8, 0 = Not Finished, 1 = Finished
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void IsFinishedReceiving(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x19, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u8>(1);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetInputLineWidth(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1A, 1, 0);
|
|
|
|
u32 input_line_width = rp.Pop<u32>();
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(conversion.SetInputLineWidth(input_line_width));
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
LOG_DEBUG(Service_Y2R, "called input_line_width=%u", input_line_width);
|
2015-05-22 04:27:48 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetInputLineWidth(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1B, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(conversion.input_line_width);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called input_line_width=%u", conversion.input_line_width);
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetInputLines(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1C, 1, 0);
|
|
|
|
u32 input_lines = rp.Pop<u32>();
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(conversion.SetInputLines(input_lines));
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
LOG_DEBUG(Service_Y2R, "called input_lines=%u", input_lines);
|
2015-02-24 14:28:36 +01:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetInputLines(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1D, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(static_cast<u32>(conversion.input_lines));
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called input_lines=%u", conversion.input_lines);
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetCoefficient(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1E, 4, 0);
|
2015-05-20 03:11:32 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
rp.PopRaw<CoefficientSet>(conversion.coefficients);
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
|
|
|
LOG_DEBUG(Service_Y2R, "called coefficients=[%hX, %hX, %hX, %hX, %hX, %hX, %hX, %hX]",
|
2017-12-10 04:25:42 +01:00
|
|
|
conversion.coefficients[0], conversion.coefficients[1], conversion.coefficients[2],
|
|
|
|
conversion.coefficients[3], conversion.coefficients[4], conversion.coefficients[5],
|
|
|
|
conversion.coefficients[6], conversion.coefficients[7]);
|
2015-06-08 03:24:03 +02:00
|
|
|
}
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetCoefficient(Interface* self) {
|
2016-04-20 12:38:01 +02:00
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
|
|
|
|
cmd_buff[0] = IPC::MakeHeader(0x1F, 5, 0);
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
|
|
std::memcpy(&cmd_buff[2], conversion.coefficients.data(), sizeof(CoefficientSet));
|
2016-04-27 01:49:19 +02:00
|
|
|
|
|
|
|
LOG_DEBUG(Service_Y2R, "called");
|
2016-04-20 12:38:01 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetStandardCoefficient(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x20, 1, 0);
|
|
|
|
u32 index = rp.Pop<u32>();
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(conversion.SetStandardCoefficient(static_cast<StandardCoefficient>(index)));
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called standard_coefficient=%u", index);
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetStandardCoefficient(Interface* self) {
|
2016-04-20 12:38:01 +02:00
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
|
|
|
|
u32 index = cmd_buff[1];
|
|
|
|
|
|
|
|
if (index < ARRAY_SIZE(standard_coefficients)) {
|
|
|
|
cmd_buff[0] = IPC::MakeHeader(0x21, 5, 0);
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
2016-04-27 01:49:19 +02:00
|
|
|
std::memcpy(&cmd_buff[2], &standard_coefficients[index], sizeof(CoefficientSet));
|
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called standard_coefficient=%u ", index);
|
2016-04-27 01:49:19 +02:00
|
|
|
} else {
|
2016-04-20 12:38:01 +02:00
|
|
|
cmd_buff[0] = IPC::MakeHeader(0x21, 1, 0);
|
2017-01-11 17:47:20 +01:00
|
|
|
cmd_buff[1] = ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
|
|
|
|
ErrorSummary::InvalidArgument, ErrorLevel::Usage)
|
|
|
|
.raw;
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_ERROR(Service_Y2R, "called standard_coefficient=%u The argument is invalid!", index);
|
|
|
|
}
|
2015-06-08 03:24:03 +02:00
|
|
|
}
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetAlpha(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x22, 1, 0);
|
|
|
|
conversion.alpha = rp.Pop<u32>();
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
|
|
|
LOG_DEBUG(Service_Y2R, "called alpha=%hu", conversion.alpha);
|
2016-04-20 12:38:01 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetAlpha(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x23, 0, 0);
|
2016-04-20 12:38:01 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(conversion.alpha);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called alpha=%hu", conversion.alpha);
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetDitheringWeightParams(Interface* self) {
|
2016-12-26 13:58:50 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x24, 8, 0); // 0x240200
|
|
|
|
rp.PopRaw(dithering_weight_params);
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called");
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetDitheringWeightParams(Interface* self) {
|
2016-04-20 12:38:01 +02:00
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
|
|
|
|
cmd_buff[0] = IPC::MakeHeader(0x25, 9, 0);
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
|
|
std::memcpy(&cmd_buff[2], &dithering_weight_params, sizeof(DitheringWeightParams));
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-04-20 12:38:01 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called");
|
2015-06-08 03:24:03 +02:00
|
|
|
}
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void StartConversion(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x26, 0, 0);
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2015-06-08 03:24:03 +02:00
|
|
|
// dst_image_size would seem to be perfect for this, but it doesn't include the gap :(
|
2016-09-18 02:38:01 +02:00
|
|
|
u32 total_output_size =
|
|
|
|
conversion.input_lines * (conversion.dst.transfer_unit + conversion.dst.gap);
|
2017-06-22 07:48:00 +02:00
|
|
|
Memory::RasterizerFlushVirtualRegion(conversion.dst.address, total_output_size,
|
|
|
|
Memory::FlushMode::FlushAndInvalidate);
|
2016-04-17 00:57:57 +02:00
|
|
|
|
|
|
|
HW::Y2R::PerformConversion(conversion);
|
2015-05-22 23:49:42 +02:00
|
|
|
|
2015-05-20 03:11:32 +02:00
|
|
|
completion_event->Signal();
|
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
|
|
|
LOG_DEBUG(Service_Y2R, "called");
|
2015-05-22 04:27:48 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void StopConversion(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x27, 0, 0);
|
2015-06-08 03:24:03 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2015-06-08 03:24:03 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called");
|
|
|
|
}
|
|
|
|
|
2015-05-22 04:27:48 +02:00
|
|
|
/**
|
2015-06-03 22:54:24 +02:00
|
|
|
* Y2R_U::IsBusyConversion service function
|
|
|
|
* Outputs:
|
|
|
|
* 1 : Result of function, 0 on success, otherwise error code
|
|
|
|
* 2 : 1 if there's a conversion running, otherwise 0.
|
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void IsBusyConversion(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x28, 0, 0);
|
2015-05-20 03:11:32 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u8>(0); // StartConversion always finishes immediately
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2015-05-22 04:27:48 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called");
|
|
|
|
}
|
|
|
|
|
2015-06-03 22:54:24 +02:00
|
|
|
/**
|
2016-04-20 12:38:01 +02:00
|
|
|
* Y2R_U::SetPackageParameter service function
|
2015-06-03 22:54:24 +02:00
|
|
|
*/
|
2016-12-10 13:51:50 +01:00
|
|
|
static void SetPackageParameter(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x29, 7, 0);
|
|
|
|
auto params = rp.PopRaw<ConversionParameters>();
|
2015-06-03 22:54:24 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
conversion.input_format = params.input_format;
|
|
|
|
conversion.output_format = params.output_format;
|
|
|
|
conversion.rotation = params.rotation;
|
|
|
|
conversion.block_alignment = params.block_alignment;
|
2015-06-08 03:24:03 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
ResultCode result = conversion.SetInputLineWidth(params.input_line_width);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
|
|
|
if (result.IsError())
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
result = conversion.SetInputLines(params.input_lines);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
|
|
|
if (result.IsError())
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
result = conversion.SetStandardCoefficient(params.standard_coefficient);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
|
|
|
if (result.IsError())
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
conversion.padding = params.padding;
|
|
|
|
conversion.alpha = params.alpha;
|
2015-06-08 03:24:03 +02:00
|
|
|
|
|
|
|
cleanup:
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(result);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
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",
|
2017-12-10 04:25:42 +01:00
|
|
|
static_cast<u8>(params.input_format), static_cast<u8>(params.output_format),
|
|
|
|
static_cast<u8>(params.rotation), static_cast<u8>(params.block_alignment),
|
|
|
|
params.input_line_width, params.input_lines, static_cast<u8>(params.standard_coefficient),
|
|
|
|
params.padding, params.alpha);
|
2015-06-03 22:54:24 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void PingProcess(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x2A, 0, 0);
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u8>(0);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2015-05-22 04:27:48 +02:00
|
|
|
LOG_WARNING(Service_Y2R, "(STUBBED) called");
|
2015-05-20 03:11:32 +02:00
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void DriverInitialize(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x2B, 0, 0);
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
2015-06-08 03:24:03 +02:00
|
|
|
|
|
|
|
conversion.input_format = InputFormat::YUV422_Indiv8;
|
|
|
|
conversion.output_format = OutputFormat::RGBA8;
|
|
|
|
conversion.rotation = Rotation::None;
|
|
|
|
conversion.block_alignment = BlockAlignment::Linear;
|
|
|
|
conversion.coefficients.fill(0);
|
|
|
|
conversion.SetInputLineWidth(1024);
|
|
|
|
conversion.SetInputLines(1024);
|
|
|
|
conversion.alpha = 0;
|
|
|
|
|
|
|
|
ConversionBuffer zero_buffer = {};
|
|
|
|
conversion.src_Y = zero_buffer;
|
|
|
|
conversion.src_U = zero_buffer;
|
|
|
|
conversion.src_V = zero_buffer;
|
|
|
|
conversion.dst = zero_buffer;
|
|
|
|
|
|
|
|
completion_event->Clear();
|
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2015-06-08 03:24:03 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called");
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void DriverFinalize(Interface* self) {
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x2C, 0, 0);
|
2015-06-08 03:24:03 +02:00
|
|
|
|
2017-12-10 04:25:42 +01:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-04-27 01:49:19 +02:00
|
|
|
|
2015-06-08 03:24:03 +02:00
|
|
|
LOG_DEBUG(Service_Y2R, "called");
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
static void GetPackageParameter(Interface* self) {
|
2016-04-20 12:38:01 +02:00
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
|
|
|
|
cmd_buff[0] = IPC::MakeHeader(0x2D, 4, 0);
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
|
|
std::memcpy(&cmd_buff[2], &conversion, sizeof(ConversionParameters));
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_Y2R, "called");
|
|
|
|
}
|
|
|
|
|
2015-01-02 19:03:40 +01:00
|
|
|
const Interface::FunctionInfo FunctionTable[] = {
|
2016-09-18 02:38:01 +02:00
|
|
|
{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, SetSpacialDithering, "SetSpacialDithering"},
|
|
|
|
{0x000A0000, GetSpacialDithering, "GetSpacialDithering"},
|
|
|
|
{0x000B0040, SetTemporalDithering, "SetTemporalDithering"},
|
|
|
|
{0x000C0000, GetTemporalDithering, "GetTemporalDithering"},
|
2015-06-08 03:24:03 +02:00
|
|
|
{0x000D0040, SetTransferEndInterrupt, "SetTransferEndInterrupt"},
|
2016-04-20 12:38:01 +02:00
|
|
|
{0x000E0000, GetTransferEndInterrupt, "GetTransferEndInterrupt"},
|
2016-09-18 02:38:01 +02:00
|
|
|
{0x000F0000, GetTransferEndEvent, "GetTransferEndEvent"},
|
|
|
|
{0x00100102, SetSendingY, "SetSendingY"},
|
|
|
|
{0x00110102, SetSendingU, "SetSendingU"},
|
|
|
|
{0x00120102, SetSendingV, "SetSendingV"},
|
|
|
|
{0x00130102, SetSendingYUYV, "SetSendingYUYV"},
|
|
|
|
{0x00140000, IsFinishedSendingYuv, "IsFinishedSendingYuv"},
|
|
|
|
{0x00150000, IsFinishedSendingY, "IsFinishedSendingY"},
|
|
|
|
{0x00160000, IsFinishedSendingU, "IsFinishedSendingU"},
|
|
|
|
{0x00170000, IsFinishedSendingV, "IsFinishedSendingV"},
|
|
|
|
{0x00180102, SetReceiving, "SetReceiving"},
|
|
|
|
{0x00190000, IsFinishedReceiving, "IsFinishedReceiving"},
|
|
|
|
{0x001A0040, SetInputLineWidth, "SetInputLineWidth"},
|
|
|
|
{0x001B0000, GetInputLineWidth, "GetInputLineWidth"},
|
|
|
|
{0x001C0040, SetInputLines, "SetInputLines"},
|
|
|
|
{0x001D0000, GetInputLines, "GetInputLines"},
|
|
|
|
{0x001E0100, SetCoefficient, "SetCoefficient"},
|
|
|
|
{0x001F0000, GetCoefficient, "GetCoefficient"},
|
|
|
|
{0x00200040, SetStandardCoefficient, "SetStandardCoefficient"},
|
|
|
|
{0x00210040, GetStandardCoefficient, "GetStandardCoefficient"},
|
|
|
|
{0x00220040, SetAlpha, "SetAlpha"},
|
|
|
|
{0x00230000, GetAlpha, "GetAlpha"},
|
|
|
|
{0x00240200, SetDitheringWeightParams, "SetDitheringWeightParams"},
|
|
|
|
{0x00250000, GetDitheringWeightParams, "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"},
|
2015-01-02 19:03:40 +01:00
|
|
|
};
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
Y2R_U::Y2R_U() {
|
2016-03-13 03:47:41 +01:00
|
|
|
completion_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "Y2R:Completed");
|
2015-06-03 22:54:24 +02:00
|
|
|
std::memset(&conversion, 0, sizeof(conversion));
|
2015-02-24 14:28:36 +01:00
|
|
|
|
2015-01-30 19:56:49 +01:00
|
|
|
Register(FunctionTable);
|
2015-01-02 19:03:40 +01:00
|
|
|
}
|
2015-05-22 04:27:48 +02:00
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
Y2R_U::~Y2R_U() {
|
2015-07-17 07:24:13 +02:00
|
|
|
completion_event = nullptr;
|
|
|
|
}
|
|
|
|
|
2016-12-10 13:51:50 +01:00
|
|
|
} // namespace Y2R
|
2017-12-10 04:25:42 +01:00
|
|
|
} // namespace Service
|