egl: Overhaul driver API.
[mesa.git] / src / gallium / state_trackers / egl / egl_tracker.h
1
2 #ifndef _EGL_TRACKER_H_
3 #define _EGL_TRACKER_H_
4
5 #include <stdint.h>
6
7 #include "eglconfig.h"
8 #include "eglcontext.h"
9 #include "egldisplay.h"
10 #include "egldriver.h"
11 #include "eglglobals.h"
12 #include "eglmode.h"
13 #include "eglscreen.h"
14 #include "eglsurface.h"
15
16 #include "xf86drm.h"
17 #include "xf86drmMode.h"
18
19 #include "pipe/p_compiler.h"
20
21 #include "state_tracker/st_public.h"
22
23 #define MAX_SCREENS 16
24
25 struct pipe_winsys;
26 struct pipe_screen;
27 struct pipe_context;
28 struct state_tracker;
29
30 struct drm_screen;
31 struct drm_context;
32
33 struct drm_device
34 {
35 _EGLDriver base; /* base class/object */
36
37 /*
38 * pipe
39 */
40
41 struct drm_api *api;
42 struct pipe_winsys *winsys;
43 struct pipe_screen *screen;
44
45 /*
46 * drm
47 */
48
49 int drmFD;
50 drmVersionPtr version;
51 int deviceID;
52
53 drmModeResPtr res;
54
55 struct drm_screen *screens[MAX_SCREENS];
56 size_t count_screens;
57 };
58
59 struct drm_surface
60 {
61 _EGLSurface base; /* base class/object */
62
63 /*
64 * pipe
65 */
66
67
68 struct st_framebuffer *stfb;
69
70 /*
71 * drm
72 */
73
74 struct drm_context *user;
75 struct drm_screen *screen;
76
77 int w;
78 int h;
79 };
80
81 struct drm_context
82 {
83 _EGLContext base; /* base class/object */
84
85 /* pipe */
86
87 struct pipe_context *pipe;
88 struct st_context *st;
89 };
90
91 struct drm_screen
92 {
93 _EGLScreen base;
94
95 /*
96 * pipe
97 */
98
99 struct pipe_buffer *buffer;
100 struct pipe_texture *tex;
101 struct pipe_surface *surface;
102
103 /*
104 * drm
105 */
106
107 struct {
108 unsigned height;
109 unsigned width;
110 unsigned pitch;
111 unsigned handle;
112 } front;
113
114 /* currently only support one connector */
115 drmModeConnectorPtr connector;
116 uint32_t connectorID;
117
118 /* dpms property */
119 drmModePropertyPtr dpms;
120
121 /* Has this screen been shown */
122 int shown;
123
124 /* Surface that is currently attached to this screen */
125 struct drm_surface *surf;
126
127 /* framebuffer */
128 drmModeFBPtr fb;
129 uint32_t fbID;
130
131 /* crtc and mode used */
132 /*drmModeCrtcPtr crtc;*/
133 uint32_t crtcID;
134
135 drmModeModeInfoPtr mode;
136 };
137
138
139 static INLINE struct drm_context *
140 lookup_drm_context(_EGLContext *c)
141 {
142 return (struct drm_context *) c;
143 }
144
145
146 static INLINE struct drm_surface *
147 lookup_drm_surface(_EGLSurface *s)
148 {
149 return (struct drm_surface *) s;
150 }
151
152 static INLINE struct drm_screen *
153 lookup_drm_screen(_EGLScreen *s)
154 {
155 return (struct drm_screen *) s;
156 }
157
158 /**
159 * egl_visual.h
160 */
161 /*@{*/
162 void drm_visual_modes_destroy(__GLcontextModes *modes);
163 __GLcontextModes* drm_visual_modes_create(unsigned count, size_t minimum_size);
164 __GLcontextModes* drm_visual_from_config(_EGLConfig *conf);
165 /*@}*/
166
167 /**
168 * egl_surface.h
169 */
170 /*@{*/
171 void drm_takedown_shown_screen(_EGLDriver *drv, struct drm_screen *screen);
172 /*@}*/
173
174 /**
175 * All function exported to the egl side.
176 */
177 /*@{*/
178 EGLBoolean drm_initialize(_EGLDriver *drv, _EGLDisplay *dpy, EGLint *major, EGLint *minor);
179 EGLBoolean drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy);
180 _EGLContext *drm_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list);
181 EGLBoolean drm_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *context);
182 _EGLSurface *drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list);
183 _EGLSurface *drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list);
184 _EGLSurface *drm_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list);
185 _EGLSurface *drm_create_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list);
186 EGLBoolean drm_show_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, _EGLSurface *surface, _EGLMode *mode);
187 EGLBoolean drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface);
188 EGLBoolean drm_make_current(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *context);
189 EGLBoolean drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw);
190 /*@}*/
191
192 #endif