1/*
2 * Copyright © 2013 Keith Packard
3 *
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.
13 *
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
20 * OF THIS SOFTWARE.
21 */
22
23#ifndef _DRI3PRIV_H_
24#define _DRI3PRIV_H_
25
26#include "dix-config.h"
27#include <X11/X.h>
28#include "scrnintstr.h"
29#include "misc.h"
30#include "list.h"
31#include "windowstr.h"
32#include "dixstruct.h"
33#include <randrstr.h>
34#include "dri3.h"
35
36extern DevPrivateKeyRec dri3_screen_private_key;
37
38typedef struct dri3_dmabuf_format {
39    uint32_t                    format;
40    uint32_t                    num_modifiers;
41    uint64_t                   *modifiers;
42} dri3_dmabuf_format_rec, *dri3_dmabuf_format_ptr;
43
44typedef struct dri3_screen_priv {
45    CloseScreenProcPtr          CloseScreen;
46    ConfigNotifyProcPtr         ConfigNotify;
47    DestroyWindowProcPtr        DestroyWindow;
48
49    Bool                        formats_cached;
50    CARD32                      num_formats;
51    dri3_dmabuf_format_ptr      formats;
52
53    const dri3_screen_info_rec *info;
54} dri3_screen_priv_rec, *dri3_screen_priv_ptr;
55
56#define wrap(priv,real,mem,func) {\
57    priv->mem = real->mem; \
58    real->mem = func; \
59}
60
61#define unwrap(priv,real,mem) {\
62    real->mem = priv->mem; \
63}
64
65static inline dri3_screen_priv_ptr
66dri3_screen_priv(ScreenPtr screen)
67{
68    return (dri3_screen_priv_ptr)dixLookupPrivate(&(screen)->devPrivates, &dri3_screen_private_key);
69}
70
71int
72proc_dri3_dispatch(ClientPtr client);
73
74int
75sproc_dri3_dispatch(ClientPtr client);
76
77/* DDX interface */
78
79int
80dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd);
81
82int
83dri3_pixmap_from_fds(PixmapPtr *ppixmap, ScreenPtr screen,
84                     CARD8 num_fds, const int *fds,
85                     CARD16 width, CARD16 height,
86                     const CARD32 *strides, const CARD32 *offsets,
87                     CARD8 depth, CARD8 bpp, CARD64 modifier);
88
89int
90dri3_fd_from_pixmap(PixmapPtr pixmap, CARD16 *stride, CARD32 *size);
91
92int
93dri3_fds_from_pixmap(PixmapPtr pixmap, int *fds,
94                     uint32_t *strides, uint32_t *offsets,
95                     uint64_t *modifier);
96
97int
98dri3_get_supported_modifiers(ScreenPtr screen, DrawablePtr drawable,
99                             CARD8 depth, CARD8 bpp,
100                             CARD32 *num_drawable_modifiers,
101                             CARD64 **drawable_modifiers,
102                             CARD32 *num_screen_modifiers,
103                             CARD64 **screen_modifiers);
104
105#endif /* _DRI3PRIV_H_ */
106