Debian Codegraph @

src/gallium/auxiliary/target-helpers/drm_helper.h

raw symbols SCIP
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 "frontend/drm_driver.h"
8 #include "util/driconf.h"
9
10 /**
11 * Instantiate a drm_driver_descriptor struct.
12 */
13 #define DEFINE_DRM_DRIVER_DESCRIPTOR(descriptor_name, driver, _driconf, _driconf_count, func, ...) \
14 const struct drm_driver_descriptor descriptor_name = { \
15 .driver_name = #driver, \
16 .driconf = _driconf, \
17 .driconf_count = _driconf_count, \
18 .create_screen = func, \
19 ##__VA_ARGS__ \
20 };
21
22 /* The pipe loader refers to the *_driver_descriptor structs for all
23 * drivers, regardless of whether they are configured in this Mesa build, or
24 * whether they're included in the specific gallium target. The target (dri,
25 * vdpau, etc.) will include this header with the #defines for the specific
26 * drivers it's including, and the disabled drivers will have a descriptor
27 * with a stub create function logging the failure.
28 */
29
30 #define DRM_DRIVER_DESCRIPTOR(driver, driconf, driconf_count, ...) \
31 DEFINE_DRM_DRIVER_DESCRIPTOR(driver##_driver_descriptor, driver, driconf, driconf_count, pipe_##driver##_create_screen, __VA_ARGS__)
32
33 #define DRM_DRIVER_DESCRIPTOR_STUB(driver) \
34 static struct pipe_screen * \
35 pipe_##driver##_create_screen(int fd, const struct pipe_screen_config *config) \
36 { \
37 fprintf(stderr, #driver ": driver missing\n"); \
38 return NULL; \
39 } \
40 DRM_DRIVER_DESCRIPTOR(driver, NULL, 0)
41
42 #define DRM_DRIVER_DESCRIPTOR_ALIAS(driver, alias, driconf, driconf_count) \
43 DEFINE_DRM_DRIVER_DESCRIPTOR(alias##_driver_descriptor, alias, driconf, \
44 driconf_count, pipe_##driver##_create_screen, NULL)
45
46 #ifdef GALLIUM_KMSRO_ONLY
47 #undef GALLIUM_V3D
48 #undef GALLIUM_VC4
49 #undef GALLIUM_FREEDRENO
50 #undef GALLIUM_ETNAVIV
51 #undef GALLIUM_PANFROST
52 #undef GALLIUM_LIMA
53 #undef GALLIUM_ASAHI
54 #undef GALLIUM_ROCKET
55 #undef GALLIUM_ETHOSU
56 #endif
57
58 #ifdef GALLIUM_I915
59 #include "i915/drm/i915_drm_public.h"
60 #include "i915/i915_public.h"
61
62 static struct pipe_screen *
63 pipe_i915_create_screen(int fd, const struct pipe_screen_config *config)
64 {
65 struct i915_winsys *iws;
66 struct pipe_screen *screen;
67
68 iws = i915_drm_winsys_create(fd);
69 if (!iws)
70 return NULL;
71
72 screen = i915_screen_create(iws);
73 return screen ? debug_screen_wrap(screen) : NULL;
74 }
75 DRM_DRIVER_DESCRIPTOR(i915, NULL, 0)
76 #else
77 DRM_DRIVER_DESCRIPTOR_STUB(i915)
78 #endif
79
80 #ifdef GALLIUM_IRIS
81 #include "iris/drm/iris_drm_public.h"
82
83 static struct pipe_screen *
84 pipe_iris_create_screen(int fd, const struct pipe_screen_config *config)
85 {
86 struct pipe_screen *screen;
87
88 screen = iris_drm_screen_create(fd, config);
89 return screen ? debug_screen_wrap(screen) : NULL;
90 }
91
92 const driOptionDescription iris_driconf[] = {
93 #include "iris/driinfo_iris.h"
94 };
95 DRM_DRIVER_DESCRIPTOR(iris, iris_driconf, ARRAY_SIZE(iris_driconf),
96 .probe_nctx = iris_drm_probe_nctx)
97
98 #else
99 DRM_DRIVER_DESCRIPTOR_STUB(iris)
100 #endif
101
102 #ifdef GALLIUM_CROCUS
103 #include "crocus/drm/crocus_drm_public.h"
104
105 static struct pipe_screen *
106 pipe_crocus_create_screen(int fd, const struct pipe_screen_config *config)
107 {
108 struct pipe_screen *screen;
109
110 screen = crocus_drm_screen_create(fd, config);
111 return screen ? debug_screen_wrap(screen) : NULL;
112 }
113
114 const driOptionDescription crocus_driconf[] = {
115 #include "crocus/driinfo_crocus.h"
116 };
117 DRM_DRIVER_DESCRIPTOR(crocus, crocus_driconf, ARRAY_SIZE(crocus_driconf),
118 .probe_nctx = crocus_drm_probe_nctx)
119 #else
120 DRM_DRIVER_DESCRIPTOR_STUB(crocus)
121 #endif
122
123 #ifdef GALLIUM_NOUVEAU
124 #include "nouveau/drm/nouveau_drm_public.h"
125
126 static struct pipe_screen *
127 pipe_nouveau_create_screen(int fd, const struct pipe_screen_config *config)
128 {
129 struct pipe_screen *screen;
130
131 screen = nouveau_drm_screen_create(fd);
132 return screen ? debug_screen_wrap(screen) : NULL;
133 }
134 DRM_DRIVER_DESCRIPTOR(nouveau, NULL, 0)
135
136 #else
137 DRM_DRIVER_DESCRIPTOR_STUB(nouveau)
138 #endif
139
140 #if defined(GALLIUM_VC4) || defined(GALLIUM_V3D)
141 const driOptionDescription v3d_driconf[] = {
142 #include "v3d/driinfo_v3d.h"
143 };
144 #endif
145
146 #ifdef GALLIUM_R300
147 #include "winsys/radeon_winsys.h"
148 #include "r300/r300_public.h"
149
150 static struct pipe_screen *
151 pipe_r300_create_screen(int fd, const struct pipe_screen_config *config)
152 {
153 struct radeon_winsys *rw;
154
155 rw = radeon_drm_winsys_create(fd, config, r300_screen_create);
156 return rw ? debug_screen_wrap(rw->screen) : NULL;
157 }
158 const driOptionDescription r300_driconf[] = {
159 #include "r300/driinfo_r300.h"
160 };
161 DRM_DRIVER_DESCRIPTOR(r300, r300_driconf, ARRAY_SIZE(r300_driconf))
162
163 #else
164 DRM_DRIVER_DESCRIPTOR_STUB(r300)
165 #endif
166
167 #ifdef GALLIUM_R600
168 #include "winsys/radeon_winsys.h"
169 #include "r600/r600_public.h"
170
171 static struct pipe_screen *
172 pipe_r600_create_screen(int fd, const struct pipe_screen_config *config)
173 {
174 struct radeon_winsys *rw;
175
176 rw = radeon_drm_winsys_create(fd, config, r600_screen_create);
177 return rw ? debug_screen_wrap(rw->screen) : NULL;
178 }
179 DRM_DRIVER_DESCRIPTOR(r600, NULL, 0)
180
181 #else
182 DRM_DRIVER_DESCRIPTOR_STUB(r600)
183 #endif
184
185 #ifdef GALLIUM_RADEONSI
186 #include "radeonsi/si_public.h"
187
188 static struct pipe_screen *
189 pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config)
190 {
191 struct pipe_screen *screen = radeonsi_screen_create(fd, config);
192
193 return screen ? debug_screen_wrap(screen) : NULL;
194 }
195
196 const driOptionDescription radeonsi_driconf[] = {
197 #include "radeonsi/driinfo_radeonsi.h"
198 };
199 DRM_DRIVER_DESCRIPTOR(radeonsi, radeonsi_driconf, ARRAY_SIZE(radeonsi_driconf),
200 .probe_nctx = si_virtgpu_probe_nctx)
201 #else
202 DRM_DRIVER_DESCRIPTOR_STUB(radeonsi)
203 #endif
204
205 #ifdef GALLIUM_VMWGFX
206 #include "svga/drm/svga_drm_public.h"
207 #include "svga/svga_public.h"
208
209 static struct pipe_screen *
210 pipe_vmwgfx_create_screen(int fd, const struct pipe_screen_config *config)
211 {
212 struct svga_winsys_screen *sws;
213 struct pipe_screen *screen;
214
215 sws = svga_drm_winsys_screen_create(fd);
216 if (!sws)
217 return NULL;
218
219 screen = svga_screen_create(sws);
220 return screen ? debug_screen_wrap(screen) : NULL;
221 }
222 DRM_DRIVER_DESCRIPTOR(vmwgfx, NULL, 0)
223
224 #else
225 DRM_DRIVER_DESCRIPTOR_STUB(vmwgfx)
226 #endif
227
228 #ifdef GALLIUM_FREEDRENO
229 #include "freedreno/drm/freedreno_drm_public.h"
230
231 static struct pipe_screen *
232 pipe_msm_create_screen(int fd, const struct pipe_screen_config *config)
233 {
234 struct pipe_screen *screen;
235
236 screen = fd_drm_screen_create_renderonly(fd, NULL, config);
237 return screen ? debug_screen_wrap(screen) : NULL;
238 }
239
240 static bool
241 pipe_msm_probe_nctx(int fd, const struct virgl_renderer_capset_drm *caps)
242 {
243 return fd_drm_probe_nctx(fd, caps);
244 }
245
246 const driOptionDescription msm_driconf[] = {
247 #ifdef GALLIUM_FREEDRENO
248 #include "freedreno/driinfo_freedreno.h"
249 #endif
250 };
251 DRM_DRIVER_DESCRIPTOR(msm, msm_driconf, ARRAY_SIZE(msm_driconf),
252 .probe_nctx = pipe_msm_probe_nctx)
253 DRM_DRIVER_DESCRIPTOR_ALIAS(msm, kgsl, msm_driconf, ARRAY_SIZE(msm_driconf))
254 #else
255 DRM_DRIVER_DESCRIPTOR_STUB(msm)
256 DRM_DRIVER_DESCRIPTOR_STUB(kgsl)
257 #endif
258
259 #if defined(GALLIUM_VIRGL)
260 #include "virgl/drm/virgl_drm_public.h"
261 #include "virgl/virgl_public.h"
262
263 static struct pipe_screen *
264 pipe_virtio_gpu_create_screen(int fd, const struct pipe_screen_config *config)
265 {
266 struct pipe_screen *screen = NULL;
267
268 if (!screen)
269 screen = virgl_drm_screen_create(fd, config);
270
271 return screen ? debug_screen_wrap(screen) : NULL;
272 }
273
274 const driOptionDescription virgl_driconf[] = {
275 #include "virgl/virgl_driinfo.h.in"
276 };
277 DRM_DRIVER_DESCRIPTOR(virtio_gpu, virgl_driconf, ARRAY_SIZE(virgl_driconf))
278
279 #else
280 DRM_DRIVER_DESCRIPTOR_STUB(virtio_gpu)
281 #endif
282
283 #ifdef GALLIUM_VC4
284 #include "vc4/drm/vc4_drm_public.h"
285
286 static struct pipe_screen *
287 pipe_vc4_create_screen(int fd, const struct pipe_screen_config *config)
288 {
289 struct pipe_screen *screen;
290
291 screen = vc4_drm_screen_create(fd, config);
292 return screen ? debug_screen_wrap(screen) : NULL;
293 }
294 DRM_DRIVER_DESCRIPTOR(vc4, v3d_driconf, ARRAY_SIZE(v3d_driconf))
295 #else
296 DRM_DRIVER_DESCRIPTOR_STUB(vc4)
297 #endif
298
299 #ifdef GALLIUM_V3D
300 #include "v3d/drm/v3d_drm_public.h"
301
302 static 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, config);
308 return screen ? debug_screen_wrap(screen) : NULL;
309 }
310
311 DRM_DRIVER_DESCRIPTOR(v3d, v3d_driconf, ARRAY_SIZE(v3d_driconf))
312
313 #else
314 DRM_DRIVER_DESCRIPTOR_STUB(v3d)
315 #endif
316
317 #ifdef GALLIUM_PANFROST
318 #include "panfrost/drm/panfrost_drm_public.h"
319
320 static struct pipe_screen *
321 pipe_panfrost_create_screen(int fd, const struct pipe_screen_config *config)
322 {
323 struct pipe_screen *screen;
324
325 screen = panfrost_drm_screen_create(fd, config);
326 return screen ? debug_screen_wrap(screen) : NULL;
327 }
328
329 const driOptionDescription pan_driconf[] = {
330 #include "panfrost/driinfo_panfrost.h"
331 };
332 DRM_DRIVER_DESCRIPTOR(panfrost, pan_driconf, ARRAY_SIZE(pan_driconf))
333 DRM_DRIVER_DESCRIPTOR_ALIAS(panfrost, panthor, pan_driconf, ARRAY_SIZE(pan_driconf))
334
335 #else
336 DRM_DRIVER_DESCRIPTOR_STUB(panfrost)
337 DRM_DRIVER_DESCRIPTOR_STUB(panthor)
338 #endif
339
340 #ifdef GALLIUM_ASAHI
341 #include "asahi/drm/asahi_drm_public.h"
342
343 static struct pipe_screen *
344 pipe_asahi_create_screen(int fd, const struct pipe_screen_config *config)
345 {
346 struct pipe_screen *screen;
347
348 screen = asahi_drm_screen_create(fd, config);
349 return screen ? debug_screen_wrap(screen) : NULL;
350 }
351
352 const driOptionDescription asahi_driconf[] = {
353 #include "asahi/driinfo_asahi.h"
354 };
355 DRM_DRIVER_DESCRIPTOR(asahi, asahi_driconf, ARRAY_SIZE(asahi_driconf))
356
357 #else
358 DRM_DRIVER_DESCRIPTOR_STUB(asahi)
359 #endif
360
361 #ifdef GALLIUM_ETNAVIV
362 #include "etnaviv/drm/etnaviv_drm_public.h"
363
364 static struct pipe_screen *
365 pipe_etnaviv_create_screen(int fd, const struct pipe_screen_config *config)
366 {
367 struct pipe_screen *screen;
368
369 screen = etna_drm_screen_create(fd);
370 return screen ? debug_screen_wrap(screen) : NULL;
371 }
372 DRM_DRIVER_DESCRIPTOR(etnaviv, NULL, 0)
373
374 #else
375 DRM_DRIVER_DESCRIPTOR_STUB(etnaviv)
376 #endif
377
378 #ifdef GALLIUM_TEGRA
379 #include "tegra/drm/tegra_drm_public.h"
380
381 static struct pipe_screen *
382 pipe_tegra_create_screen(int fd, const struct pipe_screen_config *config)
383 {
384 struct pipe_screen *screen;
385
386 screen = tegra_drm_screen_create(fd);
387
388 return screen ? debug_screen_wrap(screen) : NULL;
389 }
390 DRM_DRIVER_DESCRIPTOR(tegra, NULL, 0)
391
392 #else
393 DRM_DRIVER_DESCRIPTOR_STUB(tegra)
394 #endif
395
396 #ifdef GALLIUM_LIMA
397 #include "lima/drm/lima_drm_public.h"
398
399 static struct pipe_screen *
400 pipe_lima_create_screen(int fd, const struct pipe_screen_config *config)
401 {
402 struct pipe_screen *screen;
403
404 screen = lima_drm_screen_create(fd, config);
405 return screen ? debug_screen_wrap(screen) : NULL;
406 }
407
408 const driOptionDescription lima_driconf[] = {
409 #include "lima/driinfo_lima.h"
410 };
411 DRM_DRIVER_DESCRIPTOR(lima, lima_driconf, ARRAY_SIZE(lima_driconf))
412
413 #else
414 DRM_DRIVER_DESCRIPTOR_STUB(lima)
415 #endif
416
417 #ifdef GALLIUM_ZINK
418 #include "zink/zink_public.h"
419
420 static struct pipe_screen *
421 pipe_zink_create_screen(int fd, const struct pipe_screen_config *config)
422 {
423 struct pipe_screen *screen;
424 screen = zink_drm_create_screen(fd, config, NULL);
425 return screen ? debug_screen_wrap(screen) : NULL;
426 }
427
428 const driOptionDescription zink_driconf[] = {
429 #include "zink/driinfo_zink.h"
430 };
431 DRM_DRIVER_DESCRIPTOR(zink, zink_driconf, ARRAY_SIZE(zink_driconf))
432
433 #else
434 DRM_DRIVER_DESCRIPTOR_STUB(zink)
435 #endif
436
437 #ifdef GALLIUM_ROCKET
438 #include "rocket/drm/rkt_drm_public.h"
439
440 static struct pipe_screen *
441 pipe_rknpu_create_screen(int fd, const struct pipe_screen_config *config)
442 {
443 struct pipe_screen *screen;
444
445 screen = rkt_drm_screen_create(fd, config);
446 return screen ? debug_screen_wrap(screen) : NULL;
447 }
448
449 DRM_DRIVER_DESCRIPTOR(rknpu, NULL, 0)
450
451 static struct pipe_screen *
452 pipe_rocket_create_screen(int fd, const struct pipe_screen_config *config)
453 {
454 struct pipe_screen *screen;
455
456 screen = rkt_drm_screen_create(fd, config);
457 return screen ? debug_screen_wrap(screen) : NULL;
458 }
459
460 DRM_DRIVER_DESCRIPTOR(rocket, NULL, 0)
461
462 #else
463 DRM_DRIVER_DESCRIPTOR_STUB(rknpu)
464 DRM_DRIVER_DESCRIPTOR_STUB(rocket)
465 #endif
466
467 #ifdef GALLIUM_ETHOSU
468 #include "ethosu/drm/ethosu_drm_public.h"
469
470 static struct pipe_screen *
471 pipe_ethosu_create_screen(int fd, const struct pipe_screen_config *config)
472 {
473 struct pipe_screen *screen;
474
475 screen = ethosu_drm_screen_create(fd, config);
476 return screen ? debug_screen_wrap(screen) : NULL;
477 }
478
479 DRM_DRIVER_DESCRIPTOR(ethosu, NULL, 0)
480
481 #else
482 DRM_DRIVER_DESCRIPTOR_STUB(ethosu)
483 #endif
484
485 #ifdef GALLIUM_KMSRO
486 #include "kmsro/drm/kmsro_drm_public.h"
487
488 static struct pipe_screen *
489 pipe_kmsro_create_screen(int fd, const struct pipe_screen_config *config)
490 {
491 struct pipe_screen *screen;
492
493 screen = kmsro_drm_screen_create(fd, config);
494 return screen ? debug_screen_wrap(screen) : NULL;
495 }
496 const driOptionDescription kmsro_driconf[] = {
497 #if defined(GALLIUM_VC4) || defined(GALLIUM_V3D)
498 #include "v3d/driinfo_v3d.h"
499 #endif
500 #ifdef GALLIUM_ASAHI
501 #include "asahi/driinfo_asahi.h"
502 #endif
503 #ifdef GALLIUM_FREEDRENO
504 #include "freedreno/driinfo_freedreno.h"
505 #endif
506 #ifdef GALLIUM_PANFROST
507 #include "panfrost/driinfo_panfrost.h"
508 #endif
509 #ifdef GALLIUM_LIMA
510 #include "lima/driinfo_lima.h"
511 #endif
512 #ifdef GALLIUM_ZINK
513 #include "zink/driinfo_zink.h"
514 #endif
515 };
516 DRM_DRIVER_DESCRIPTOR(kmsro, kmsro_driconf, ARRAY_SIZE(kmsro_driconf))
517
518 #else
519 DRM_DRIVER_DESCRIPTOR_STUB(kmsro)
520 #endif
521
522 /* kmsro should be the last entry in the file. */
523
524 #endif /* DRM_HELPER_H */