libnx/nx/source/nvidia/channel.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

49 lines
913 B
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/map.h"
#include "nvidia/channel.h"
Result nvChannelCreate(NvChannel* c, const char* dev)
{
Result rc;
c->has_init = true;
rc = nvOpen(&c->fd, dev);
if (R_FAILED(rc))
c->fd = -1;
if (R_SUCCEEDED(rc))
rc = nvioctlChannel_SetNvmapFd(c->fd, nvMapGetFd());
if (R_FAILED(rc))
nvChannelClose(c);
return rc;
}
void nvChannelClose(NvChannel* c)
{
if (!c->has_init)
return;
if (c->fd != -1)
nvClose(c->fd);
c->fd = -1;
}
Result nvChannelSetPriority(NvChannel* c, NvChannelPriority prio) {
return nvioctlChannel_SetPriority(c->fd, prio);
}
Result nvChannelSetTimeout(NvChannel* c, u32 timeout) {
return nvioctlChannel_SetTimeout(c->fd, timeout);
}