xref: /OK3568_Linux_fs/external/xserver/miext/sync/misyncstr.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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 _MISYNCSTR_H_
29 #define _MISYNCSTR_H_
30 
31 #include <stdint.h>
32 #include "dix.h"
33 #include "misync.h"
34 #include "scrnintstr.h"
35 #include <X11/extensions/syncconst.h>
36 
37 /* Sync object types */
38 #define SYNC_COUNTER		0
39 #define SYNC_FENCE		1
40 
41 struct _SyncObject {
42     ClientPtr client;           /* Owning client. 0 for system counters */
43     struct _SyncTriggerList *pTriglist; /* list of triggers */
44     XID id;                     /* resource ID */
45     unsigned char type;         /* SYNC_* */
46     unsigned char initialized;  /* FALSE if created but not initialized */
47     Bool beingDestroyed;        /* in process of going away */
48 };
49 
50 typedef struct _SyncCounter {
51     SyncObject sync;            /* Common sync object data */
52     int64_t value;              /* counter value */
53     struct _SysCounterInfo *pSysCounterInfo; /* NULL if not a system counter */
54 } SyncCounter;
55 
56 struct _SyncFence {
57     SyncObject sync;            /* Common sync object data */
58     ScreenPtr pScreen;          /* Screen of this fence object */
59     SyncFenceFuncsRec funcs;    /* Funcs for performing ops on fence */
60     Bool triggered;             /* fence state */
61     PrivateRec *devPrivates;    /* driver-specific per-fence data */
62 };
63 
64 struct _SyncTrigger {
65     SyncObject *pSync;
66     int64_t wait_value;         /* wait value */
67     unsigned int value_type;    /* Absolute or Relative */
68     unsigned int test_type;     /* transition or Comparision type */
69     int64_t test_value;         /* trigger event threshold value */
70     Bool (*CheckTrigger)(struct _SyncTrigger *pTrigger,
71                          int64_t newval);
72     void (*TriggerFired)(struct _SyncTrigger *pTrigger);
73     void (*CounterDestroyed)(struct _SyncTrigger *pTrigger);
74 };
75 
76 typedef struct _SyncTriggerList {
77     SyncTrigger *pTrigger;
78     struct _SyncTriggerList *next;
79 } SyncTriggerList;
80 
81 extern DevPrivateKeyRec miSyncScreenPrivateKey;
82 
83 #define SYNC_SCREEN_PRIV(pScreen) 				\
84     (SyncScreenPrivPtr) dixLookupPrivate(&pScreen->devPrivates,	\
85 					 &miSyncScreenPrivateKey)
86 
87 typedef struct _syncScreenPriv {
88     /* Wrappable sync-specific screen functions */
89     SyncScreenFuncsRec funcs;
90 
91     /* Wrapped screen functions */
92     CloseScreenProcPtr CloseScreen;
93 } SyncScreenPrivRec, *SyncScreenPrivPtr;
94 
95 #endif                          /* _MISYNCSTR_H_ */
96