4 * Copyright 2012 Google, Inc
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include <linux/sync.h>
25 #include <linux/sw_sync.h>
27 #include <sys/ioctl.h>
29 #include <sys/types.h>
31 int sync_wait(int fd
, int timeout
)
35 return ioctl(fd
, SYNC_IOC_WAIT
, &to
);
38 int sync_merge(const char *name
, int fd1
, int fd2
)
40 struct sync_merge_data data
;
44 strlcpy(data
.name
, name
, sizeof(data
.name
));
46 err
= ioctl(fd1
, SYNC_IOC_MERGE
, &data
);
53 struct sync_fence_info_data
*sync_fence_info(int fd
)
55 struct sync_fence_info_data
*info
;
63 err
= ioctl(fd
, SYNC_IOC_FENCE_INFO
, info
);
72 struct sync_pt_info
*sync_pt_info(struct sync_fence_info_data
*info
,
73 struct sync_pt_info
*itr
)
76 itr
= (struct sync_pt_info
*) info
->pt_info
;
78 itr
= (struct sync_pt_info
*) ((__u8
*)itr
+ itr
->len
);
80 if ((__u8
*)itr
- (__u8
*)info
>= (int)info
->len
)
86 void sync_fence_info_free(struct sync_fence_info_data
*info
)
92 int sw_sync_timeline_create(void)
94 return open("/dev/sw_sync", O_RDWR
);
97 int sw_sync_timeline_inc(int fd
, unsigned count
)
101 return ioctl(fd
, SW_SYNC_IOC_INC
, &arg
);
104 int sw_sync_fence_create(int fd
, const char *name
, unsigned value
)
106 struct sw_sync_create_fence_data data
;
110 strlcpy(data
.name
, name
, sizeof(data
.name
));
112 err
= ioctl(fd
, SW_SYNC_IOC_CREATE_FENCE
, &data
);