ilo: add the driver to the build system
[mesa.git] / src / gallium / targets / egl-static / egl_pipe.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.10
4 *
5 * Copyright (C) 2011 LunarG Inc.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 *
25 * Authors:
26 * Chia-I Wu <olv@lunarg.com>
27 */
28 #include "target-helpers/inline_debug_helper.h"
29 #include "target-helpers/inline_sw_helper.h"
30 #include "egl_pipe.h"
31
32 /* for i915 */
33 #include "i915/drm/i915_drm_public.h"
34 #include "i915/i915_public.h"
35 #include "target-helpers/inline_wrapper_sw_helper.h"
36 /* for ilo */
37 #include "intel/drm/intel_drm_public.h"
38 #include "ilo/ilo_public.h"
39 /* for nouveau */
40 #include "nouveau/drm/nouveau_drm_public.h"
41 /* for r300 */
42 #include "radeon/drm/radeon_drm_public.h"
43 #include "r300/r300_public.h"
44 /* for r600 */
45 #include "r600/r600_public.h"
46 /* for radeonsi */
47 #include "radeonsi/radeonsi_public.h"
48 /* for vmwgfx */
49 #include "svga/drm/svga_drm_public.h"
50 #include "svga/svga_public.h"
51 /* for freedreno */
52 #include "freedreno/drm/freedreno_drm_public.h"
53
54 static struct pipe_screen *
55 pipe_i915_create_screen(int fd)
56 {
57 #if _EGL_PIPE_I915
58 struct i915_winsys *iws;
59 struct pipe_screen *screen;
60
61 iws = i915_drm_winsys_create(fd);
62 if (!iws)
63 return NULL;
64
65 screen = i915_screen_create(iws);
66 if (!screen)
67 return NULL;
68
69 screen = debug_screen_wrap(screen);
70
71 return screen;
72 #else
73 return NULL;
74 #endif
75 }
76
77 static struct pipe_screen *
78 pipe_ilo_create_screen(int fd)
79 {
80 #if _EGL_PIPE_ILO
81 struct intel_winsys *iws;
82 struct pipe_screen *screen;
83
84 iws = intel_drm_winsys_create(fd);
85 if (!iws)
86 return NULL;
87
88 screen = ilo_screen_create(iws);
89 if (!screen)
90 return NULL;
91
92 screen = debug_screen_wrap(screen);
93
94 return screen;
95 #else
96 return NULL;
97 #endif
98 }
99
100 static struct pipe_screen *
101 pipe_nouveau_create_screen(int fd)
102 {
103 #if _EGL_PIPE_NOUVEAU
104 struct pipe_screen *screen;
105
106 screen = nouveau_drm_screen_create(fd);
107 if (!screen)
108 return NULL;
109
110 screen = debug_screen_wrap(screen);
111
112 return screen;
113 #else
114 return NULL;
115 #endif
116 }
117
118 static struct pipe_screen *
119 pipe_r300_create_screen(int fd)
120 {
121 #if _EGL_PIPE_R300
122 struct radeon_winsys *sws;
123 struct pipe_screen *screen;
124
125 sws = radeon_drm_winsys_create(fd);
126 if (!sws)
127 return NULL;
128
129 screen = r300_screen_create(sws);
130 if (!screen)
131 return NULL;
132
133 screen = debug_screen_wrap(screen);
134
135 return screen;
136 #else
137 return NULL;
138 #endif
139 }
140
141 static struct pipe_screen *
142 pipe_r600_create_screen(int fd)
143 {
144 #if _EGL_PIPE_R600
145 struct radeon_winsys *rw;
146 struct pipe_screen *screen;
147
148 rw = radeon_drm_winsys_create(fd);
149 if (!rw)
150 return NULL;
151
152 screen = r600_screen_create(rw);
153 if (!screen)
154 return NULL;
155
156 screen = debug_screen_wrap(screen);
157
158 return screen;
159 #else
160 return NULL;
161 #endif
162 }
163
164 static struct pipe_screen *
165 pipe_radeonsi_create_screen(int fd)
166 {
167 #if _EGL_PIPE_RADEONSI
168 struct radeon_winsys *rw;
169 struct pipe_screen *screen;
170
171 rw = radeon_drm_winsys_create(fd);
172 if (!rw)
173 return NULL;
174
175 screen = radeonsi_screen_create(rw);
176 if (!screen)
177 return NULL;
178
179 screen = debug_screen_wrap(screen);
180
181 return screen;
182 #else
183 return NULL;
184 #endif
185 }
186
187 static struct pipe_screen *
188 pipe_vmwgfx_create_screen(int fd)
189 {
190 #if _EGL_PIPE_VMWGFX
191 struct svga_winsys_screen *sws;
192 struct pipe_screen *screen;
193
194 sws = svga_drm_winsys_screen_create(fd);
195 if (!sws)
196 return NULL;
197
198 screen = svga_screen_create(sws);
199 if (!screen)
200 return NULL;
201
202 screen = debug_screen_wrap(screen);
203
204 return screen;
205 #else
206 return NULL;
207 #endif
208 }
209
210 static struct pipe_screen *
211 pipe_freedreno_create_screen(int fd)
212 {
213 #if _EGL_PIPE_FREEDRENO
214 struct pipe_screen *screen;
215
216 screen = fd_drm_screen_create(fd);
217 if (!screen)
218 return NULL;
219
220 screen = debug_screen_wrap(screen);
221
222 return screen;
223 #else
224 return NULL;
225 #endif
226 }
227
228 struct pipe_screen *
229 egl_pipe_create_drm_screen(const char *name, int fd)
230 {
231 if (strcmp(name, "i915") == 0)
232 return pipe_i915_create_screen(fd);
233 else if (strcmp(name, "i965") == 0)
234 return pipe_ilo_create_screen(fd);
235 else if (strcmp(name, "nouveau") == 0)
236 return pipe_nouveau_create_screen(fd);
237 else if (strcmp(name, "r300") == 0)
238 return pipe_r300_create_screen(fd);
239 else if (strcmp(name, "r600") == 0)
240 return pipe_r600_create_screen(fd);
241 else if (strcmp(name, "radeonsi") == 0)
242 return pipe_radeonsi_create_screen(fd);
243 else if (strcmp(name, "vmwgfx") == 0)
244 return pipe_vmwgfx_create_screen(fd);
245 else if (strcmp(name, "kgsl") == 0)
246 return pipe_freedreno_create_screen(fd);
247 else
248 return NULL;
249 }
250
251 struct pipe_screen *
252 egl_pipe_create_swrast_screen(struct sw_winsys *ws)
253 {
254 struct pipe_screen *screen;
255
256 screen = sw_screen_create(ws);
257 if (screen)
258 screen = debug_screen_wrap(screen);
259
260 return screen;
261 }