nvdata.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // SPDX-FileCopyrightText: 2021 yuzu Emulator Project
  2. // SPDX-FileCopyrightText: 2021 Skyline Team and Contributors
  3. // SPDX-License-Identifier: GPL-3.0-or-later
  4. #pragma once
  5. #include <array>
  6. #include "common/bit_field.h"
  7. #include "common/common_types.h"
  8. namespace Service::Nvidia {
  9. constexpr u32 MaxSyncPoints = 192;
  10. constexpr u32 MaxNvEvents = 64;
  11. using DeviceFD = s32;
  12. constexpr DeviceFD INVALID_NVDRV_FD = -1;
  13. struct NvFence {
  14. s32 id;
  15. u32 value;
  16. };
  17. static_assert(sizeof(NvFence) == 8, "NvFence has wrong size");
  18. enum class NvResult : u32 {
  19. Success = 0x0,
  20. NotImplemented = 0x1,
  21. NotSupported = 0x2,
  22. NotInitialized = 0x3,
  23. BadParameter = 0x4,
  24. Timeout = 0x5,
  25. InsufficientMemory = 0x6,
  26. ReadOnlyAttribute = 0x7,
  27. InvalidState = 0x8,
  28. InvalidAddress = 0x9,
  29. InvalidSize = 0xA,
  30. BadValue = 0xB,
  31. AlreadyAllocated = 0xD,
  32. Busy = 0xE,
  33. ResourceError = 0xF,
  34. CountMismatch = 0x10,
  35. OverFlow = 0x11,
  36. InsufficientTransferMemory = 0x1000,
  37. InsufficientVideoMemory = 0x10000,
  38. BadSurfaceColorScheme = 0x10001,
  39. InvalidSurface = 0x10002,
  40. SurfaceNotSupported = 0x10003,
  41. DispInitFailed = 0x20000,
  42. DispAlreadyAttached = 0x20001,
  43. DispTooManyDisplays = 0x20002,
  44. DispNoDisplaysAttached = 0x20003,
  45. DispModeNotSupported = 0x20004,
  46. DispNotFound = 0x20005,
  47. DispAttachDissallowed = 0x20006,
  48. DispTypeNotSupported = 0x20007,
  49. DispAuthenticationFailed = 0x20008,
  50. DispNotAttached = 0x20009,
  51. DispSamePwrState = 0x2000A,
  52. DispEdidFailure = 0x2000B,
  53. DispDsiReadAckError = 0x2000C,
  54. DispDsiReadInvalidResp = 0x2000D,
  55. FileWriteFailed = 0x30000,
  56. FileReadFailed = 0x30001,
  57. EndOfFile = 0x30002,
  58. FileOperationFailed = 0x30003,
  59. DirOperationFailed = 0x30004,
  60. EndOfDirList = 0x30005,
  61. ConfigVarNotFound = 0x30006,
  62. InvalidConfigVar = 0x30007,
  63. LibraryNotFound = 0x30008,
  64. SymbolNotFound = 0x30009,
  65. MemoryMapFailed = 0x3000A,
  66. IoctlFailed = 0x3000F,
  67. AccessDenied = 0x30010,
  68. DeviceNotFound = 0x30011,
  69. KernelDriverNotFound = 0x30012,
  70. FileNotFound = 0x30013,
  71. PathAlreadyExists = 0x30014,
  72. ModuleNotPresent = 0xA000E,
  73. };
  74. // obtained from
  75. // https://github.com/skyline-emu/skyline/blob/nvdec-dev/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost/ctrl.h#L47
  76. enum class EventState {
  77. Available = 0,
  78. Waiting = 1,
  79. Cancelling = 2,
  80. Signalling = 3,
  81. Signalled = 4,
  82. Cancelled = 5,
  83. };
  84. union Ioctl {
  85. u32_le raw;
  86. BitField<0, 8, u32> cmd;
  87. BitField<8, 8, u32> group;
  88. BitField<16, 14, u32> length;
  89. BitField<30, 1, u32> is_in;
  90. BitField<31, 1, u32> is_out;
  91. };
  92. } // namespace Service::Nvidia