]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/android/sw_sync.c
staging/android: store last signaled value on sync timeline
[karo-tx-linux.git] / drivers / staging / android / sw_sync.c
1 /*
2  * drivers/base/sw_sync.c
3  *
4  * Copyright (C) 2012 Google, Inc.
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/export.h>
20 #include <linux/file.h>
21 #include <linux/fs.h>
22 #include <linux/miscdevice.h>
23 #include <linux/syscalls.h>
24 #include <linux/uaccess.h>
25
26 #include "sw_sync.h"
27
28 struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value)
29 {
30         struct sw_sync_pt *pt;
31
32         pt = (struct sw_sync_pt *)
33                 sync_pt_create(&obj->obj, sizeof(struct sw_sync_pt), value);
34
35         pt->value = value;
36
37         return (struct fence *)pt;
38 }
39 EXPORT_SYMBOL(sw_sync_pt_create);
40
41 static void sw_sync_timeline_value_str(struct sync_timeline *sync_timeline,
42                                        char *str, int size)
43 {
44         struct sw_sync_timeline *timeline =
45                 (struct sw_sync_timeline *)sync_timeline;
46         snprintf(str, size, "%d", timeline->value);
47 }
48
49 static void sw_sync_fence_value_str(struct fence *fence, char *str, int size)
50 {
51         struct sw_sync_pt *pt = (struct sw_sync_pt *)fence;
52
53         snprintf(str, size, "%d", pt->value);
54 }
55
56 static struct sync_timeline_ops sw_sync_timeline_ops = {
57         .driver_name = "sw_sync",
58         .timeline_value_str = sw_sync_timeline_value_str,
59         .fence_value_str = sw_sync_fence_value_str,
60 };
61
62 struct sw_sync_timeline *sw_sync_timeline_create(const char *name)
63 {
64         struct sw_sync_timeline *obj = (struct sw_sync_timeline *)
65                 sync_timeline_create(&sw_sync_timeline_ops,
66                                      sizeof(struct sw_sync_timeline),
67                                      name);
68
69         return obj;
70 }
71 EXPORT_SYMBOL(sw_sync_timeline_create);
72
73 void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc)
74 {
75         sync_timeline_signal(&obj->obj, inc);
76 }
77 EXPORT_SYMBOL(sw_sync_timeline_inc);