import OT_8063_20170412 mali driver
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / gpu / mt8127 / mali / mali / linux / mali_sync.h
CommitLineData
6fa3eb70
S
1/*
2 * This confidential and proprietary software may be used only as
3 * authorised by a licensing agreement from ARM Limited
bdc132d7 4 * (C) COPYRIGHT 2012-2015 ARM Limited
6fa3eb70
S
5 * ALL RIGHTS RESERVED
6 * The entire notice above must be reproduced on all authorised
7 * copies and copies may only be made to the extent permitted
8 * by a licensing agreement from ARM Limited.
9 */
10
11/**
12 * @file mali_sync.h
13 *
14 * Mali interface for Linux sync objects.
15 */
16
17#ifndef _MALI_SYNC_H_
18#define _MALI_SYNC_H_
19
20#if defined(CONFIG_SYNC)
21
6fa3eb70 22#include <linux/seq_file.h>
bdc132d7
S
23#include <linux/version.h>
24#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
6fa3eb70 25#include <linux/sync.h>
bdc132d7
S
26#else
27#include <sync.h>
6fa3eb70
S
28#endif
29
bdc132d7 30
6fa3eb70
S
31#include "mali_osk.h"
32
33struct mali_sync_flag;
bdc132d7 34struct mali_timeline;
6fa3eb70
S
35
36/**
37 * Create a sync timeline.
38 *
39 * @param name Name of the sync timeline.
40 * @return The new sync timeline if successful, NULL if not.
41 */
bdc132d7 42struct sync_timeline *mali_sync_timeline_create(struct mali_timeline *timeline, const char *name);
6fa3eb70
S
43
44/**
45 * Creates a file descriptor representing the sync fence. Will release sync fence if allocation of
46 * file descriptor fails.
47 *
48 * @param sync_fence Sync fence.
49 * @return File descriptor representing sync fence if successful, or -1 if not.
50 */
51s32 mali_sync_fence_fd_alloc(struct sync_fence *sync_fence);
52
53/**
54 * Merges two sync fences. Both input sync fences will be released.
55 *
56 * @param sync_fence1 First sync fence.
57 * @param sync_fence2 Second sync fence.
58 * @return New sync fence that is the result of the merger if successful, or NULL if not.
59 */
60struct sync_fence *mali_sync_fence_merge(struct sync_fence *sync_fence1, struct sync_fence *sync_fence2);
61
62/**
63 * Create a sync fence that is already signaled.
64 *
65 * @param tl Sync timeline.
66 * @return New signaled sync fence if successful, NULL if not.
67 */
68struct sync_fence *mali_sync_timeline_create_signaled_fence(struct sync_timeline *sync_tl);
69
70/**
71 * Create a sync flag.
72 *
73 * @param sync_tl Sync timeline.
74 * @param point Point on Mali timeline.
75 * @return New sync flag if successful, NULL if not.
76 */
77struct mali_sync_flag *mali_sync_flag_create(struct sync_timeline *sync_tl, u32 point);
78
79/**
80 * Grab sync flag reference.
81 *
82 * @param flag Sync flag.
83 */
84void mali_sync_flag_get(struct mali_sync_flag *flag);
85
86/**
87 * Release sync flag reference. If this was the last reference, the sync flag will be freed.
88 *
89 * @param flag Sync flag.
90 */
91void mali_sync_flag_put(struct mali_sync_flag *flag);
92
93/**
94 * Signal sync flag. All sync fences created from this flag will be signaled.
95 *
96 * @param flag Sync flag to signal.
97 * @param error Negative error code, or 0 if no error.
98 */
99void mali_sync_flag_signal(struct mali_sync_flag *flag, int error);
100
101/**
102 * Create a sync fence attached to given sync flag.
103 *
104 * @param flag Sync flag.
105 * @return New sync fence if successful, NULL if not.
106 */
107struct sync_fence *mali_sync_flag_create_fence(struct mali_sync_flag *flag);
108
109#endif /* defined(CONFIG_SYNC) */
110
111#endif /* _MALI_SYNC_H_ */