1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright © 2013 Keith Packard
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Permission to use, copy, modify, distribute, and sell this software and its
5*4882a593Smuzhiyun * documentation for any purpose is hereby granted without fee, provided that
6*4882a593Smuzhiyun * the above copyright notice appear in all copies and that both that copyright
7*4882a593Smuzhiyun * notice and this permission notice appear in supporting documentation, and
8*4882a593Smuzhiyun * that the name of the copyright holders not be used in advertising or
9*4882a593Smuzhiyun * publicity pertaining to distribution of the software without specific,
10*4882a593Smuzhiyun * written prior permission. The copyright holders make no representations
11*4882a593Smuzhiyun * about the suitability of this software for any purpose. It is provided "as
12*4882a593Smuzhiyun * is" without express or implied warranty.
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15*4882a593Smuzhiyun * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16*4882a593Smuzhiyun * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17*4882a593Smuzhiyun * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18*4882a593Smuzhiyun * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19*4882a593Smuzhiyun * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20*4882a593Smuzhiyun * OF THIS SOFTWARE.
21*4882a593Smuzhiyun */
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun #ifndef _DRI3PRIV_H_
24*4882a593Smuzhiyun #define _DRI3PRIV_H_
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun #include <X11/X.h>
27*4882a593Smuzhiyun #include "scrnintstr.h"
28*4882a593Smuzhiyun #include "misc.h"
29*4882a593Smuzhiyun #include "list.h"
30*4882a593Smuzhiyun #include "windowstr.h"
31*4882a593Smuzhiyun #include "dixstruct.h"
32*4882a593Smuzhiyun #include <randrstr.h>
33*4882a593Smuzhiyun #include "dri3.h"
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun extern DevPrivateKeyRec dri3_screen_private_key;
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun typedef struct dri3_dmabuf_format {
38*4882a593Smuzhiyun uint32_t format;
39*4882a593Smuzhiyun uint32_t num_modifiers;
40*4882a593Smuzhiyun uint64_t *modifiers;
41*4882a593Smuzhiyun } dri3_dmabuf_format_rec, *dri3_dmabuf_format_ptr;
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun typedef struct dri3_screen_priv {
44*4882a593Smuzhiyun CloseScreenProcPtr CloseScreen;
45*4882a593Smuzhiyun ConfigNotifyProcPtr ConfigNotify;
46*4882a593Smuzhiyun DestroyWindowProcPtr DestroyWindow;
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun Bool formats_cached;
49*4882a593Smuzhiyun CARD32 num_formats;
50*4882a593Smuzhiyun dri3_dmabuf_format_ptr formats;
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun const dri3_screen_info_rec *info;
53*4882a593Smuzhiyun } dri3_screen_priv_rec, *dri3_screen_priv_ptr;
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun #define wrap(priv,real,mem,func) {\
56*4882a593Smuzhiyun priv->mem = real->mem; \
57*4882a593Smuzhiyun real->mem = func; \
58*4882a593Smuzhiyun }
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun #define unwrap(priv,real,mem) {\
61*4882a593Smuzhiyun real->mem = priv->mem; \
62*4882a593Smuzhiyun }
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun static inline dri3_screen_priv_ptr
dri3_screen_priv(ScreenPtr screen)65*4882a593Smuzhiyun dri3_screen_priv(ScreenPtr screen)
66*4882a593Smuzhiyun {
67*4882a593Smuzhiyun return (dri3_screen_priv_ptr)dixLookupPrivate(&(screen)->devPrivates, &dri3_screen_private_key);
68*4882a593Smuzhiyun }
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun int
71*4882a593Smuzhiyun proc_dri3_dispatch(ClientPtr client);
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun int
74*4882a593Smuzhiyun sproc_dri3_dispatch(ClientPtr client);
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun /* DDX interface */
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun int
79*4882a593Smuzhiyun dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd);
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun int
82*4882a593Smuzhiyun dri3_pixmap_from_fds(PixmapPtr *ppixmap, ScreenPtr screen,
83*4882a593Smuzhiyun CARD8 num_fds, const int *fds,
84*4882a593Smuzhiyun CARD16 width, CARD16 height,
85*4882a593Smuzhiyun const CARD32 *strides, const CARD32 *offsets,
86*4882a593Smuzhiyun CARD8 depth, CARD8 bpp, CARD64 modifier);
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun int
89*4882a593Smuzhiyun dri3_fd_from_pixmap(PixmapPtr pixmap, CARD16 *stride, CARD32 *size);
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun int
92*4882a593Smuzhiyun dri3_fds_from_pixmap(PixmapPtr pixmap, int *fds,
93*4882a593Smuzhiyun uint32_t *strides, uint32_t *offsets,
94*4882a593Smuzhiyun uint64_t *modifier);
95*4882a593Smuzhiyun
96*4882a593Smuzhiyun int
97*4882a593Smuzhiyun dri3_get_supported_modifiers(ScreenPtr screen, DrawablePtr drawable,
98*4882a593Smuzhiyun CARD8 depth, CARD8 bpp,
99*4882a593Smuzhiyun CARD32 *num_drawable_modifiers,
100*4882a593Smuzhiyun CARD64 **drawable_modifiers,
101*4882a593Smuzhiyun CARD32 *num_screen_modifiers,
102*4882a593Smuzhiyun CARD64 **screen_modifiers);
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun #endif /* _DRI3PRIV_H_ */
105