1 /****************************************************************************
3 * Copyright (C) 2005 - 2014 by Vivante Corp.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the license, or
8 * (at your option) any later version.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *****************************************************************************/
23 #include <gc_hal_base.h>
25 #if gcdANDROID_NATIVE_FENCE_SYNC
27 #include <linux/kernel.h>
28 #include <linux/file.h>
30 #include <linux/miscdevice.h>
31 #include <linux/module.h>
32 #include <linux/syscalls.h>
33 #include <linux/uaccess.h>
35 #include "gc_hal_kernel_sync.h"
37 static struct sync_pt *
39 struct sync_pt * sync_pt
43 struct viv_sync_pt *pt;
44 struct viv_sync_pt *src;
45 struct viv_sync_timeline *obj;
47 src = (struct viv_sync_pt *) sync_pt;
48 obj = (struct viv_sync_timeline *) sync_pt->parent;
50 /* Create the new sync_pt. */
51 pt = (struct viv_sync_pt *)
52 sync_pt_create(&obj->obj, sizeof(struct viv_sync_pt));
54 pt->stamp = src->stamp;
57 /* Reference sync point. */
58 status = gckOS_ReferenceSyncPoint(obj->os, pt->sync);
60 if (gcmIS_ERROR(status))
62 sync_pt_free((struct sync_pt *)pt);
66 return (struct sync_pt *)pt;
70 viv_sync_pt_has_signaled(
71 struct sync_pt * sync_pt
76 struct viv_sync_pt * pt;
77 struct viv_sync_timeline * obj;
79 pt = (struct viv_sync_pt *)sync_pt;
80 obj = (struct viv_sync_timeline *)sync_pt->parent;
82 status = gckOS_QuerySyncPoint(obj->os, pt->sync, &state);
84 if (gcmIS_ERROR(status))
100 struct viv_sync_pt * pt1 = (struct viv_sync_pt *) a;
101 struct viv_sync_pt * pt2 = (struct viv_sync_pt *) b;
103 ret = (pt1->stamp < pt2->stamp) ? -1
104 : (pt1->stamp == pt2->stamp) ? 0
112 struct sync_pt * sync_pt
115 struct viv_sync_pt * pt;
116 struct viv_sync_timeline * obj;
118 pt = (struct viv_sync_pt *) sync_pt;
119 obj = (struct viv_sync_timeline *) sync_pt->parent;
121 gckOS_DestroySyncPoint(obj->os, pt->sync);
124 static struct sync_timeline_ops viv_timeline_ops =
126 .driver_name = "viv_sync",
127 .dup = viv_sync_pt_dup,
128 .has_signaled = viv_sync_pt_has_signaled,
129 .compare = viv_sync_pt_compare,
130 .free_pt = viv_sync_pt_free,
133 struct viv_sync_timeline *
134 viv_sync_timeline_create(
139 struct viv_sync_timeline * obj;
141 obj = (struct viv_sync_timeline *)
142 sync_timeline_create(&viv_timeline_ops, sizeof(struct viv_sync_timeline), name);
152 struct viv_sync_timeline * obj,
153 gctSYNC_POINT SyncPoint
157 struct viv_sync_pt * pt;
159 pt = (struct viv_sync_pt *)
160 sync_pt_create(&obj->obj, sizeof(struct viv_sync_pt));
162 pt->stamp = obj->stamp++;
163 pt->sync = SyncPoint;
166 status = gckOS_ReferenceSyncPoint(obj->os, SyncPoint);
168 if (gcmIS_ERROR(status))
170 sync_pt_free((struct sync_pt *)pt);
174 return (struct sync_pt *) pt;