1 /**************************************************************************
2  *
3  * Copyright (C) 2014 Red Hat Inc.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included
13  * in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16  * OR 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
19  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21  * OTHER DEALINGS IN THE SOFTWARE.
22  *
23  **************************************************************************/
24 
25 #ifndef VREND_WINSYS_H
26 #define VREND_WINSYS_H
27 
28 #include "config.h"
29 
30 #ifdef HAVE_EPOXY_EGL_H
31 #include "vrend_winsys_gbm.h"
32 #include "vrend_winsys_egl.h"
33 #endif
34 
35 #include "virglrenderer.h"
36 
37 #ifndef DRM_FORMAT_MOD_INVALID
38 #define DRM_FORMAT_MOD_INVALID 0x00ffffffffffffffULL
39 #endif
40 
41 struct virgl_gl_ctx_param;
42 
43 #ifdef HAVE_EPOXY_EGL_H
44 extern struct virgl_egl *egl;
45 extern struct virgl_gbm *gbm;
46 #endif
47 
48 int vrend_winsys_init(uint32_t flags, int preferred_fd);
49 void vrend_winsys_cleanup(void);
50 
51 virgl_renderer_gl_context vrend_winsys_create_context(struct virgl_gl_ctx_param *param);
52 void vrend_winsys_destroy_context(virgl_renderer_gl_context ctx);
53 int vrend_winsys_make_context_current(virgl_renderer_gl_context ctx);
54 
55 int vrend_winsys_has_gl_colorspace(void);
56 
57 int vrend_winsys_get_fourcc_for_texture(uint32_t tex_id, uint32_t format, int *fourcc);
58 int vrend_winsys_get_fd_for_texture(uint32_t tex_id, int *fd);
59 int vrend_winsys_get_fd_for_texture2(uint32_t tex_id, int *fd, int *stride, int *offset);
60 
61 uint32_t vrend_winsys_query_video_memory(void);
62 
63 #endif /* VREND_WINSYS_H */
64