summaryrefslogtreecommitdiff
path: root/lib/libdrm/tegra
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2022-06-06 12:14:08 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2022-06-06 12:14:08 +0000
commit2bd8150b39195449b9473a7afa51dc88f7650b60 (patch)
tree30fcb5c94c1562113321613766c363a54d607b79 /lib/libdrm/tegra
parent3c012d229d655ce7ec8da541464f38b441b1ae3d (diff)
Import libdrm 2.4.111
Diffstat (limited to 'lib/libdrm/tegra')
-rw-r--r--lib/libdrm/tegra/channel.c195
-rw-r--r--lib/libdrm/tegra/job.c187
-rw-r--r--lib/libdrm/tegra/meson.build7
-rw-r--r--lib/libdrm/tegra/private.h85
-rw-r--r--lib/libdrm/tegra/pushbuf.c184
-rw-r--r--lib/libdrm/tegra/syncpt.c101
-rw-r--r--lib/libdrm/tegra/tegra-symbols.txt27
-rw-r--r--lib/libdrm/tegra/tegra.c386
-rw-r--r--lib/libdrm/tegra/tegra.h95
9 files changed, 1061 insertions, 206 deletions
diff --git a/lib/libdrm/tegra/channel.c b/lib/libdrm/tegra/channel.c
new file mode 100644
index 000000000..391362023
--- /dev/null
+++ b/lib/libdrm/tegra/channel.c
@@ -0,0 +1,195 @@
+/*
+ * Copyright © 2012, 2013 Thierry Reding
+ * Copyright © 2013 Erik Faye-Lund
+ * Copyright © 2014-2021 NVIDIA Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <errno.h>
+#include <string.h>
+
+#include <sys/ioctl.h>
+
+#include "private.h"
+
+drm_public int
+drm_tegra_channel_open(struct drm_tegra *drm,
+ enum drm_tegra_class client,
+ struct drm_tegra_channel **channelp)
+{
+ struct drm_tegra_channel_open args;
+ struct drm_tegra_channel *channel;
+ enum host1x_class class;
+ int err;
+
+ switch (client) {
+ case DRM_TEGRA_HOST1X:
+ class = HOST1X_CLASS_HOST1X;
+ break;
+
+ case DRM_TEGRA_GR2D:
+ class = HOST1X_CLASS_GR2D;
+ break;
+
+ case DRM_TEGRA_GR3D:
+ class = HOST1X_CLASS_GR3D;
+ break;
+
+ case DRM_TEGRA_VIC:
+ class = HOST1X_CLASS_VIC;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ channel = calloc(1, sizeof(*channel));
+ if (!channel)
+ return -ENOMEM;
+
+ channel->drm = drm;
+
+ memset(&args, 0, sizeof(args));
+ args.host1x_class = class;
+
+ err = ioctl(drm->fd, DRM_IOCTL_TEGRA_CHANNEL_OPEN, &args);
+ if (err < 0) {
+ free(channel);
+ return -errno;
+ }
+
+ channel->context = args.context;
+ channel->version = args.version;
+ channel->capabilities = args.capabilities;
+ channel->class = class;
+
+ switch (channel->version) {
+ case 0x20:
+ case 0x30:
+ case 0x35:
+ case 0x40:
+ case 0x21:
+ channel->cond_shift = 8;
+ break;
+
+ case 0x18:
+ case 0x19:
+ channel->cond_shift = 10;
+ break;
+
+ default:
+ return -ENOTSUP;
+ }
+
+ *channelp = channel;
+
+ return 0;
+}
+
+drm_public int drm_tegra_channel_close(struct drm_tegra_channel *channel)
+{
+ struct drm_tegra_channel_close args;
+ struct drm_tegra *drm;
+ int err;
+
+ if (!channel)
+ return -EINVAL;
+
+ drm = channel->drm;
+
+ memset(&args, 0, sizeof(args));
+ args.context = channel->context;
+
+ err = ioctl(drm->fd, DRM_IOCTL_TEGRA_CHANNEL_CLOSE, &args);
+ if (err < 0)
+ return -errno;
+
+ free(channel);
+
+ return 0;
+}
+
+drm_public unsigned int
+drm_tegra_channel_get_version(struct drm_tegra_channel *channel)
+{
+ return channel->version;
+}
+
+drm_public int
+drm_tegra_channel_map(struct drm_tegra_channel *channel,
+ struct drm_tegra_bo *bo, uint32_t flags,
+ struct drm_tegra_mapping **mapp)
+{
+ struct drm_tegra *drm = channel->drm;
+ struct drm_tegra_channel_map args;
+ struct drm_tegra_mapping *map;
+ int err;
+
+ if (!drm || !bo || !mapp)
+ return -EINVAL;
+
+ map = calloc(1, sizeof(*map));
+ if (!map)
+ return -ENOMEM;
+
+ memset(&args, 0, sizeof(args));
+ args.context = channel->context;
+ args.handle = bo->handle;
+ args.flags = flags;
+
+ err = ioctl(drm->fd, DRM_IOCTL_TEGRA_CHANNEL_MAP, &args);
+ if (err < 0) {
+ free(map);
+ return -errno;
+ }
+
+ map->channel = channel;
+ map->id = args.mapping;
+ *mapp = map;
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_channel_unmap(struct drm_tegra_mapping *map)
+{
+ struct drm_tegra_channel *channel = map->channel;
+ struct drm_tegra *drm = channel->drm;
+ struct drm_tegra_channel_unmap args;
+ int err;
+
+ if (!channel || !map)
+ return -EINVAL;
+
+ memset(&args, 0, sizeof(args));
+ args.context = channel->context;
+ args.mapping = map->id;
+
+ err = ioctl(drm->fd, DRM_IOCTL_TEGRA_CHANNEL_UNMAP, &args);
+ if (err < 0)
+ return -errno;
+
+ free(map);
+ return 0;
+}
diff --git a/lib/libdrm/tegra/job.c b/lib/libdrm/tegra/job.c
new file mode 100644
index 000000000..75a344f1d
--- /dev/null
+++ b/lib/libdrm/tegra/job.c
@@ -0,0 +1,187 @@
+/*
+ * Copyright © 2012, 2013 Thierry Reding
+ * Copyright © 2013 Erik Faye-Lund
+ * Copyright © 2014 NVIDIA Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#include <sys/ioctl.h>
+#include <sys/poll.h>
+
+#include "private.h"
+
+struct drm_tegra_submit_cmd *
+drm_tegra_job_add_command(struct drm_tegra_job *job, uint32_t type,
+ uint32_t flags)
+{
+ struct drm_tegra_submit_cmd *commands, *command;
+ size_t size;
+
+ size = (job->num_commands + 1) * sizeof(*commands);
+
+ commands = realloc(job->commands, size);
+ if (!commands)
+ return NULL;
+
+ command = &commands[job->num_commands];
+ memset(command, 0, sizeof(*command));
+ command->type = type;
+ command->flags = flags;
+
+ job->commands = commands;
+ job->num_commands++;
+
+ return command;
+}
+
+drm_public int
+drm_tegra_job_new(struct drm_tegra_channel *channel,
+ struct drm_tegra_job **jobp)
+{
+ struct drm_tegra_job *job;
+
+ job = calloc(1, sizeof(*job));
+ if (!job)
+ return -ENOMEM;
+
+ job->page_size = sysconf(_SC_PAGESIZE);
+ job->channel = channel;
+
+ *jobp = job;
+
+ return 0;
+}
+
+drm_public int drm_tegra_job_free(struct drm_tegra_job *job)
+{
+ if (!job)
+ return -EINVAL;
+
+ if (job->pushbuf)
+ drm_tegra_pushbuf_free(job->pushbuf);
+
+ if (job->commands)
+ free(job->commands);
+
+ if (job->buffers)
+ free(job->buffers);
+
+ free(job);
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_job_get_pushbuf(struct drm_tegra_job *job,
+ struct drm_tegra_pushbuf **pushbufp)
+{
+ struct drm_tegra_pushbuf *pushbuf;
+
+ if (!job->pushbuf) {
+ pushbuf = calloc(1, sizeof(*pushbuf));
+ if (!pushbuf)
+ return -ENOMEM;
+
+ pushbuf->job = job;
+
+ pushbuf->start = calloc(1, job->page_size);
+ if (!pushbuf->start) {
+ free(pushbuf);
+ return -ENOMEM;
+ }
+
+ pushbuf->end = pushbuf->start + job->page_size / 4;
+ pushbuf->ptr = pushbuf->start;
+
+ job->pushbuf = pushbuf;
+ }
+
+ *pushbufp = job->pushbuf;
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_job_submit(struct drm_tegra_job *job, struct drm_tegra_fence *fence)
+{
+ struct drm_tegra_channel *channel = job->channel;
+ struct drm_tegra *drm = channel->drm;
+ struct drm_tegra_channel_submit args;
+ int err;
+
+ memset(&args, 0, sizeof(args));
+ args.context = channel->context;
+ args.num_bufs = job->num_buffers;
+ args.num_cmds = job->num_commands;
+ args.gather_data_words = job->pushbuf->ptr - job->pushbuf->start;
+ args.syncpt.id = job->syncpt.id;
+ args.syncpt.increments = job->syncpt.increments;
+
+ args.bufs_ptr = (uintptr_t)job->buffers;
+ args.cmds_ptr = (uintptr_t)job->commands;
+ args.gather_data_ptr = (uintptr_t)job->pushbuf->start;
+
+ err = ioctl(drm->fd, DRM_IOCTL_TEGRA_CHANNEL_SUBMIT, &args);
+ if (err < 0)
+ return -errno;
+
+ job->syncpt.fence = args.syncpt.value;
+
+ if (fence) {
+ fence->drm = drm;
+ fence->syncpt = job->syncpt.id;
+ fence->value = job->syncpt.fence;
+ }
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_job_wait(struct drm_tegra_job *job, unsigned long timeout)
+{
+ struct drm_tegra_channel *channel = job->channel;
+ struct drm_tegra *drm = channel->drm;
+ struct drm_tegra_syncpoint_wait args;
+ struct timespec ts;
+ int err;
+
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+
+ memset(&args, 0, sizeof(args));
+ args.timeout_ns = ts.tv_sec * 1000000000 + ts.tv_nsec + timeout;
+ args.id = job->syncpt.id;
+ args.threshold = job->syncpt.fence;
+
+ err = ioctl(drm->fd, DRM_IOCTL_TEGRA_SYNCPOINT_WAIT, &args);
+ if (err < 0)
+ return -errno;
+
+ return 0;
+}
diff --git a/lib/libdrm/tegra/meson.build b/lib/libdrm/tegra/meson.build
index 7585c8b5b..0b63d7894 100644
--- a/lib/libdrm/tegra/meson.build
+++ b/lib/libdrm/tegra/meson.build
@@ -20,7 +20,12 @@
libdrm_tegra = library(
'drm_tegra',
- [files('tegra.c'), config_file],
+ [
+ files(
+ 'channel.c', 'job.c', 'private.h', 'pushbuf.c', 'syncpt.c', 'tegra.c'
+ ),
+ config_file
+ ],
include_directories : [inc_root, inc_drm],
link_with : libdrm,
dependencies : [dep_pthread_stubs, dep_atomic_ops],
diff --git a/lib/libdrm/tegra/private.h b/lib/libdrm/tegra/private.h
index bb6c1a516..fc204e82e 100644
--- a/lib/libdrm/tegra/private.h
+++ b/lib/libdrm/tegra/private.h
@@ -26,26 +26,93 @@
#define __DRM_TEGRA_PRIVATE_H__ 1
#include <stdbool.h>
+#include <stddef.h>
#include <stdint.h>
#include <libdrm_macros.h>
#include <xf86atomic.h>
+#include "tegra_drm.h"
#include "tegra.h"
+#define container_of(ptr, type, member) ({ \
+ const __typeof__(((type *)0)->member) *__mptr = (ptr); \
+ (type *)((char *)__mptr - offsetof(type, member)); \
+ })
+
+enum host1x_class {
+ HOST1X_CLASS_HOST1X = 0x01,
+ HOST1X_CLASS_GR2D = 0x51,
+ HOST1X_CLASS_GR2D_SB = 0x52,
+ HOST1X_CLASS_VIC = 0x5d,
+ HOST1X_CLASS_GR3D = 0x60,
+};
+
struct drm_tegra {
- bool close;
- int fd;
+ bool close;
+ int fd;
};
struct drm_tegra_bo {
- struct drm_tegra *drm;
- uint32_t handle;
- uint32_t offset;
- uint32_t flags;
- uint32_t size;
- atomic_t ref;
- void *map;
+ struct drm_tegra *drm;
+ uint32_t handle;
+ uint64_t offset;
+ uint32_t flags;
+ uint32_t size;
+ atomic_t ref;
+ void *map;
+};
+
+struct drm_tegra_channel {
+ struct drm_tegra *drm;
+ enum host1x_class class;
+ uint32_t capabilities;
+ unsigned int version;
+ uint64_t context;
+
+ unsigned int cond_shift;
+};
+
+struct drm_tegra_mapping {
+ struct drm_tegra_channel *channel;
+ uint32_t id;
+};
+
+struct drm_tegra_pushbuf {
+ struct drm_tegra_job *job;
+
+ uint32_t *start;
+ uint32_t *end;
+ uint32_t *ptr;
+};
+
+void drm_tegra_pushbuf_free(struct drm_tegra_pushbuf *pushbuf);
+
+struct drm_tegra_job {
+ struct drm_tegra_channel *channel;
+ struct drm_tegra_pushbuf *pushbuf;
+ size_t page_size;
+
+ struct drm_tegra_submit_cmd *commands;
+ unsigned int num_commands;
+
+ struct drm_tegra_submit_buf *buffers;
+ unsigned int num_buffers;
+
+ struct {
+ uint32_t id;
+ uint32_t increments;
+ uint32_t fence;
+ } syncpt;
+};
+
+struct drm_tegra_submit_cmd *
+drm_tegra_job_add_command(struct drm_tegra_job *job, uint32_t type,
+ uint32_t flags);
+
+struct drm_tegra_syncpoint {
+ struct drm_tegra *drm;
+ uint32_t id;
};
#endif /* __DRM_TEGRA_PRIVATE_H__ */
diff --git a/lib/libdrm/tegra/pushbuf.c b/lib/libdrm/tegra/pushbuf.c
new file mode 100644
index 000000000..0c0212e12
--- /dev/null
+++ b/lib/libdrm/tegra/pushbuf.c
@@ -0,0 +1,184 @@
+/*
+ * Copyright © 2012, 2013 Thierry Reding
+ * Copyright © 2013 Erik Faye-Lund
+ * Copyright © 2014 NVIDIA Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "util_math.h"
+#include "private.h"
+
+#define HOST1X_OPCODE_NONINCR(offset, count) \
+ ((0x2 << 28) | (((offset) & 0xfff) << 16) | ((count) & 0xffff))
+
+static inline unsigned int
+drm_tegra_pushbuf_get_offset(struct drm_tegra_pushbuf *pushbuf, uint32_t *ptr)
+{
+ return ptr - pushbuf->start;
+}
+
+void drm_tegra_pushbuf_free(struct drm_tegra_pushbuf *pushbuf)
+{
+ if (pushbuf->start)
+ free(pushbuf->start);
+
+ free(pushbuf);
+}
+
+/**
+ * drm_tegra_pushbuf_begin() - prepare push buffer for a series of pushes
+ * @pushbuf: push buffer
+ * @words: maximum number of words in series of pushes to follow
+ */
+drm_public int
+drm_tegra_pushbuf_begin(struct drm_tegra_pushbuf *pushbuf,
+ unsigned int words, uint32_t **ptrp)
+{
+ struct drm_tegra_job *job = pushbuf->job;
+ unsigned long offset;
+ size_t size;
+ void *ptr;
+
+ if (pushbuf->ptr + words >= pushbuf->end) {
+ words = pushbuf->end - pushbuf->start + words;
+ size = ALIGN(words * 4, job->page_size);
+ offset = pushbuf->ptr - pushbuf->start;
+
+ ptr = realloc(pushbuf->start, size);
+ if (!ptr)
+ return -ENOMEM;
+
+ pushbuf->start = ptr;
+ pushbuf->end = pushbuf->start + size / 4;
+ pushbuf->ptr = pushbuf->start + offset;
+ }
+
+ if (ptrp)
+ *ptrp = pushbuf->ptr;
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_pushbuf_end(struct drm_tegra_pushbuf *pushbuf, uint32_t *ptr)
+{
+ struct drm_tegra_submit_cmd *command;
+
+ command = drm_tegra_job_add_command(pushbuf->job,
+ DRM_TEGRA_SUBMIT_CMD_GATHER_UPTR,
+ 0);
+ if (!command)
+ return -ENOMEM;
+
+ command->gather_uptr.words = ptr - pushbuf->start;
+ pushbuf->ptr = ptr;
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_pushbuf_wait(struct drm_tegra_pushbuf *pushbuf,
+ struct drm_tegra_syncpoint *syncpt,
+ uint32_t value)
+{
+ struct drm_tegra_submit_cmd *command;
+
+ command = drm_tegra_job_add_command(pushbuf->job,
+ DRM_TEGRA_SUBMIT_CMD_WAIT_SYNCPT,
+ 0);
+ if (!command)
+ return -ENOMEM;
+
+ command->wait_syncpt.id = syncpt->id;
+ command->wait_syncpt.value = value;
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_pushbuf_relocate(struct drm_tegra_pushbuf *pushbuf, uint32_t **ptrp,
+ struct drm_tegra_mapping *target,
+ unsigned long offset, unsigned int shift,
+ uint32_t flags)
+{
+ struct drm_tegra_submit_buf *buffers, *buffer;
+ struct drm_tegra_job *job = pushbuf->job;
+ size_t size;
+
+ size = (job->num_buffers + 1) * sizeof(*buffer);
+
+ buffers = realloc(job->buffers, size);
+ if (!buffers)
+ return -ENOMEM;
+
+ buffer = &buffers[job->num_buffers];
+
+ memset(buffer, 0, sizeof(*buffer));
+ buffer->mapping = target->id;
+ buffer->flags = flags;
+ buffer->reloc.target_offset = offset;
+ buffer->reloc.gather_offset_words = drm_tegra_pushbuf_get_offset(pushbuf,
+ *ptrp);
+ buffer->reloc.shift = shift;
+
+ *(*ptrp)++ = 0xdeadbeef;
+
+ job->buffers = buffers;
+ job->num_buffers++;
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_pushbuf_sync(struct drm_tegra_pushbuf *pushbuf,
+ struct drm_tegra_syncpoint *syncpt,
+ unsigned int count)
+{
+ struct drm_tegra_job *job = pushbuf->job;
+
+ job->syncpt.increments += count;
+ job->syncpt.id = syncpt->id;
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_pushbuf_sync_cond(struct drm_tegra_pushbuf *pushbuf, uint32_t **ptrp,
+ struct drm_tegra_syncpoint *syncpt,
+ enum drm_tegra_sync_cond cond)
+{
+ struct drm_tegra_channel *channel = pushbuf->job->channel;
+
+ if (cond >= DRM_TEGRA_SYNC_COND_MAX)
+ return -EINVAL;
+
+ *(*ptrp)++ = HOST1X_OPCODE_NONINCR(0x0, 0x1);
+ *(*ptrp)++ = cond << channel->cond_shift | syncpt->id;
+
+ return drm_tegra_pushbuf_sync(pushbuf, syncpt, 1);
+}
diff --git a/lib/libdrm/tegra/syncpt.c b/lib/libdrm/tegra/syncpt.c
new file mode 100644
index 000000000..16014186f
--- /dev/null
+++ b/lib/libdrm/tegra/syncpt.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright © 2021 NVIDIA Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <errno.h>
+#include <string.h>
+
+#include <sys/ioctl.h>
+
+#include "private.h"
+
+drm_public int
+drm_tegra_syncpoint_new(struct drm_tegra *drm,
+ struct drm_tegra_syncpoint **syncptp)
+{
+ struct drm_tegra_syncpoint_allocate args;
+ struct drm_tegra_syncpoint *syncpt;
+ int err;
+
+ syncpt = calloc(1, sizeof(*syncpt));
+ if (!syncpt)
+ return -ENOMEM;
+
+ memset(&args, 0, sizeof(args));
+
+ err = ioctl(drm->fd, DRM_IOCTL_TEGRA_SYNCPOINT_ALLOCATE, &args);
+ if (err < 0) {
+ free(syncpt);
+ return -errno;
+ }
+
+ syncpt->drm = drm;
+ syncpt->id = args.id;
+
+ *syncptp = syncpt;
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_syncpoint_free(struct drm_tegra_syncpoint *syncpt)
+{
+ struct drm_tegra_syncpoint_free args;
+ struct drm_tegra *drm = syncpt->drm;
+ int err;
+
+ if (!syncpt)
+ return -EINVAL;
+
+ memset(&args, 0, sizeof(args));
+ args.id = syncpt->id;
+
+ err = ioctl(drm->fd, DRM_IOCTL_TEGRA_SYNCPOINT_FREE, &args);
+ if (err < 0)
+ return -errno;
+
+ free(syncpt);
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_fence_wait(struct drm_tegra_fence *fence, unsigned long timeout)
+{
+ struct drm_tegra_syncpoint_wait args;
+ struct drm_tegra *drm = fence->drm;
+ int err;
+
+ memset(&args, 0, sizeof(args));
+ args.timeout_ns = 0;
+ args.id = fence->syncpt;
+ args.threshold = fence->value;
+
+ err = ioctl(drm->fd, DRM_IOCTL_TEGRA_SYNCPOINT_WAIT, &args);
+ if (err < 0)
+ return -errno;
+
+ return 0;
+}
diff --git a/lib/libdrm/tegra/tegra-symbols.txt b/lib/libdrm/tegra/tegra-symbols.txt
index 5e3e955f2..1a75c3d27 100644
--- a/lib/libdrm/tegra/tegra-symbols.txt
+++ b/lib/libdrm/tegra/tegra-symbols.txt
@@ -1,13 +1,32 @@
-drm_tegra_bo_get_flags
+drm_tegra_bo_export
drm_tegra_bo_get_handle
-drm_tegra_bo_get_tiling
+drm_tegra_bo_get_name
+drm_tegra_bo_import
drm_tegra_bo_map
drm_tegra_bo_new
+drm_tegra_bo_open
drm_tegra_bo_ref
-drm_tegra_bo_set_flags
-drm_tegra_bo_set_tiling
drm_tegra_bo_unmap
drm_tegra_bo_unref
drm_tegra_bo_wrap
+drm_tegra_channel_close
+drm_tegra_channel_get_version
+drm_tegra_channel_map
+drm_tegra_channel_open
+drm_tegra_channel_unmap
drm_tegra_close
+drm_tegra_fence_wait
+drm_tegra_job_free
+drm_tegra_job_get_pushbuf
+drm_tegra_job_new
+drm_tegra_job_submit
+drm_tegra_job_wait
drm_tegra_new
+drm_tegra_pushbuf_begin
+drm_tegra_pushbuf_end
+drm_tegra_pushbuf_relocate
+drm_tegra_pushbuf_sync
+drm_tegra_pushbuf_sync_cond
+drm_tegra_pushbuf_wait
+drm_tegra_syncpoint_free
+drm_tegra_syncpoint_new
diff --git a/lib/libdrm/tegra/tegra.c b/lib/libdrm/tegra/tegra.c
index 420b171c5..6a51c4311 100644
--- a/lib/libdrm/tegra/tegra.c
+++ b/lib/libdrm/tegra/tegra.c
@@ -37,288 +37,318 @@
static void drm_tegra_bo_free(struct drm_tegra_bo *bo)
{
- struct drm_tegra *drm = bo->drm;
+ struct drm_tegra *drm = bo->drm;
- if (bo->map)
- munmap(bo->map, bo->size);
+ if (bo->map)
+ munmap(bo->map, bo->size);
- drmCloseBufferHandle(drm->fd, bo->handle);
+ drmCloseBufferHandle(drm->fd, bo->handle);
- free(bo);
+ free(bo);
}
static int drm_tegra_wrap(struct drm_tegra **drmp, int fd, bool close)
{
- struct drm_tegra *drm;
+ struct drm_tegra *drm;
- if (fd < 0 || !drmp)
- return -EINVAL;
+ if (fd < 0 || !drmp)
+ return -EINVAL;
- drm = calloc(1, sizeof(*drm));
- if (!drm)
- return -ENOMEM;
+ drm = calloc(1, sizeof(*drm));
+ if (!drm)
+ return -ENOMEM;
- drm->close = close;
- drm->fd = fd;
+ drm->close = close;
+ drm->fd = fd;
- *drmp = drm;
+ *drmp = drm;
- return 0;
+ return 0;
}
-drm_public int drm_tegra_new(struct drm_tegra **drmp, int fd)
+drm_public int drm_tegra_new(int fd, struct drm_tegra **drmp)
{
- bool supported = false;
- drmVersionPtr version;
+ bool supported = false;
+ drmVersionPtr version;
- version = drmGetVersion(fd);
- if (!version)
- return -ENOMEM;
+ version = drmGetVersion(fd);
+ if (!version)
+ return -ENOMEM;
- if (!strncmp(version->name, "tegra", version->name_len))
- supported = true;
+ if (!strncmp(version->name, "tegra", version->name_len))
+ supported = true;
- drmFreeVersion(version);
+ drmFreeVersion(version);
- if (!supported)
- return -ENOTSUP;
+ if (!supported)
+ return -ENOTSUP;
- return drm_tegra_wrap(drmp, fd, false);
+ return drm_tegra_wrap(drmp, fd, false);
}
drm_public void drm_tegra_close(struct drm_tegra *drm)
{
- if (!drm)
- return;
+ if (!drm)
+ return;
- if (drm->close)
- close(drm->fd);
+ if (drm->close)
+ close(drm->fd);
- free(drm);
+ free(drm);
}
-drm_public int drm_tegra_bo_new(struct drm_tegra_bo **bop, struct drm_tegra *drm,
- uint32_t flags, uint32_t size)
+static struct drm_tegra_bo *drm_tegra_bo_alloc(struct drm_tegra *drm,
+ uint32_t handle,
+ uint32_t flags,
+ uint32_t size)
{
- struct drm_tegra_gem_create args;
- struct drm_tegra_bo *bo;
- int err;
+ struct drm_tegra_bo *bo;
- if (!drm || size == 0 || !bop)
- return -EINVAL;
+ bo = calloc(1, sizeof(*bo));
+ if (!bo)
+ return NULL;
- bo = calloc(1, sizeof(*bo));
- if (!bo)
- return -ENOMEM;
+ atomic_set(&bo->ref, 1);
+ bo->handle = handle;
+ bo->flags = flags;
+ bo->size = size;
+ bo->drm = drm;
- atomic_set(&bo->ref, 1);
- bo->flags = flags;
- bo->size = size;
- bo->drm = drm;
+ return bo;
+}
+
+drm_public int
+drm_tegra_bo_new(struct drm_tegra *drm, uint32_t flags, uint32_t size,
+ struct drm_tegra_bo **bop)
+{
+ struct drm_tegra_gem_create args;
+ struct drm_tegra_bo *bo;
+ int err;
+
+ if (!drm || size == 0 || !bop)
+ return -EINVAL;
+
+ bo = drm_tegra_bo_alloc(drm, 0, flags, size);
+ if (!bo)
+ return -ENOMEM;
- memset(&args, 0, sizeof(args));
- args.flags = flags;
- args.size = size;
+ memset(&args, 0, sizeof(args));
+ args.flags = flags;
+ args.size = size;
- err = drmCommandWriteRead(drm->fd, DRM_TEGRA_GEM_CREATE, &args,
- sizeof(args));
- if (err < 0) {
- err = -errno;
- free(bo);
- return err;
- }
+ err = drmCommandWriteRead(drm->fd, DRM_TEGRA_GEM_CREATE, &args,
+ sizeof(args));
+ if (err < 0) {
+ err = -errno;
+ free(bo);
+ return err;
+ }
- bo->handle = args.handle;
+ bo->handle = args.handle;
- *bop = bo;
+ *bop = bo;
- return 0;
+ return 0;
}
-drm_public int drm_tegra_bo_wrap(struct drm_tegra_bo **bop, struct drm_tegra *drm,
- uint32_t handle, uint32_t flags, uint32_t size)
+drm_public int
+drm_tegra_bo_wrap(struct drm_tegra *drm, uint32_t handle, uint32_t flags,
+ uint32_t size, struct drm_tegra_bo **bop)
{
- struct drm_tegra_bo *bo;
+ struct drm_tegra_bo *bo;
- if (!drm || !bop)
- return -EINVAL;
+ if (!drm || !bop)
+ return -EINVAL;
- bo = calloc(1, sizeof(*bo));
- if (!bo)
- return -ENOMEM;
+ bo = drm_tegra_bo_alloc(drm, handle, flags, size);
+ if (!bo)
+ return -ENOMEM;
- atomic_set(&bo->ref, 1);
- bo->handle = handle;
- bo->flags = flags;
- bo->size = size;
- bo->drm = drm;
+ *bop = bo;
- *bop = bo;
-
- return 0;
+ return 0;
}
drm_public struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo)
{
- if (bo)
- atomic_inc(&bo->ref);
+ if (bo)
+ atomic_inc(&bo->ref);
- return bo;
+ return bo;
}
drm_public void drm_tegra_bo_unref(struct drm_tegra_bo *bo)
{
- if (bo && atomic_dec_and_test(&bo->ref))
- drm_tegra_bo_free(bo);
+ if (bo && atomic_dec_and_test(&bo->ref))
+ drm_tegra_bo_free(bo);
}
-drm_public int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle)
+drm_public int
+drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle)
{
- if (!bo || !handle)
- return -EINVAL;
+ if (!bo || !handle)
+ return -EINVAL;
- *handle = bo->handle;
+ *handle = bo->handle;
- return 0;
+ return 0;
}
drm_public int drm_tegra_bo_map(struct drm_tegra_bo *bo, void **ptr)
{
- struct drm_tegra *drm = bo->drm;
+ struct drm_tegra *drm = bo->drm;
- if (!bo->map) {
- struct drm_tegra_gem_mmap args;
- int err;
+ if (!bo->map) {
+ struct drm_tegra_gem_mmap args;
+ int err;
- memset(&args, 0, sizeof(args));
- args.handle = bo->handle;
+ memset(&args, 0, sizeof(args));
+ args.handle = bo->handle;
- err = drmCommandWriteRead(drm->fd, DRM_TEGRA_GEM_MMAP, &args,
- sizeof(args));
- if (err < 0)
- return -errno;
+ err = drmCommandWriteRead(drm->fd, DRM_TEGRA_GEM_MMAP, &args,
+ sizeof(args));
+ if (err < 0)
+ return -errno;
- bo->offset = args.offset;
+ bo->offset = args.offset;
- bo->map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
- drm->fd, bo->offset);
- if (bo->map == MAP_FAILED) {
- bo->map = NULL;
- return -errno;
- }
- }
+ bo->map = drm_mmap(NULL, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ drm->fd, bo->offset);
+ if (bo->map == MAP_FAILED) {
+ bo->map = NULL;
+ return -errno;
+ }
+ }
- if (ptr)
- *ptr = bo->map;
+ if (ptr)
+ *ptr = bo->map;
- return 0;
+ return 0;
}
drm_public int drm_tegra_bo_unmap(struct drm_tegra_bo *bo)
{
- if (!bo)
- return -EINVAL;
+ if (!bo)
+ return -EINVAL;
- if (!bo->map)
- return 0;
+ if (!bo->map)
+ return 0;
- if (munmap(bo->map, bo->size))
- return -errno;
+ if (munmap(bo->map, bo->size))
+ return -errno;
- bo->map = NULL;
+ bo->map = NULL;
- return 0;
+ return 0;
}
-drm_public int drm_tegra_bo_get_flags(struct drm_tegra_bo *bo, uint32_t *flags)
+drm_public int drm_tegra_bo_get_name(struct drm_tegra_bo *bo, uint32_t *name)
{
- struct drm_tegra_gem_get_flags args;
- struct drm_tegra *drm = bo->drm;
- int err;
-
- if (!bo)
- return -EINVAL;
+ struct drm_tegra *drm = bo->drm;
+ struct drm_gem_flink args;
+ int err;
- memset(&args, 0, sizeof(args));
- args.handle = bo->handle;
+ memset(&args, 0, sizeof(args));
+ args.handle = bo->handle;
- err = drmCommandWriteRead(drm->fd, DRM_TEGRA_GEM_GET_FLAGS, &args,
- sizeof(args));
- if (err < 0)
- return -errno;
+ err = drmIoctl(drm->fd, DRM_IOCTL_GEM_FLINK, &args);
+ if (err < 0)
+ return err;
- if (flags)
- *flags = args.flags;
+ if (name)
+ *name = args.name;
- return 0;
+ return 0;
}
-drm_public int drm_tegra_bo_set_flags(struct drm_tegra_bo *bo, uint32_t flags)
+drm_public int
+drm_tegra_bo_open(struct drm_tegra *drm, uint32_t name, uint32_t flags,
+ struct drm_tegra_bo **bop)
{
- struct drm_tegra_gem_get_flags args;
- struct drm_tegra *drm = bo->drm;
- int err;
+ struct drm_gem_open args;
+ struct drm_tegra_bo *bo;
+ int err;
+
+ bo = drm_tegra_bo_alloc(drm, 0, flags, 0);
+ if (!bo)
+ return -ENOMEM;
+
+ memset(&args, 0, sizeof(args));
+ args.name = name;
- if (!bo)
- return -EINVAL;
+ err = drmIoctl(drm->fd, DRM_IOCTL_GEM_OPEN, &args);
+ if (err < 0)
+ goto free;
- memset(&args, 0, sizeof(args));
- args.handle = bo->handle;
- args.flags = flags;
+ bo->handle = args.handle;
+ bo->size = args.size;
- err = drmCommandWriteRead(drm->fd, DRM_TEGRA_GEM_SET_FLAGS, &args,
- sizeof(args));
- if (err < 0)
- return -errno;
+ *bop = bo;
- return 0;
+ return 0;
+
+free:
+ free(bo);
+ return err;
}
-drm_public int drm_tegra_bo_get_tiling(struct drm_tegra_bo *bo,
- struct drm_tegra_bo_tiling *tiling)
+drm_public int drm_tegra_bo_export(struct drm_tegra_bo *bo, uint32_t flags)
{
- struct drm_tegra_gem_get_tiling args;
- struct drm_tegra *drm = bo->drm;
- int err;
+ int fd, err;
+
+ flags |= DRM_CLOEXEC;
+
+ err = drmPrimeHandleToFD(bo->drm->fd, bo->handle, flags, &fd);
+ if (err < 0)
+ return err;
+
+ return fd;
+}
- if (!bo)
- return -EINVAL;
+static ssize_t fd_get_size(int fd)
+{
+ ssize_t size, offset;
+ int err;
- memset(&args, 0, sizeof(args));
- args.handle = bo->handle;
+ offset = lseek(fd, 0, SEEK_CUR);
+ if (offset < 0)
+ return -errno;
- err = drmCommandWriteRead(drm->fd, DRM_TEGRA_GEM_GET_TILING, &args,
- sizeof(args));
- if (err < 0)
- return -errno;
+ size = lseek(fd, 0, SEEK_END);
+ if (size < 0)
+ return -errno;
- if (tiling) {
- tiling->mode = args.mode;
- tiling->value = args.value;
- }
+ err = lseek(fd, offset, SEEK_SET);
+ if (err < 0)
+ return -errno;
- return 0;
+ return size;
}
-drm_public int drm_tegra_bo_set_tiling(struct drm_tegra_bo *bo,
- const struct drm_tegra_bo_tiling *tiling)
+drm_public int
+drm_tegra_bo_import(struct drm_tegra *drm, int fd, struct drm_tegra_bo **bop)
{
- struct drm_tegra_gem_set_tiling args;
- struct drm_tegra *drm = bo->drm;
- int err;
+ struct drm_tegra_bo *bo;
+ ssize_t size;
+ int err;
+
+ size = fd_get_size(fd);
+ if (size < 0)
+ return size;
+
+ bo = drm_tegra_bo_alloc(drm, 0, 0, size);
+ if (!bo)
+ return -ENOMEM;
- if (!bo)
- return -EINVAL;
+ err = drmPrimeFDToHandle(drm->fd, fd, &bo->handle);
+ if (err < 0)
+ goto free;
- memset(&args, 0, sizeof(args));
- args.handle = bo->handle;
- args.mode = tiling->mode;
- args.value = tiling->value;
+ *bop = bo;
- err = drmCommandWriteRead(drm->fd, DRM_TEGRA_GEM_SET_TILING, &args,
- sizeof(args));
- if (err < 0)
- return -errno;
+ return 0;
- return 0;
+free:
+ free(bo);
+ return err;
}
diff --git a/lib/libdrm/tegra/tegra.h b/lib/libdrm/tegra/tegra.h
index 31b0995ad..8f3c0554f 100644
--- a/lib/libdrm/tegra/tegra.h
+++ b/lib/libdrm/tegra/tegra.h
@@ -28,33 +28,100 @@
#include <stdint.h>
#include <stdlib.h>
+#include <tegra_drm.h>
+
+enum drm_tegra_class {
+ DRM_TEGRA_HOST1X,
+ DRM_TEGRA_GR2D,
+ DRM_TEGRA_GR3D,
+ DRM_TEGRA_VIC,
+};
+
struct drm_tegra_bo;
struct drm_tegra;
-int drm_tegra_new(struct drm_tegra **drmp, int fd);
+int drm_tegra_new(int fd, struct drm_tegra **drmp);
void drm_tegra_close(struct drm_tegra *drm);
-int drm_tegra_bo_new(struct drm_tegra_bo **bop, struct drm_tegra *drm,
- uint32_t flags, uint32_t size);
-int drm_tegra_bo_wrap(struct drm_tegra_bo **bop, struct drm_tegra *drm,
- uint32_t handle, uint32_t flags, uint32_t size);
+int drm_tegra_bo_new(struct drm_tegra *drm, uint32_t flags, uint32_t size,
+ struct drm_tegra_bo **bop);
+int drm_tegra_bo_wrap(struct drm_tegra *drm, uint32_t handle, uint32_t flags,
+ uint32_t size, struct drm_tegra_bo **bop);
struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo);
void drm_tegra_bo_unref(struct drm_tegra_bo *bo);
int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle);
int drm_tegra_bo_map(struct drm_tegra_bo *bo, void **ptr);
int drm_tegra_bo_unmap(struct drm_tegra_bo *bo);
-int drm_tegra_bo_get_flags(struct drm_tegra_bo *bo, uint32_t *flags);
-int drm_tegra_bo_set_flags(struct drm_tegra_bo *bo, uint32_t flags);
+int drm_tegra_bo_get_name(struct drm_tegra_bo *bo, uint32_t *name);
+int drm_tegra_bo_open(struct drm_tegra *drm, uint32_t name, uint32_t flags,
+ struct drm_tegra_bo **bop);
+
+int drm_tegra_bo_export(struct drm_tegra_bo *bo, uint32_t flags);
+int drm_tegra_bo_import(struct drm_tegra *drm, int fd,
+ struct drm_tegra_bo **bop);
+
+struct drm_tegra_channel;
+struct drm_tegra_mapping;
+struct drm_tegra_pushbuf;
+struct drm_tegra_job;
+struct drm_tegra_syncpoint;
-struct drm_tegra_bo_tiling {
- uint32_t mode;
- uint32_t value;
+enum drm_tegra_sync_cond {
+ DRM_TEGRA_SYNC_COND_IMMEDIATE,
+ DRM_TEGRA_SYNC_COND_OP_DONE,
+ DRM_TEGRA_SYNC_COND_RD_DONE,
+ DRM_TEGRA_SYNC_COND_WR_SAFE,
+ DRM_TEGRA_SYNC_COND_MAX,
+ };
+
+struct drm_tegra_fence {
+ struct drm_tegra *drm;
+ uint32_t syncpt;
+ uint32_t value;
};
-int drm_tegra_bo_get_tiling(struct drm_tegra_bo *bo,
- struct drm_tegra_bo_tiling *tiling);
-int drm_tegra_bo_set_tiling(struct drm_tegra_bo *bo,
- const struct drm_tegra_bo_tiling *tiling);
+int drm_tegra_channel_open(struct drm_tegra *drm,
+ enum drm_tegra_class client,
+ struct drm_tegra_channel **channelp);
+int drm_tegra_channel_close(struct drm_tegra_channel *channel);
+unsigned int drm_tegra_channel_get_version(struct drm_tegra_channel *channel);
+int drm_tegra_channel_map(struct drm_tegra_channel *channel,
+ struct drm_tegra_bo *bo, uint32_t flags,
+ struct drm_tegra_mapping **mapp);
+int drm_tegra_channel_unmap(struct drm_tegra_mapping *map);
+
+int drm_tegra_job_new(struct drm_tegra_channel *channel,
+ struct drm_tegra_job **jobp);
+int drm_tegra_job_free(struct drm_tegra_job *job);
+int drm_tegra_job_get_pushbuf(struct drm_tegra_job *job,
+ struct drm_tegra_pushbuf **pushbufp);
+int drm_tegra_job_submit(struct drm_tegra_job *job,
+ struct drm_tegra_fence *fence);
+int drm_tegra_job_wait(struct drm_tegra_job *job, unsigned long timeout);
+
+int drm_tegra_pushbuf_begin(struct drm_tegra_pushbuf *pushbuf,
+ unsigned int words, uint32_t **ptrp);
+int drm_tegra_pushbuf_end(struct drm_tegra_pushbuf *pushbuf, uint32_t *ptr);
+int drm_tegra_pushbuf_wait(struct drm_tegra_pushbuf *pushbuf,
+ struct drm_tegra_syncpoint *syncpt,
+ uint32_t value);
+int drm_tegra_pushbuf_relocate(struct drm_tegra_pushbuf *pushbuf,
+ uint32_t **ptrp,
+ struct drm_tegra_mapping *target,
+ unsigned long offset, unsigned int shift,
+ uint32_t flags);
+int drm_tegra_pushbuf_sync(struct drm_tegra_pushbuf *pushbuf,
+ struct drm_tegra_syncpoint *syncpt,
+ unsigned int count);
+int drm_tegra_pushbuf_sync_cond(struct drm_tegra_pushbuf *pushbuf,
+ uint32_t **ptrp,
+ struct drm_tegra_syncpoint *syncpt,
+ enum drm_tegra_sync_cond cond);
+
+int drm_tegra_syncpoint_new(struct drm_tegra *drm,
+ struct drm_tegra_syncpoint **syncptp);
+int drm_tegra_syncpoint_free(struct drm_tegra_syncpoint *syncpt);
+int drm_tegra_fence_wait(struct drm_tegra_fence *fence, unsigned long timeout);
#endif /* __DRM_TEGRA_H__ */