tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / mali / linux / mali_sync.h
1 /*
2  * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
3  *
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  *
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10
11 /**
12  * @file mali_sync.h
13  *
14  */
15
16 #ifndef _MALI_SYNC_H_
17 #define _MALI_SYNC_H_
18
19 #include <linux/version.h>
20 #ifdef CONFIG_SYNC
21 /* MALI_SEC */
22 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
23
24 #include <linux/seq_file.h>
25 #include <linux/sync.h>
26
27 /*
28  * Create a stream object.
29  * Built on top of timeline object.
30  * Exposed as a file descriptor.
31  * Life-time controlled via the file descriptor:
32  * - dup to add a ref
33  * - close to remove a ref
34  */
35 _mali_osk_errcode_t mali_stream_create(const char * name, int * out_fd);
36
37 /*
38  * Create a fence in a stream object
39  */
40 struct sync_pt *mali_stream_create_point(int tl_fd);
41 int mali_stream_create_fence(struct sync_pt *pt);
42
43 /*
44  * Validate a fd to be a valid fence
45  * No reference is taken.
46  *
47  * This function is only usable to catch unintentional user errors early,
48  * it does not stop malicious code changing the fd after this function returns.
49  */
50 _mali_osk_errcode_t mali_fence_validate(int fd);
51
52
53 /* Returns true if the specified timeline is allocated by Mali */
54 int mali_sync_timeline_is_ours(struct sync_timeline *timeline);
55
56 /* Allocates a timeline for Mali
57  *
58  * One timeline should be allocated per API context.
59  */
60 struct sync_timeline *mali_sync_timeline_alloc(const char *name);
61
62 /* Allocates a sync point within the timeline.
63  *
64  * The timeline must be the one allocated by mali_sync_timeline_alloc
65  *
66  * Sync points must be triggered in *exactly* the same order as they are allocated.
67  */
68 struct sync_pt *mali_sync_pt_alloc(struct sync_timeline *parent);
69
70 /* Signals a particular sync point
71  *
72  * Sync points must be triggered in *exactly* the same order as they are allocated.
73  *
74  * If they are signalled in the wrong order then a message will be printed in debug
75  * builds and otherwise attempts to signal order sync_pts will be ignored.
76  */
77 void mali_sync_signal_pt(struct sync_pt *pt, int error);
78
79 #endif
80 #endif /* CONFIG_SYNC */
81 #endif /* _MALI_SYNC_H_ */