1 /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
2 /*
3  * Copyright (C) 2012 Google, Inc.
4  *
5  * This program is distributed in the hope that it will be useful,
6  * but WITHOUT ANY WARRANTY; without even the implied warranty of
7  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8  * GNU General Public License for more details.
9  *
10  */
11 
12 #ifndef _UAPI_LINUX_SYNC_H
13 #define _UAPI_LINUX_SYNC_H
14 
15 #if defined(__linux__)
16 
17 #include <linux/ioctl.h>
18 #include <linux/types.h>
19 
20 #else /* One of the BSDs */
21 
22 #include <stdint.h>
23 #include <sys/types.h>
24 #include <sys/ioccom.h>
25 
26 typedef int8_t   __s8;
27 typedef uint8_t  __u8;
28 typedef int16_t  __s16;
29 typedef uint16_t __u16;
30 typedef int32_t  __s32;
31 typedef uint32_t __u32;
32 typedef int64_t  __s64;
33 typedef uint64_t __u64;
34 
35 #endif
36 
37 /**
38  * struct sync_merge_data - data passed to merge ioctl
39  * @name:	name of new fence
40  * @fd2:	file descriptor of second fence
41  * @fence:	returns the fd of the new fence to userspace
42  * @flags:	merge_data flags
43  * @pad:	padding for 64-bit alignment, should always be zero
44  */
45 struct sync_merge_data {
46 	char	name[32];
47 	__s32	fd2;
48 	__s32	fence;
49 	__u32	flags;
50 	__u32	pad;
51 };
52 
53 /**
54  * struct sync_fence_info - detailed fence information
55  * @obj_name:		name of parent sync_timeline
56 * @driver_name:	name of driver implementing the parent
57 * @status:		status of the fence 0:active 1:signaled <0:error
58  * @flags:		fence_info flags
59  * @timestamp_ns:	timestamp of status change in nanoseconds
60  */
61 struct sync_fence_info {
62 	char	obj_name[32];
63 	char	driver_name[32];
64 	__s32	status;
65 	__u32	flags;
66 	__u64	timestamp_ns;
67 };
68 
69 /**
70  * struct sync_file_info - data returned from fence info ioctl
71  * @name:	name of fence
72  * @status:	status of fence. 1: signaled 0:active <0:error
73  * @flags:	sync_file_info flags
74  * @num_fences	number of fences in the sync_file
75  * @pad:	padding for 64-bit alignment, should always be zero
76  * @sync_fence_info: pointer to array of structs sync_fence_info with all
77  *		 fences in the sync_file
78  */
79 struct sync_file_info {
80 	char	name[32];
81 	__s32	status;
82 	__u32	flags;
83 	__u32	num_fences;
84 	__u32	pad;
85 
86 	__u64	sync_fence_info;
87 };
88 
89 #define SYNC_IOC_MAGIC		'>'
90 
91 /**
92  * Opcodes  0, 1 and 2 were burned during a API change to avoid users of the
93  * old API to get weird errors when trying to handling sync_files. The API
94  * change happened during the de-stage of the Sync Framework when there was
95  * no upstream users available.
96  */
97 
98 /**
99  * DOC: SYNC_IOC_MERGE - merge two fences
100  *
101  * Takes a struct sync_merge_data.  Creates a new fence containing copies of
102  * the sync_pts in both the calling fd and sync_merge_data.fd2.  Returns the
103  * new fence's fd in sync_merge_data.fence
104  */
105 #define SYNC_IOC_MERGE		_IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data)
106 
107 /**
108  * DOC: SYNC_IOC_FILE_INFO - get detailed information on a sync_file
109  *
110  * Takes a struct sync_file_info. If num_fences is 0, the field is updated
111  * with the actual number of fences. If num_fences is > 0, the system will
112  * use the pointer provided on sync_fence_info to return up to num_fences of
113  * struct sync_fence_info, with detailed fence information.
114  */
115 #define SYNC_IOC_FILE_INFO	_IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info)
116 
117 #endif /* _UAPI_LINUX_SYNC_H */
118