diff options
| author | Meizu OpenSource <patchwork@meizu.com> | 2016-08-15 10:19:42 +0800 |
|---|---|---|
| committer | Meizu OpenSource <patchwork@meizu.com> | 2016-08-15 10:19:42 +0800 |
| commit | d2e1446d81725c351dc73a03b397ce043fb18452 (patch) | |
| tree | 4dbc616b7f92aea39cd697a9084205ddb805e344 /drivers/misc/mediatek/sync/mtk_sync.c | |
| download | android_kernel_m2note-d2e1446d81725c351dc73a03b397ce043fb18452.tar.gz | |
first commit
Diffstat (limited to 'drivers/misc/mediatek/sync/mtk_sync.c')
| -rw-r--r-- | drivers/misc/mediatek/sync/mtk_sync.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/drivers/misc/mediatek/sync/mtk_sync.c b/drivers/misc/mediatek/sync/mtk_sync.c new file mode 100644 index 000000000..e9fe3173a --- /dev/null +++ b/drivers/misc/mediatek/sync/mtk_sync.c @@ -0,0 +1,131 @@ +/* +* Copyright (C) 2011-2014 MediaTek Inc. +* +* This program is free software: you can redistribute it and/or modify it under the terms of the +* GNU General Public License version 2 as published by the Free Software Foundation. +* +* 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. +* +* You should have received a copy of the GNU General Public License along with this program. +* If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <linux/debugfs.h> +#include <linux/export.h> +#include <linux/seq_file.h> +#include <linux/file.h> +#include <linux/kthread.h> +#include <linux/xlog.h> +#include <linux/delay.h> + +#include "mtk_sync.h" + +/* -------------------------------------------------------------------------- */ + +struct sw_sync_timeline *timeline_create(const char *name) +{ + return sw_sync_timeline_create(name); +} +EXPORT_SYMBOL(timeline_create); + +void timeline_destroy(struct sw_sync_timeline *obj) +{ + sync_timeline_destroy(&obj->obj); +} +EXPORT_SYMBOL(timeline_destroy); + +void timeline_inc(struct sw_sync_timeline *obj, u32 value) +{ + sw_sync_timeline_inc(obj, value); +} +EXPORT_SYMBOL(timeline_inc); + +int fence_create(struct sw_sync_timeline *obj, struct fence_data *data) +{ + int fd = get_unused_fd(); + int err; + struct sync_pt *pt; + struct sync_fence *fence; + + if (fd < 0) + return fd; + + pt = sw_sync_pt_create(obj, data->value); + if (pt == NULL) { + err = -ENOMEM; + goto err; + } + + data->name[sizeof(data->name) - 1] = '\0'; + fence = sync_fence_create(data->name, pt); + if (fence == NULL) { + sync_pt_free(pt); + err = -ENOMEM; + goto err; + } + + data->fence = fd; + + sync_fence_install(fence, fd); + + return 0; + + err: + put_unused_fd(fd); + return err; +} +EXPORT_SYMBOL(fence_create); + +int fence_merge(char *const name, int fd1, int fd2) +{ + int fd = get_unused_fd(); + int err; + struct sync_fence *fence1, *fence2, *fence3; + + if (fd < 0) + return fd; + + fence1 = sync_fence_fdget(fd1); + if (NULL == fence1) { + err = -ENOENT; + goto err_put_fd; + } + + fence2 = sync_fence_fdget(fd2); + if (NULL == fence2) { + err = -ENOENT; + goto err_put_fence1; + } + + name[sizeof(name) - 1] = '\0'; + fence3 = sync_fence_merge(name, fence1, fence2); + if (fence3 == NULL) { + err = -ENOMEM; + goto err_put_fence2; + } + + sync_fence_install(fence3, fd); + sync_fence_put(fence2); + sync_fence_put(fence1); + + return fd; + + err_put_fence2: + sync_fence_put(fence2); + + err_put_fence1: + sync_fence_put(fence1); + + err_put_fd: + put_unused_fd(fd); + return err; +} +EXPORT_SYMBOL(fence_merge); + +inline int fence_wait(struct sync_fence *fence, int timeout) +{ + return sync_fence_wait(fence, timeout); +} +EXPORT_SYMBOL(fence_wait); |
