Merge branch 'master' into r300-compiler
[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 /*
36 * pipe
37 */
38
39 struct drm_api *api;
40 struct pipe_winsys *winsys;
41 struct pipe_screen *screen;
42
43 /*
44 * drm
45 */
46
47 int drmFD;
48 drmVersionPtr version;
49 int deviceID;
50
51 drmModeResPtr res;
52
53 struct drm_screen *screens[MAX_SCREENS];
54 size_t count_screens;
55 };
56
57 struct drm_surface
58 {
59 _EGLSurface base; /* base class/object */
60
61 /*
62 * pipe
63 */
64
65
66 struct st_framebuffer *stfb;
67
68 /*
69 * drm
70 */
71
72 struct drm_screen *screen;
73
74 int w;
75 int h;
76 };
77
78 struct drm_context
79 {
80 _EGLContext base; /* base class/object */
81
82 /* pipe */
83
84 struct pipe_context *pipe;
85 struct st_context *st;
86 };
87
88 struct drm_screen
89 {
90 _EGLScreen base;
91
92 /*
93 * pipe
94 */
95
96 struct pipe_texture *tex;
97 struct pipe_surface *surface;
98
99 /*
100 * drm
101 */
102
103 struct {
104 unsigned height;
105 unsigned width;
106 unsigned pitch;
107 unsigned handle;
108 } front;
109
110 /* currently only support one connector */
111 drmModeConnectorPtr connector;
112 uint32_t connectorID;
113
114 /* dpms property */
115 drmModePropertyPtr dpms;
116
117 /* Has this screen been shown */
118 int shown;
119
120 /* Surface that is currently attached to this screen */
121 struct drm_surface *surf;
122
123 /* framebuffer */
124 drmModeFBPtr fb;
125 uint32_t fbID;
126
127 /* crtc and mode used */
128 /*drmModeCrtcPtr crtc;*/
129 uint32_t crtcID;
130
131 drmModeModeInfoPtr mode;
132 };
133
134
135 static INLINE struct drm_device *
136 lookup_drm_device(_EGLDisplay *d)
137 {
138 return (struct drm_device *) d->DriverData;
139 }
140
141
142 static INLINE struct drm_context *
143 lookup_drm_context(_EGLContext *c)
144 {
145 return (struct drm_context *) c;
146 }
147
148
149 static INLINE struct drm_surface *
150 lookup_drm_surface(_EGLSurface *s)
151 {
152 return (struct drm_surface *) s;
153 }
154
155 static INLINE struct drm_screen *
156 lookup_drm_screen(_EGLScreen *s)
157 {
158 return (struct drm_screen *) s;
159 }
160
161 /**
162 * egl_visual.h
163 */
164 /*@{*/
165 void drm_visual_modes_destroy(__GLcontextModes *modes);
166 __GLcontextModes* drm_visual_modes_create(unsigned count, size_t minimum_size);
167 __GLcontextModes* drm_visual_from_config(_EGLConfig *conf);
168 /*@}*/
169
170 /**
171 * egl_surface.h
172 */
173 /*@{*/
174 void drm_takedown_shown_screen(_EGLDisplay *dpy, struct drm_screen *screen);
175 /*@}*/
176
177 /**
178 * All function exported to the egl side.
179 */
180 /*@{*/
181 EGLBoolean drm_initialize(_EGLDriver *drv, _EGLDisplay *dpy, EGLint *major, EGLint *minor);
182 EGLBoolean drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy);
183 _EGLContext *drm_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list);
184 EGLBoolean drm_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *context);
185 _EGLSurface *drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list);
186 _EGLSurface *drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list);
187 _EGLSurface *drm_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list);
188 _EGLSurface *drm_create_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list);
189 EGLBoolean drm_show_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, _EGLSurface *surface, _EGLMode *mode);
190 EGLBoolean drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface);
191 EGLBoolean drm_make_current(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *context);
192 EGLBoolean drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw);
193 /*@}*/
194
195 #endif