tbm_sync: Inlucde linux/sync_file.h 65/317665/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Fri, 13 Sep 2024 02:17:56 +0000 (11:17 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Fri, 13 Sep 2024 02:35:19 +0000 (11:35 +0900)
Change-Id: If4b24f2c9cc0f7906f6ce13e71b6d798648b8782

src/tbm_sync.c

index 9421436c5657bc6e9ad39fe45de9dfbfdeecc58d..15015679bbb843dcddf520156d37485caa839825 100644 (file)
@@ -40,47 +40,51 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #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
@@ -140,7 +144,7 @@ tbm_sync_timeline_inc(tbm_fd timeline, unsigned int count)
 {
        __u32 arg = count;
 
-       if (ioctl(timeline, TIMELINE_IOC_INC, &arg) == -1) {
+       if (ioctl(timeline, SW_SYNC_IOC_INC, &arg) == -1) {
                _log_errno();
                return 0;
        }
@@ -155,7 +159,7 @@ tbm_sync_fence_create(tbm_fd timeline, const char *name, unsigned int value)
 
        _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;
        }
@@ -201,13 +205,13 @@ tbm_sync_fence_merge(const char *name, tbm_fd fence1, tbm_fd fence2)
 
        _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;