blob: a2b33922a45827e3e76bbbb7b3f9a69410022afd [file] [edit]
From c7e53a4262eff3569eaf83a98f94bcd1b1c12345 Mon Sep 17 00:00:00 2001
From: David Reveman <reveman@chromium.org>
Date: Sat, 4 Nov 2017 21:59:34 +0000
Subject: [PATCH] mesa virtwl 13.0.6
---
src/egl/drivers/dri2/platform_wayland.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 27baec348f..fa38d71ebc 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -45,6 +45,12 @@
#include <wayland-client.h>
#include "wayland-drm-client-protocol.h"
+#define HAVE_VIRTWL 1
+#ifdef HAVE_VIRTWL
+#include <sys/ioctl.h>
+#include <linux/virtwl.h>
+#endif
+
enum wl_drm_format_flags {
HAS_ARGB8888 = 1,
HAS_XRGB8888 = 2,
@@ -1306,7 +1312,7 @@ dri2_wl_swrast_get_stride_for_format(int format, int w)
* Taken from weston shared/os-compatibility.c
*/
-#ifndef HAVE_MKOSTEMP
+#if !defined(HAVE_MKOSTEMP) || defined(HAVE_VIRTWL)
static int
set_cloexec_or_close(int fd)
@@ -1388,6 +1394,24 @@ os_create_anonymous_file(off_t size)
int fd;
int ret;
+#ifdef HAVE_VIRTWL
+ struct virtwl_ioctl_new virtwl_ioctl_new = {
+ .type = VIRTWL_IOCTL_NEW_ALLOC,
+ .fd = -1,
+ .flags = 0,
+ .size = size,
+ };
+ int wl_fd = open("/dev/wl0", O_RDWR);
+ if (wl_fd >= 0) {
+ ret = ioctl(wl_fd, VIRTWL_IOCTL_NEW, &virtwl_ioctl_new);
+ close(wl_fd);
+ if (ret)
+ return -1;
+
+ return set_cloexec_or_close(virtwl_ioctl_new.fd);
+ }
+#endif
+
path = getenv("XDG_RUNTIME_DIR");
if (!path) {
errno = ENOENT;
--
2.11.0