i965g: Delete this driver.
[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 nouveau */
37 #include "nouveau/drm/nouveau_drm_public.h"
38 /* for r300 */
39 #include "radeon/drm/radeon_drm_public.h"
40 #include "r300/r300_public.h"
41 /* for r600 */
42 #include "r600/r600_public.h"
43 /* for vmwgfx */
44 #include "svga/drm/svga_drm_public.h"
45 #include "svga/svga_public.h"
46
47 static struct pipe_screen *
48 pipe_i915_create_screen(int fd)
49 {
50 #if _EGL_PIPE_I915
51 struct i915_winsys *iws;
52 struct pipe_screen *screen;
53
54 iws = i915_drm_winsys_create(fd);
55 if (!iws)
56 return NULL;
57
58 screen = i915_screen_create(iws);
59 if (!screen)
60 return NULL;
61
62 screen = debug_screen_wrap(screen);
63
64 return screen;
65 #else
66 return NULL;
67 #endif
68 }
69
70 static struct pipe_screen *
71 pipe_nouveau_create_screen(int fd)
72 {
73 #if _EGL_PIPE_NOUVEAU
74 struct pipe_screen *screen;
75
76 screen = nouveau_drm_screen_create(fd);
77 if (!screen)
78 return NULL;
79
80 screen = debug_screen_wrap(screen);
81
82 return screen;
83 #else
84 return NULL;
85 #endif
86 }
87
88 static struct pipe_screen *
89 pipe_r300_create_screen(int fd)
90 {
91 #if _EGL_PIPE_R300
92 struct radeon_winsys *sws;
93 struct pipe_screen *screen;
94
95 sws = radeon_drm_winsys_create(fd);
96 if (!sws)
97 return NULL;
98
99 screen = r300_screen_create(sws);
100 if (!screen)
101 return NULL;
102
103 screen = debug_screen_wrap(screen);
104
105 return screen;
106 #else
107 return NULL;
108 #endif
109 }
110
111 static struct pipe_screen *
112 pipe_r600_create_screen(int fd)
113 {
114 #if _EGL_PIPE_R600
115 struct radeon_winsys *rw;
116 struct pipe_screen *screen;
117
118 rw = radeon_drm_winsys_create(fd);
119 if (!rw)
120 return NULL;
121
122 screen = r600_screen_create(rw);
123 if (!screen)
124 return NULL;
125
126 screen = debug_screen_wrap(screen);
127
128 return screen;
129 #else
130 return NULL;
131 #endif
132 }
133
134 static struct pipe_screen *
135 pipe_vmwgfx_create_screen(int fd)
136 {
137 #if _EGL_PIPE_VMWGFX
138 struct svga_winsys_screen *sws;
139 struct pipe_screen *screen;
140
141 sws = svga_drm_winsys_screen_create(fd);
142 if (!sws)
143 return NULL;
144
145 screen = svga_screen_create(sws);
146 if (!screen)
147 return NULL;
148
149 screen = debug_screen_wrap(screen);
150
151 return screen;
152 #else
153 return NULL;
154 #endif
155 }
156
157 struct pipe_screen *
158 egl_pipe_create_drm_screen(const char *name, int fd)
159 {
160 if (strcmp(name, "i915") == 0)
161 return pipe_i915_create_screen(fd);
162 else if (strcmp(name, "nouveau") == 0)
163 return pipe_nouveau_create_screen(fd);
164 else if (strcmp(name, "r300") == 0)
165 return pipe_r300_create_screen(fd);
166 else if (strcmp(name, "r600") == 0)
167 return pipe_r600_create_screen(fd);
168 else if (strcmp(name, "vmwgfx") == 0)
169 return pipe_vmwgfx_create_screen(fd);
170 else
171 return NULL;
172 }
173
174 struct pipe_screen *
175 egl_pipe_create_swrast_screen(struct sw_winsys *ws)
176 {
177 struct pipe_screen *screen;
178
179 screen = sw_screen_create(ws);
180 if (screen)
181 screen = debug_screen_wrap(screen);
182
183 return screen;
184 }