#include <errno.h>
#include <sys/ioctl.h>
#include <linux/types.h>
+#include <linux/sync_file.h>
#include <poll.h>
-/* IOCTLs for timeline file object. */
-#define TIMELINE_IOC_MAGIC 'W'
-#define TIMELINE_IOC_CREATE_FENCE _IOWR(TIMELINE_IOC_MAGIC, 0, struct create_fence_data)
-#define TIMELINE_IOC_INC _IOW(TIMELINE_IOC_MAGIC, 1, __u32)
-
-/* IOCTLs for fence file object. */
-#define FENCE_IOC_MAGIC '>'
-#define FENCE_IOC_MERGE _IOWR(FENCE_IOC_MAGIC, 3, struct sync_merge_data)
-
-#define FENCE_IOC_LEGACY_WAIT _IOW(FENCE_IOC_MAGIC, 0, __s32)
-#define FENCE_IOC_LEGACY_MERGE _IOWR(FENCE_IOC_MAGIC, 1, struct sync_legacy_merge_data)
-
/* Path to the sync device legacy file. */
-#define SYNC_DEVICE_PATH_LEGACY "/dev/sw_sync"
+#define SYNC_DEVICE_PATH_LEGACY "/dev/sw_sync"
/* Path to the sync device file. */
-#define SYNC_DEVICE_PATH "/sys/kernel/debug/sync/sw_sync"
+#define SYNC_DEVICE_PATH "/sys/kernel/debug/sync/sw_sync"
+
+/* IOCTLs for timeline file object. */
+#define SW_SYNC_IOC_MAGIC 'W'
+#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0, struct create_fence_data)
+#define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32)
+
+#define SYNC_IOC_LEGACY_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_legacy_merge_data)
+#define SYNC_IOC_LEGACY_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2, struct sync_fence_info_data)
/* Argument data structure for the timeline.create_fence ioctl. */
struct create_fence_data {
- __u32 value; /* Pt value on the timeline for the fence (IN) */
- char name[32]; /* Name of the fence object (IN) */
- __s32 fence; /* File descriptor for the created fence (OUT) */
+ uint32_t value; /* Pt value on the timeline for the fence (IN) */
+ char name[32]; /* Name of the fence object (IN) */
+ int32_t fence; /* File descriptor for the created fence (OUT) */
};
-/* Argument data structure for the fence.merge ioctl. */
-struct sync_merge_data {
- char name[32]; /* Name of the new fence object (IN) */
- __s32 fd2; /* fence to merged with the fence (IN) */
- __s32 fence; /* File descriptor for the new fence (OUT) */
- __u32 flags; /* merge_data flags (IN) */
- __u32 pad; /* padding for 64-bit alignment, should always be zero */
+/* Argument data structure for the legacy fence.merge ioctl. */
+struct sync_fence_info_data {
+ uint32_t len;
+ char name[32];
+ int32_t status;
+ uint8_t pt_info[0];
+};
+
+struct sync_pt_info {
+ uint32_t len;
+ char obj_name[32];
+ char driver_name[32];
+ int32_t status;
+ uint64_t timestamp_ns;
+ uint8_t driver_data[0];
};
-/* Argument data structure for the legacy fence.merge ioctl. */
struct sync_legacy_merge_data {
- __s32 fd2; /* fence to merged with the fence (IN) */
- char name[32]; /* Name of the new fence object (IN) */
- __s32 fence; /* File descriptor for the new fence (OUT) */
+ int32_t fd2; /* fence to merged with the fence (IN) */
+ char name[32]; /* Name of the new fence object (IN) */
+ int32_t fence; /* File descriptor for the new fence (OUT) */
};
#define ERRNO_BUF_SIZE 256
{
__u32 arg = count;
- if (ioctl(timeline, TIMELINE_IOC_INC, &arg) == -1) {
+ if (ioctl(timeline, SW_SYNC_IOC_INC, &arg) == -1) {
_log_errno();
return 0;
}
_copy_string(data.name, name, 32);
- if (ioctl(timeline, TIMELINE_IOC_CREATE_FENCE, &data) == -1) {
+ if (ioctl(timeline, SW_SYNC_IOC_CREATE_FENCE, &data) == -1) {
_log_errno();
return -1;
}
_copy_string(data.name, name, 32);
- ret = ioctl(fence1, FENCE_IOC_MERGE, &data);
+ ret = ioctl(fence1, SYNC_IOC_MERGE, &data);
if (ret < 0 && errno == ENOTTY) {
struct sync_legacy_merge_data legacy_data = {. fd2 = fence2 };
_copy_string(legacy_data.name, name, 32);
- ret = ioctl(fence1, FENCE_IOC_LEGACY_MERGE, &legacy_data);
+ ret = ioctl(fence1, SYNC_IOC_LEGACY_MERGE, &legacy_data);
if (ret < 0) {
_log_errno();
return -1;