nouveau/ws: add context support
authorKarol Herbst <kherbst@redhat.com>
Wed, 1 Jun 2022 20:16:56 +0000 (22:16 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:53 +0000 (21:31 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/winsys/meson.build
src/nouveau/winsys/nouveau_context.c [new file with mode: 0644]
src/nouveau/winsys/nouveau_context.h [new file with mode: 0644]

index 7ce1762..08d73dd 100644 (file)
@@ -3,6 +3,8 @@ libnouveau_ws = static_library(
   [
     'nouveau_bo.h',
     'nouveau_bo.c',
+    'nouveau_context.h',
+    'nouveau_context.c',
     'nouveau_device.h',
     'nouveau_device.c',
     'nouveau_private.h',
diff --git a/src/nouveau/winsys/nouveau_context.c b/src/nouveau/winsys/nouveau_context.c
new file mode 100644 (file)
index 0000000..54c7768
--- /dev/null
@@ -0,0 +1,34 @@
+#include "nouveau_context.h"
+
+#include <errno.h>
+#include <nouveau/nouveau.h>
+
+#include "nouveau_device.h"
+
+int
+nouveau_ws_context_create(struct nouveau_ws_device *dev, struct nouveau_ws_context **out)
+{
+   struct nouveau_ws_device_priv *pdev = nouveau_ws_device(dev);
+   struct nvc0_fifo nvc0_data = { };
+   uint32_t size = sizeof(nvc0_data);
+
+   *out = CALLOC_STRUCT(nouveau_ws_context);
+   if (!*out)
+      return -ENOMEM;
+
+   int ret = nouveau_object_new(&pdev->dev->object, 0, NOUVEAU_FIFO_CHANNEL_CLASS,
+                                &nvc0_data, size, &(*out)->channel);
+   if (ret) {
+      FREE(*out);
+      return ret;
+   }
+
+   return 0;
+}
+
+void
+nouveau_ws_context_destroy(struct nouveau_ws_context *context)
+{
+   nouveau_object_del(&context->channel);
+   FREE(context);
+}
diff --git a/src/nouveau/winsys/nouveau_context.h b/src/nouveau/winsys/nouveau_context.h
new file mode 100644 (file)
index 0000000..44db4b4
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef NOUVEAU_CONTEXT
+#define NOUVEAU_CONTEXT 1
+
+#include "nouveau_private.h"
+
+struct nouveau_ws_device;
+
+struct nouveau_ws_context {
+   struct nouveau_object *channel;
+};
+
+int nouveau_ws_context_create(struct nouveau_ws_device *, struct nouveau_ws_context **out);
+void nouveau_ws_context_destroy(struct nouveau_ws_context *);
+
+#endif