2 * Copyright © 2013 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 #ifdef HAVE_DIX_CONFIG_H
24 #include <dix-config.h>
27 #include "scrnintstr.h"
29 #include "misyncstr.h"
31 #include "pixmapstr.h"
33 static DevPrivateKeyRec syncFdScreenPrivateKey
;
35 typedef struct _SyncFdScreenPrivate
{
36 SyncFdScreenFuncsRec funcs
;
37 } SyncFdScreenPrivateRec
, *SyncFdScreenPrivatePtr
;
39 static inline SyncFdScreenPrivatePtr
sync_fd_screen_priv(ScreenPtr pScreen
)
41 if (!dixPrivateKeyRegistered(&syncFdScreenPrivateKey
))
43 return dixLookupPrivate(&pScreen
->devPrivates
, &syncFdScreenPrivateKey
);
47 miSyncInitFenceFromFD(DrawablePtr pDraw
, SyncFence
*pFence
, int fd
, BOOL initially_triggered
)
50 SyncFdScreenPrivatePtr priv
= sync_fd_screen_priv(pDraw
->pScreen
);
55 return (*priv
->funcs
.CreateFenceFromFd
)(pDraw
->pScreen
, pFence
, fd
, initially_triggered
);
59 miSyncFDFromFence(DrawablePtr pDraw
, SyncFence
*pFence
)
61 SyncFdScreenPrivatePtr priv
= sync_fd_screen_priv(pDraw
->pScreen
);
66 return (*priv
->funcs
.GetFenceFd
)(pDraw
->pScreen
, pFence
);
69 _X_EXPORT Bool
miSyncFdScreenInit(ScreenPtr pScreen
,
70 const SyncFdScreenFuncsRec
*funcs
)
72 SyncFdScreenPrivatePtr priv
;
74 /* Check to see if we've already been initialized */
75 if (sync_fd_screen_priv(pScreen
) != NULL
)
78 if (!miSyncSetup(pScreen
))
81 if (!dixPrivateKeyRegistered(&syncFdScreenPrivateKey
)) {
82 if (!dixRegisterPrivateKey(&syncFdScreenPrivateKey
, PRIVATE_SCREEN
, 0))
86 priv
= calloc(1, sizeof (SyncFdScreenPrivateRec
));
90 /* Will require version checks when there are multiple versions
91 * of the funcs structure
96 dixSetPrivate(&pScreen
->devPrivates
, &syncFdScreenPrivateKey
, priv
);