libnx/nx/source/nvidia/info.c
fincs 5fe01c065a Major refactor and redesign of nvidia wrapper objects, see details:
- NvBuffer replaced with NvMap, which only manages the creation of
  raw nvmap objects. Users must map these objects manually to
  address spaces.
- nvAddressSpaceBindToChannel removed.
- nvChannelSetNvmapFd is now automatic and has been removed.
- Nv3DContext, NvCmdList, NvErrorNotifier, NvGpfifo, NvGpu and
  NvZcullContext have all been removed.
- Introduced NvGpuChannel, which provides all functionality that was
  part of said removed objects.
- Other miscellaneous changes and fixes.
2018-12-19 19:33:31 +01:00

58 lines
1.1 KiB
C

#include <malloc.h>
#include "types.h"
#include "result.h"
#include "arm/atomics.h"
#include "kernel/svc.h"
#include "services/nv.h"
#include "nvidia/ioctl.h"
#include "nvidia/info.h"
static u32 g_ctrlgpu_fd = -1;
static u64 g_refCnt;
static nvioctl_gpu_characteristics g_gpu_characteristics;
static u32 g_zcull_ctx_size;
Result nvInfoInit(void)
{
Result rc;
if (atomicIncrement64(&g_refCnt) > 0)
return 0;
rc = nvOpen(&g_ctrlgpu_fd, "/dev/nvhost-ctrl-gpu");
if (R_FAILED(rc))
g_ctrlgpu_fd = -1;
if (R_SUCCEEDED(rc))
rc = nvioctlNvhostCtrlGpu_GetCharacteristics(g_ctrlgpu_fd, &g_gpu_characteristics);
if (R_SUCCEEDED(rc))
rc = nvioctlNvhostCtrlGpu_ZCullGetCtxSize(g_ctrlgpu_fd, &g_zcull_ctx_size);
if (R_FAILED(rc))
nvInfoExit();
return rc;
}
void nvInfoExit(void)
{
if (atomicDecrement64(&g_refCnt) == 0)
{
if (g_ctrlgpu_fd != -1)
nvClose(g_ctrlgpu_fd);
g_ctrlgpu_fd = -1;
}
}
const nvioctl_gpu_characteristics* nvInfoGetGpuCharacteristics(void) {
return &g_gpu_characteristics;
}
u32 nvInfoGetZcullCtxSize(void) {
return g_zcull_ctx_size;
}