1/*
2 * Copyright © 2010 NVIDIA Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#ifdef HAVE_DIX_CONFIG_H
25#include <dix-config.h>
26#endif
27
28#ifndef _MISYNC_H_
29#define _MISYNC_H_
30
31typedef struct _SyncObject SyncObject;
32typedef struct _SyncFence SyncFence;
33typedef struct _SyncTrigger SyncTrigger;
34
35typedef void (*SyncScreenCreateFenceFunc) (ScreenPtr pScreen,
36                                           SyncFence * pFence,
37                                           Bool initially_triggered);
38typedef void (*SyncScreenDestroyFenceFunc) (ScreenPtr pScreen,
39                                            SyncFence * pFence);
40
41typedef struct _syncScreenFuncs {
42    SyncScreenCreateFenceFunc CreateFence;
43    SyncScreenDestroyFenceFunc DestroyFence;
44} SyncScreenFuncsRec, *SyncScreenFuncsPtr;
45
46
47extern _X_EXPORT void
48miSyncScreenCreateFence(ScreenPtr pScreen, SyncFence * pFence,
49                        Bool initially_triggered);
50extern _X_EXPORT void
51 miSyncScreenDestroyFence(ScreenPtr pScreen, SyncFence * pFence);
52
53typedef void (*SyncFenceSetTriggeredFunc) (SyncFence * pFence);
54typedef void (*SyncFenceResetFunc) (SyncFence * pFence);
55typedef Bool (*SyncFenceCheckTriggeredFunc) (SyncFence * pFence);
56typedef void (*SyncFenceAddTriggerFunc) (SyncTrigger * pTrigger);
57typedef void (*SyncFenceDeleteTriggerFunc) (SyncTrigger * pTrigger);
58
59typedef struct _syncFenceFuncs {
60    SyncFenceSetTriggeredFunc SetTriggered;
61    SyncFenceResetFunc Reset;
62    SyncFenceCheckTriggeredFunc CheckTriggered;
63    SyncFenceAddTriggerFunc AddTrigger;
64    SyncFenceDeleteTriggerFunc DeleteTrigger;
65} SyncFenceFuncsRec, *SyncFenceFuncsPtr;
66
67extern _X_EXPORT void
68
69miSyncInitFence(ScreenPtr pScreen, SyncFence * pFence,
70                Bool initially_triggered);
71extern _X_EXPORT void
72 miSyncDestroyFence(SyncFence * pFence);
73extern _X_EXPORT void
74 miSyncTriggerFence(SyncFence * pFence);
75
76extern _X_EXPORT SyncScreenFuncsPtr miSyncGetScreenFuncs(ScreenPtr pScreen);
77extern _X_EXPORT Bool
78 miSyncSetup(ScreenPtr pScreen);
79
80Bool
81miSyncFenceCheckTriggered(SyncFence * pFence);
82
83void
84miSyncFenceSetTriggered(SyncFence * pFence);
85
86void
87miSyncFenceReset(SyncFence * pFence);
88
89void
90miSyncFenceAddTrigger(SyncTrigger * pTrigger);
91
92void
93miSyncFenceDeleteTrigger(SyncTrigger * pTrigger);
94
95int
96miSyncInitFenceFromFD(DrawablePtr pDraw, SyncFence *pFence, int fd, BOOL initially_triggered);
97
98int
99miSyncFDFromFence(DrawablePtr pDraw, SyncFence *pFence);
100
101#endif                          /* _MISYNC_H_ */
102