830c0abcb7f6d17b96fde35cbc9fc1ae5c2a8b01
[mesa.git] / src / gallium / auxiliary / target-helpers / drm_helper.h
1 #ifndef DRM_HELPER_H
2 #define DRM_HELPER_H
3
4 #include <stdio.h>
5 #include "target-helpers/inline_debug_helper.h"
6 #include "target-helpers/drm_helper_public.h"
7 #include "state_tracker/drm_driver.h"
8 #include "util/xmlpool.h"
9
10 #ifdef GALLIUM_I915
11 #include "i915/drm/i915_drm_public.h"
12 #include "i915/i915_public.h"
13
14 struct pipe_screen *
15 pipe_i915_create_screen(int fd, const struct pipe_screen_config *config)
16 {
17 struct i915_winsys *iws;
18 struct pipe_screen *screen;
19
20 iws = i915_drm_winsys_create(fd);
21 if (!iws)
22 return NULL;
23
24 screen = i915_screen_create(iws);
25 return screen ? debug_screen_wrap(screen) : NULL;
26 }
27
28 #else
29
30 struct pipe_screen *
31 pipe_i915_create_screen(int fd, const struct pipe_screen_config *config)
32 {
33 fprintf(stderr, "i915g: driver missing\n");
34 return NULL;
35 }
36
37 #endif
38
39 #ifdef GALLIUM_IRIS
40 #include "iris/drm/iris_drm_public.h"
41
42 struct pipe_screen *
43 pipe_iris_create_screen(int fd, const struct pipe_screen_config *config)
44 {
45 struct pipe_screen *screen;
46
47 screen = iris_drm_screen_create(fd, config);
48 return screen ? debug_screen_wrap(screen) : NULL;
49 }
50
51 const char *iris_driconf_xml =
52 #include "iris/iris_driinfo.h"
53 ;
54
55 #else
56
57 struct pipe_screen *
58 pipe_iris_create_screen(int fd, const struct pipe_screen_config *config)
59 {
60 fprintf(stderr, "iris: driver missing\n");
61 return NULL;
62 }
63
64 const char *iris_driconf_xml = NULL;
65
66 #endif
67
68 #ifdef GALLIUM_NOUVEAU
69 #include "nouveau/drm/nouveau_drm_public.h"
70
71 struct pipe_screen *
72 pipe_nouveau_create_screen(int fd, const struct pipe_screen_config *config)
73 {
74 struct pipe_screen *screen;
75
76 screen = nouveau_drm_screen_create(fd);
77 return screen ? debug_screen_wrap(screen) : NULL;
78 }
79
80 #else
81
82 struct pipe_screen *
83 pipe_nouveau_create_screen(int fd, const struct pipe_screen_config *config)
84 {
85 fprintf(stderr, "nouveau: driver missing\n");
86 return NULL;
87 }
88
89 #endif
90
91 #ifdef GALLIUM_KMSRO
92 #include "kmsro/drm/kmsro_drm_public.h"
93
94 struct pipe_screen *
95 pipe_kmsro_create_screen(int fd, const struct pipe_screen_config *config)
96 {
97 struct pipe_screen *screen;
98
99 screen = kmsro_drm_screen_create(fd);
100 return screen ? debug_screen_wrap(screen) : NULL;
101 }
102
103 #else
104
105 struct pipe_screen *
106 pipe_kmsro_create_screen(int fd, const struct pipe_screen_config *config)
107 {
108 return NULL;
109 }
110
111 #endif
112
113 #ifdef GALLIUM_R300
114 #include "radeon/radeon_winsys.h"
115 #include "radeon/drm/radeon_drm_public.h"
116 #include "r300/r300_public.h"
117
118 struct pipe_screen *
119 pipe_r300_create_screen(int fd, const struct pipe_screen_config *config)
120 {
121 struct radeon_winsys *rw;
122
123 rw = radeon_drm_winsys_create(fd, config, r300_screen_create);
124 return rw ? debug_screen_wrap(rw->screen) : NULL;
125 }
126
127 #else
128
129 struct pipe_screen *
130 pipe_r300_create_screen(int fd, const struct pipe_screen_config *config)
131 {
132 fprintf(stderr, "r300: driver missing\n");
133 return NULL;
134 }
135
136 #endif
137
138 #ifdef GALLIUM_R600
139 #include "radeon/radeon_winsys.h"
140 #include "radeon/drm/radeon_drm_public.h"
141 #include "r600/r600_public.h"
142
143 struct pipe_screen *
144 pipe_r600_create_screen(int fd, const struct pipe_screen_config *config)
145 {
146 struct radeon_winsys *rw;
147
148 rw = radeon_drm_winsys_create(fd, config, r600_screen_create);
149 return rw ? debug_screen_wrap(rw->screen) : NULL;
150 }
151
152 #else
153
154 struct pipe_screen *
155 pipe_r600_create_screen(int fd, const struct pipe_screen_config *config)
156 {
157 fprintf(stderr, "r600: driver missing\n");
158 return NULL;
159 }
160
161 #endif
162
163 #ifdef GALLIUM_RADEONSI
164 #include "radeon/radeon_winsys.h"
165 #include "radeon/drm/radeon_drm_public.h"
166 #include "amdgpu/drm/amdgpu_public.h"
167 #include "radeonsi/si_public.h"
168
169 struct pipe_screen *
170 pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config)
171 {
172 struct radeon_winsys *rw;
173
174 /* First, try amdgpu. */
175 rw = amdgpu_winsys_create(fd, config, radeonsi_screen_create);
176
177 if (!rw)
178 rw = radeon_drm_winsys_create(fd, config, radeonsi_screen_create);
179
180 return rw ? debug_screen_wrap(rw->screen) : NULL;
181 }
182
183 const char *radeonsi_driconf_xml =
184 #include "radeonsi/si_driinfo.h"
185 ;
186
187 #else
188
189 struct pipe_screen *
190 pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config)
191 {
192 fprintf(stderr, "radeonsi: driver missing\n");
193 return NULL;
194 }
195
196 const char *radeonsi_driconf_xml = NULL;
197
198 #endif
199
200 #ifdef GALLIUM_VMWGFX
201 #include "svga/drm/svga_drm_public.h"
202 #include "svga/svga_public.h"
203
204 struct pipe_screen *
205 pipe_vmwgfx_create_screen(int fd, const struct pipe_screen_config *config)
206 {
207 struct svga_winsys_screen *sws;
208 struct pipe_screen *screen;
209
210 sws = svga_drm_winsys_screen_create(fd);
211 if (!sws)
212 return NULL;
213
214 screen = svga_screen_create(sws);
215 return screen ? debug_screen_wrap(screen) : NULL;
216 }
217
218 #else
219
220 struct pipe_screen *
221 pipe_vmwgfx_create_screen(int fd, const struct pipe_screen_config *config)
222 {
223 fprintf(stderr, "svga: driver missing\n");
224 return NULL;
225 }
226
227 #endif
228
229 #ifdef GALLIUM_FREEDRENO
230 #include "freedreno/drm/freedreno_drm_public.h"
231
232 struct pipe_screen *
233 pipe_freedreno_create_screen(int fd, const struct pipe_screen_config *config)
234 {
235 struct pipe_screen *screen;
236
237 screen = fd_drm_screen_create(fd, NULL);
238 return screen ? debug_screen_wrap(screen) : NULL;
239 }
240
241 #else
242
243 struct pipe_screen *
244 pipe_freedreno_create_screen(int fd, const struct pipe_screen_config *config)
245 {
246 fprintf(stderr, "freedreno: driver missing\n");
247 return NULL;
248 }
249
250 #endif
251
252 #ifdef GALLIUM_VIRGL
253 #include "virgl/drm/virgl_drm_public.h"
254 #include "virgl/virgl_public.h"
255
256 struct pipe_screen *
257 pipe_virgl_create_screen(int fd, const struct pipe_screen_config *config)
258 {
259 struct pipe_screen *screen;
260
261 screen = virgl_drm_screen_create(fd);
262 return screen ? debug_screen_wrap(screen) : NULL;
263 }
264
265 #else
266
267 struct pipe_screen *
268 pipe_virgl_create_screen(int fd, const struct pipe_screen_config *config)
269 {
270 fprintf(stderr, "virgl: driver missing\n");
271 return NULL;
272 }
273
274 #endif
275
276 #ifdef GALLIUM_VC4
277 #include "vc4/drm/vc4_drm_public.h"
278
279 struct pipe_screen *
280 pipe_vc4_create_screen(int fd, const struct pipe_screen_config *config)
281 {
282 struct pipe_screen *screen;
283
284 screen = vc4_drm_screen_create(fd);
285 return screen ? debug_screen_wrap(screen) : NULL;
286 }
287
288 #else
289
290 struct pipe_screen *
291 pipe_vc4_create_screen(int fd, const struct pipe_screen_config *config)
292 {
293 fprintf(stderr, "vc4: driver missing\n");
294 return NULL;
295 }
296
297 #endif
298
299 #ifdef GALLIUM_V3D
300 #include "v3d/drm/v3d_drm_public.h"
301
302 struct pipe_screen *
303 pipe_v3d_create_screen(int fd, const struct pipe_screen_config *config)
304 {
305 struct pipe_screen *screen;
306
307 screen = v3d_drm_screen_create(fd);
308 return screen ? debug_screen_wrap(screen) : NULL;
309 }
310
311 #else
312
313 struct pipe_screen *
314 pipe_v3d_create_screen(int fd, const struct pipe_screen_config *config)
315 {
316 fprintf(stderr, "v3d: driver missing\n");
317 return NULL;
318 }
319
320 #endif
321
322 #ifdef GALLIUM_PANFROST
323 #include "panfrost/drm/panfrost_drm_public.h"
324
325 struct pipe_screen *
326 pipe_panfrost_create_screen(int fd, const struct pipe_screen_config *config)
327 {
328 struct pipe_screen *screen;
329
330 screen = panfrost_drm_screen_create(fd);
331 return screen ? debug_screen_wrap(screen) : NULL;
332 }
333
334 #else
335
336 struct pipe_screen *
337 pipe_panfrost_create_screen(int fd, const struct pipe_screen_config *config)
338 {
339 fprintf(stderr, "panfrost: driver missing\n");
340 return NULL;
341 }
342
343 #endif
344
345 #ifdef GALLIUM_ETNAVIV
346 #include "etnaviv/drm/etnaviv_drm_public.h"
347
348 struct pipe_screen *
349 pipe_etna_create_screen(int fd, const struct pipe_screen_config *config)
350 {
351 struct pipe_screen *screen;
352
353 screen = etna_drm_screen_create(fd);
354 return screen ? debug_screen_wrap(screen) : NULL;
355 }
356
357 #else
358
359 struct pipe_screen *
360 pipe_etna_create_screen(int fd, const struct pipe_screen_config *config)
361 {
362 fprintf(stderr, "etnaviv: driver missing\n");
363 return NULL;
364 }
365
366 #endif
367
368 #ifdef GALLIUM_TEGRA
369 #include "tegra/drm/tegra_drm_public.h"
370
371 struct pipe_screen *
372 pipe_tegra_create_screen(int fd, const struct pipe_screen_config *config)
373 {
374 struct pipe_screen *screen;
375
376 screen = tegra_drm_screen_create(fd);
377
378 return screen ? debug_screen_wrap(screen) : NULL;
379 }
380
381 #else
382
383 struct pipe_screen *
384 pipe_tegra_create_screen(int fd, const struct pipe_screen_config *config)
385 {
386 fprintf(stderr, "tegra: driver missing\n");
387 return NULL;
388 }
389
390 #endif
391
392 #ifdef GALLIUM_LIMA
393 #include "lima/drm/lima_drm_public.h"
394
395 struct pipe_screen *
396 pipe_lima_create_screen(int fd, const struct pipe_screen_config *config)
397 {
398 struct pipe_screen *screen;
399
400 screen = lima_drm_screen_create(fd);
401 return screen ? debug_screen_wrap(screen) : NULL;
402 }
403
404 #else
405
406 struct pipe_screen *
407 pipe_lima_create_screen(int fd, const struct pipe_screen_config *config)
408 {
409 fprintf(stderr, "lima: driver missing\n");
410 return NULL;
411 }
412
413 #endif
414
415 #endif /* DRM_HELPER_H */