summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/y2r_u.cpp
blob: edc44361100e5c508ca61ba8e44499a2a8d4fd48 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#include "common/logging/log.h"

#include "core/hle/hle.h"
#include "core/hle/kernel/event.h"
#include "core/hle/service/y2r_u.h"

////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace Y2R_U

namespace Y2R_U {

static Kernel::SharedPtr<Kernel::Event> completion_event;

/**
 * Y2R_U::IsBusyConversion service function
 *  Outputs:
 *      1 : Result of function, 0 on success, otherwise error code
 *      2 : Whether the current conversion is of type busy conversion (?)
 */
static void IsBusyConversion(Service::Interface* self) {
    u32* cmd_buff = Kernel::GetCommandBuffer();

    cmd_buff[1] = RESULT_SUCCESS.raw;;
    cmd_buff[2] = 0;

    LOG_WARNING(Service, "(STUBBED) called");
}

/**
 * Y2R_U::GetTransferEndEvent service function
 *  Outputs:
 *      1 : Result of function, 0 on success, otherwise error code
 *      3 : The handle of the completion event
 */
static void GetTransferEndEvent(Service::Interface* self) {
    u32* cmd_buff = Kernel::GetCommandBuffer();
    
    cmd_buff[1] = RESULT_SUCCESS.raw;
    cmd_buff[3] = Kernel::g_handle_table.Create(completion_event).MoveFrom();
}

/**
 * Starts a YUV -> RGB conversion
 */
static void StartConversion(Service::Interface* self) {
    u32* cmd_buff = Kernel::GetCommandBuffer();

    // TODO(bunnei): This is hack to indicate to the game that the conversion has immediately
    // completed, even though it's not actually implemented yet. This fixes games that would
    // otherwise hang on trying to play moflex videos, which uses the Y2R service.
    completion_event->Signal();

    LOG_WARNING(Service, "(STUBBED) called, expect blank video (MOFLEX) output!");

    cmd_buff[1] = RESULT_SUCCESS.raw;
}

const Interface::FunctionInfo FunctionTable[] = {
    {0x00010040, nullptr,                 "SetInputFormat"},
    {0x00030040, nullptr,                 "SetOutputFormat"},
    {0x00050040, nullptr,                 "SetRotation"},
    {0x00070040, nullptr,                 "SetBlockAlignment"},
    {0x000D0040, nullptr,                 "SetTransferEndInterrupt"},
    {0x000F0000, GetTransferEndEvent,     "GetTransferEndEvent"},
    {0x00100102, nullptr,                 "SetSendingY"},
    {0x00110102, nullptr,                 "SetSendingU"},
    {0x00120102, nullptr,                 "SetSendingV"},
    {0x00180102, nullptr,                 "SetReceiving"},
    {0x001A0040, nullptr,                 "SetInputLineWidth"},
    {0x001C0040, nullptr,                 "SetInputLines"},
    {0x00200040, nullptr,                 "SetStandardCoefficient"},
    {0x00220040, nullptr,                 "SetAlpha"},
    {0x00260000, StartConversion,         "StartConversion"},
    {0x00270000, nullptr,                 "StopConversion"},
    {0x00280000, IsBusyConversion,        "IsBusyConversion"},
    {0x002A0000, nullptr,                 "PingProcess"},
    {0x002B0000, nullptr,                 "DriverInitialize"},
    {0x002C0000, nullptr,                 "DriverFinalize"}
};

////////////////////////////////////////////////////////////////////////////////////////////////////
// Interface class

Interface::Interface() {
    completion_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "Y2R:Completed");

    Register(FunctionTable);
}
    
} // namespace