qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Kasireddy <vivek.kasireddy@intel.com>
To: qemu-devel@nongnu.org
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH v6 01/13] ui: Get the fd associated with udmabuf driver
Date: Mon, 24 May 2021 15:30:51 -0700	[thread overview]
Message-ID: <20210524223103.922910-2-vivek.kasireddy@intel.com> (raw)
In-Reply-To: <20210524223103.922910-1-vivek.kasireddy@intel.com>

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>
Cc: 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 b5aed14886..a3a187d633 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -12,6 +12,7 @@ softmmu_ss.add(files(
   'kbd-state.c',
   'keymaps.c',
   'qemu-pixman.c',
+  'udmabuf.c',
 ))
 softmmu_ss.add([spice_headers, files('spice-module.c')])
 softmmu_ss.add(when: spice_protocol, if_true: files('vdagent.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.30.2



  reply	other threads:[~2021-05-24 22:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 22:30 [PATCH v6 00/13] virtio-gpu: Add support for Blob resources feature Vivek Kasireddy
2021-05-24 22:30 ` Vivek Kasireddy [this message]
2021-05-24 22:30 ` [PATCH v6 02/13] headers: Add udmabuf.h Vivek Kasireddy
2021-05-24 22:30 ` [PATCH v6 03/13] virtio-gpu: Add udmabuf helpers Vivek Kasireddy
2021-05-26  6:16   ` Gerd Hoffmann
2021-05-26 19:32     ` Kasireddy, Vivek
2021-05-24 22:30 ` [PATCH v6 04/13] virtio-gpu: Add virtio_gpu_find_check_resource Vivek Kasireddy
2021-05-24 22:30 ` [PATCH v6 05/13] virtio-gpu: Refactor virtio_gpu_set_scanout Vivek Kasireddy
2021-05-24 22:30 ` [PATCH v6 06/13] virtio-gpu: Refactor virtio_gpu_create_mapping_iov Vivek Kasireddy
2021-05-24 22:30 ` [PATCH v6 07/13] virtio-gpu: Add initial definitions for blob resources Vivek Kasireddy
2021-05-24 22:30 ` [PATCH v6 08/13] virtio-gpu: Add virtio_gpu_resource_create_blob Vivek Kasireddy
2021-05-24 22:30 ` [PATCH v6 09/13] ui/pixman: Add qemu_pixman_to_drm_format() Vivek Kasireddy
2021-05-24 22:31 ` [PATCH v6 10/13] virtio-gpu: Add helpers to create and destroy dmabuf objects Vivek Kasireddy
2021-05-24 22:31 ` [PATCH v6 11/13] virtio-gpu: Factor out update scanout Vivek Kasireddy
2021-05-24 22:31 ` [PATCH v6 12/13] virtio-gpu: Add virtio_gpu_set_scanout_blob Vivek Kasireddy
2021-05-24 22:31 ` [PATCH v6 13/13] virtio-gpu: Update cursor data using blob Vivek Kasireddy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210524223103.922910-2-vivek.kasireddy@intel.com \
    --to=vivek.kasireddy@intel.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).