xref: /OK3568_Linux_fs/external/xserver/dri3/dri3.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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 _DRI3_H_
24*4882a593Smuzhiyun #define _DRI3_H_
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun #ifdef DRI3
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun #include <X11/extensions/dri3proto.h>
29*4882a593Smuzhiyun #include <randrstr.h>
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun #define DRI3_SCREEN_INFO_VERSION        2
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun typedef int (*dri3_open_proc)(ScreenPtr screen,
34*4882a593Smuzhiyun                               RRProviderPtr provider,
35*4882a593Smuzhiyun                               int *fd);
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun typedef int (*dri3_open_client_proc)(ClientPtr client,
38*4882a593Smuzhiyun                                      ScreenPtr screen,
39*4882a593Smuzhiyun                                      RRProviderPtr provider,
40*4882a593Smuzhiyun                                      int *fd);
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun typedef PixmapPtr (*dri3_pixmap_from_fd_proc) (ScreenPtr screen,
43*4882a593Smuzhiyun                                                int fd,
44*4882a593Smuzhiyun                                                CARD16 width,
45*4882a593Smuzhiyun                                                CARD16 height,
46*4882a593Smuzhiyun                                                CARD16 stride,
47*4882a593Smuzhiyun                                                CARD8 depth,
48*4882a593Smuzhiyun                                                CARD8 bpp);
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun typedef PixmapPtr (*dri3_pixmap_from_fds_proc) (ScreenPtr screen,
51*4882a593Smuzhiyun                                                 CARD8 num_fds,
52*4882a593Smuzhiyun                                                 const int *fds,
53*4882a593Smuzhiyun                                                 CARD16 width,
54*4882a593Smuzhiyun                                                 CARD16 height,
55*4882a593Smuzhiyun                                                 const CARD32 *strides,
56*4882a593Smuzhiyun                                                 const CARD32 *offsets,
57*4882a593Smuzhiyun                                                 CARD8 depth,
58*4882a593Smuzhiyun                                                 CARD8 bpp,
59*4882a593Smuzhiyun                                                 CARD64 modifier);
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun typedef int (*dri3_fd_from_pixmap_proc) (ScreenPtr screen,
62*4882a593Smuzhiyun                                          PixmapPtr pixmap,
63*4882a593Smuzhiyun                                          CARD16 *stride,
64*4882a593Smuzhiyun                                          CARD32 *size);
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun typedef int (*dri3_fds_from_pixmap_proc) (ScreenPtr screen,
67*4882a593Smuzhiyun                                           PixmapPtr pixmap,
68*4882a593Smuzhiyun                                           int *fds,
69*4882a593Smuzhiyun                                           uint32_t *strides,
70*4882a593Smuzhiyun                                           uint32_t *offsets,
71*4882a593Smuzhiyun                                           uint64_t *modifier);
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun typedef int (*dri3_get_formats_proc) (ScreenPtr screen,
74*4882a593Smuzhiyun                                       CARD32 *num_formats,
75*4882a593Smuzhiyun                                       CARD32 **formats);
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun typedef int (*dri3_get_modifiers_proc) (ScreenPtr screen,
78*4882a593Smuzhiyun                                         uint32_t format,
79*4882a593Smuzhiyun                                         uint32_t *num_modifiers,
80*4882a593Smuzhiyun                                         uint64_t **modifiers);
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun typedef int (*dri3_get_drawable_modifiers_proc) (DrawablePtr draw,
83*4882a593Smuzhiyun                                                  uint32_t format,
84*4882a593Smuzhiyun                                                  uint32_t *num_modifiers,
85*4882a593Smuzhiyun                                                  uint64_t **modifiers);
86*4882a593Smuzhiyun 
87*4882a593Smuzhiyun typedef struct dri3_screen_info {
88*4882a593Smuzhiyun     uint32_t                    version;
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun     dri3_open_proc              open;
91*4882a593Smuzhiyun     dri3_pixmap_from_fd_proc    pixmap_from_fd;
92*4882a593Smuzhiyun     dri3_fd_from_pixmap_proc    fd_from_pixmap;
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun     /* Version 1 */
95*4882a593Smuzhiyun     dri3_open_client_proc       open_client;
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun     /* Version 2 */
98*4882a593Smuzhiyun     dri3_pixmap_from_fds_proc   pixmap_from_fds;
99*4882a593Smuzhiyun     dri3_fds_from_pixmap_proc   fds_from_pixmap;
100*4882a593Smuzhiyun     dri3_get_formats_proc       get_formats;
101*4882a593Smuzhiyun     dri3_get_modifiers_proc     get_modifiers;
102*4882a593Smuzhiyun     dri3_get_drawable_modifiers_proc get_drawable_modifiers;
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun } dri3_screen_info_rec, *dri3_screen_info_ptr;
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun extern _X_EXPORT Bool
107*4882a593Smuzhiyun dri3_screen_init(ScreenPtr screen, const dri3_screen_info_rec *info);
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun extern _X_EXPORT int
110*4882a593Smuzhiyun dri3_send_open_reply(ClientPtr client, int fd);
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun extern _X_EXPORT uint32_t
113*4882a593Smuzhiyun drm_format_for_depth(uint32_t depth, uint32_t bpp);
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun #endif
116*4882a593Smuzhiyun 
117*4882a593Smuzhiyun #endif /* _DRI3_H_ */
118