[PATCH weston v2 3/4] libweston: Add check and fallback for linux/sync_file.h

Alexandros Frantzis alexandros.frantzis at collabora.com
Tue Sep 19 11:59:10 UTC 2017


The sync file functionality is required by the upcoming GPU render
timeline work, but it's only available in relatively new linux kernel
versions (4.7 and above).

This commit provides an in-tree copy of the required sync file
definitions.  On systems that don't have the sync file header (due to
having an older kernel), we will be able to fall back to our own copy
when building.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis at collabora.com>
---

Changes in v2:
  - New patch.

 Makefile.am                  |  1 +
 configure.ac                 |  1 +
 libweston/weston-sync-file.h | 73 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+)
 create mode 100644 libweston/weston-sync-file.h

diff --git a/Makefile.am b/Makefile.am
index 58a5c596..9d99c694 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -334,6 +334,7 @@ gl_renderer_la_SOURCES =			\
 	libweston/gl-renderer.c			\
 	libweston/vertex-clipping.c		\
 	libweston/vertex-clipping.h		\
+	libweston/weston-sync-file.h		\
 	shared/helpers.h
 endif
 
diff --git a/configure.ac b/configure.ac
index 0ea7b703..c287fac6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -142,6 +142,7 @@ if test x$enable_egl = xyes; then
 	AC_DEFINE([ENABLE_EGL], [1], [Build Weston with EGL support])
 	PKG_CHECK_MODULES(EGL, [egl glesv2])
         PKG_CHECK_MODULES([EGL_TESTS], [egl glesv2 wayland-client wayland-egl])
+	AC_CHECK_HEADERS([linux/sync_file.h])
 fi
 
 COMPOSITOR_MODULES="$COMPOSITOR_MODULES xkbcommon >= 0.3.0"
diff --git a/libweston/weston-sync-file.h b/libweston/weston-sync-file.h
new file mode 100644
index 00000000..4d179df0
--- /dev/null
+++ b/libweston/weston-sync-file.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 Google, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+/* Sync file interface used by Weston, copied from kernel's sync_file.h */
+
+#ifndef WESTON_SYNC_FILE_H
+#define WESTON_SYNC_FILE_H
+
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+/**
+ * struct sync_fence_info - detailed fence information
+ * @obj_name:		name of parent sync_timeline
+* @driver_name:	name of driver implementing the parent
+* @status:		status of the fence 0:active 1:signaled <0:error
+ * @flags:		fence_info flags
+ * @timestamp_ns:	timestamp of status change in nanoseconds
+ */
+struct sync_fence_info {
+	char	obj_name[32];
+	char	driver_name[32];
+	__s32	status;
+	__u32	flags;
+	__u64	timestamp_ns;
+};
+
+/**
+ * struct sync_file_info - data returned from fence info ioctl
+ * @name:	name of fence
+ * @status:	status of fence. 1: signaled 0:active <0:error
+ * @flags:	sync_file_info flags
+ * @num_fences	number of fences in the sync_file
+ * @pad:	padding for 64-bit alignment, should always be zero
+ * @sync_fence_info: pointer to array of structs sync_fence_info with all
+ *		 fences in the sync_file
+ */
+struct sync_file_info {
+	char	name[32];
+	__s32	status;
+	__u32	flags;
+	__u32	num_fences;
+	__u32	pad;
+
+	__u64	sync_fence_info;
+};
+
+#define SYNC_IOC_MAGIC		'>'
+
+/**
+ * Opcodes  0, 1 and 2 were burned during a API change to avoid users of the
+ * old API to get weird errors when trying to handling sync_files. The API
+ * change happened during the de-stage of the Sync Framework when there was
+ * no upstream users available.
+ */
+
+/**
+ * DOC: SYNC_IOC_FILE_INFO - get detailed information on a sync_file
+ *
+ * Takes a struct sync_file_info. If num_fences is 0, the field is updated
+ * with the actual number of fences. If num_fences is > 0, the system will
+ * use the pointer provided on sync_fence_info to return up to num_fences of
+ * struct sync_fence_info, with detailed fence information.
+ */
+#define SYNC_IOC_FILE_INFO	_IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info)
+
+#endif
-- 
2.14.1



More information about the wayland-devel mailing list