summaryrefslogtreecommitdiff
path: root/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp
blob: 8219a2c7e839b97a7f2f8e1e912bfa7f9b6cc419 (plain)
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
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "common/assert.h"
#include "common/logging/log.h"
#include "core/core.h"
#include "core/hle/service/nvdrv/core/container.h"
#include "core/hle/service/nvdrv/devices/ioctl_serialization.h"
#include "core/hle/service/nvdrv/devices/nvhost_vic.h"
#include "video_core/host1x/host1x.h"
#include "video_core/renderer_base.h"

namespace Service::Nvidia::Devices {

nvhost_vic::nvhost_vic(Core::System& system_, NvCore::Container& core_)
    : nvhost_nvdec_common{system_, core_, NvCore::ChannelType::VIC} {}

nvhost_vic::~nvhost_vic() = default;

NvResult nvhost_vic::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> input,
                            std::span<u8> output) {
    switch (command.group) {
    case 0x0:
        switch (command.cmd) {
        case 0x1:
            return WrapFixedVariable(this, &nvhost_vic::Submit, input, output, fd);
        case 0x2:
            return WrapFixed(this, &nvhost_vic::GetSyncpoint, input, output);
        case 0x3:
            return WrapFixed(this, &nvhost_vic::GetWaitbase, input, output);
        case 0x9:
            return WrapFixedVariable(this, &nvhost_vic::MapBuffer, input, output, fd);
        case 0xa:
            return WrapFixedVariable(this, &nvhost_vic::UnmapBuffer, input, output);
        default:
            break;
        }
        break;
    case 'H':
        switch (command.cmd) {
        case 0x1:
            return WrapFixed(this, &nvhost_vic::SetNVMAPfd, input, output);
        default:
            break;
        }
        break;
    default:
        break;
    }

    UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
    return NvResult::NotImplemented;
}

NvResult nvhost_vic::Ioctl2(DeviceFD fd, Ioctl command, std::span<const u8> input,
                            std::span<const u8> inline_input, std::span<u8> output) {
    UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
    return NvResult::NotImplemented;
}

NvResult nvhost_vic::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> input,
                            std::span<u8> output, std::span<u8> inline_output) {
    UNIMPLEMENTED_MSG("Unimplemented ioctl={:08X}", command.raw);
    return NvResult::NotImplemented;
}

void nvhost_vic::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {
    sessions[fd] = session_id;
    host1x.StartDevice(fd, Tegra::Host1x::ChannelType::VIC, channel_syncpoint);
}

void nvhost_vic::OnClose(DeviceFD fd) {
    host1x.StopDevice(fd, Tegra::Host1x::ChannelType::VIC);
    sessions.erase(fd);
}

} // namespace Service::Nvidia::Devices