[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 01/11] ui: Get the fd associated with udmabuf driver
From: |
Vivek Kasireddy |
Subject: |
[PATCH 01/11] ui: Get the fd associated with udmabuf driver |
Date: |
Tue, 30 Mar 2021 20:09:51 -0700 |
Try to open the udmabuf dev node for the first time or return the
fd if the device was previously opened.
Based-on-patch-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
include/ui/console.h | 3 +++
ui/meson.build | 1 +
ui/udmabuf.c | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+)
create mode 100644 ui/udmabuf.c
diff --git a/include/ui/console.h b/include/ui/console.h
index ca3c7af6a6..b30b63976a 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -471,4 +471,7 @@ bool vnc_display_reload_certs(const char *id, Error
**errp);
/* input.c */
int index_from_key(const char *key, size_t key_length);
+/* udmabuf.c */
+int udmabuf_fd(void);
+
#endif
diff --git a/ui/meson.build b/ui/meson.build
index e8d3ff41b9..7a709ff548 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -11,6 +11,7 @@ softmmu_ss.add(files(
'kbd-state.c',
'keymaps.c',
'qemu-pixman.c',
+ 'udmabuf.c',
))
softmmu_ss.add([spice_headers, files('spice-module.c')])
diff --git a/ui/udmabuf.c b/ui/udmabuf.c
new file mode 100644
index 0000000000..e6234fd86f
--- /dev/null
+++ b/ui/udmabuf.c
@@ -0,0 +1,40 @@
+/*
+ * udmabuf helper functions.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "ui/console.h"
+
+#ifdef CONFIG_LINUX
+
+#include <sys/fcntl.h>
+#include <sys/ioctl.h>
+
+int udmabuf_fd(void)
+{
+ static bool first = true;
+ static int udmabuf;
+
+ if (!first) {
+ return udmabuf;
+ }
+ first = false;
+
+ udmabuf = open("/dev/udmabuf", O_RDWR);
+ if (udmabuf < 0) {
+ warn_report("open /dev/udmabuf: %s", strerror(errno));
+ }
+ return udmabuf;
+}
+
+#else
+
+int udmabuf_fd(void)
+{
+ return -1;
+}
+
+#endif
--
2.26.2
- [PATCH 00/11] Add support for Blob resources feature, Vivek Kasireddy, 2021/03/30
- [PATCH 01/11] ui: Get the fd associated with udmabuf driver,
Vivek Kasireddy <=
- [PATCH 02/11] ui/pixman: Add qemu_pixman_to_drm_format(), Vivek Kasireddy, 2021/03/30
- [PATCH 03/11] virtio-gpu: Add udmabuf helpers, Vivek Kasireddy, 2021/03/30
- [PATCH 05/11] virtio-gpu: Refactor virtio_gpu_set_scanout, Vivek Kasireddy, 2021/03/30
- [PATCH 06/11] virtio-gpu: Refactor virtio_gpu_create_mapping_iov, Vivek Kasireddy, 2021/03/30
- [PATCH 04/11] virtio-gpu: Add virtio_gpu_find_check_resource, Vivek Kasireddy, 2021/03/30
- [PATCH 07/11] virtio-gpu: Add initial definitions for blob resources, Vivek Kasireddy, 2021/03/30
- [PATCH 08/11] virtio-gpu: Add virtio_gpu_resource_create_blob, Vivek Kasireddy, 2021/03/30
- [PATCH 09/11] virtio-gpu: Add helpers to create and destroy dmabuf objects, Vivek Kasireddy, 2021/03/30
- [PATCH 11/11] virtio-gpu: Update cursor data using blob, Vivek Kasireddy, 2021/03/30
- [PATCH 10/11] virtio-gpu: Add virtio_gpu_set_scanout_blob, Vivek Kasireddy, 2021/03/30