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 static const struct drm_conf_ret throttle_ret = {
11 .type = DRM_CONF_INT,
12 .val.val_int = 2,
13 };
14
15 static const struct drm_conf_ret share_fd_ret = {
16 .type = DRM_CONF_BOOL,
17 .val.val_bool = true,
18 };
19
20 const struct drm_conf_ret *
pipe_default_configuration_query(enum drm_conf conf)21 pipe_default_configuration_query(enum drm_conf conf)
22 {
23 switch (conf) {
24 case DRM_CONF_THROTTLE:
25 return &throttle_ret;
26 case DRM_CONF_SHARE_FD:
27 return &share_fd_ret;
28 default:
29 break;
30 }
31 return NULL;
32 }
33
34 #ifdef GALLIUM_I915
35 #include "i915/drm/i915_drm_public.h"
36 #include "i915/i915_public.h"
37
38 struct pipe_screen *
pipe_i915_create_screen(int fd,const struct pipe_screen_config * config)39 pipe_i915_create_screen(int fd, const struct pipe_screen_config *config)
40 {
41 struct i915_winsys *iws;
42 struct pipe_screen *screen;
43
44 iws = i915_drm_winsys_create(fd);
45 if (!iws)
46 return NULL;
47
48 screen = i915_screen_create(iws);
49 return screen ? debug_screen_wrap(screen) : NULL;
50 }
51
52 #else
53
54 struct pipe_screen *
pipe_i915_create_screen(int fd,const struct pipe_screen_config * config)55 pipe_i915_create_screen(int fd, const struct pipe_screen_config *config)
56 {
57 fprintf(stderr, "i915g: driver missing\n");
58 return NULL;
59 }
60
61 #endif
62
63 #ifdef GALLIUM_NOUVEAU
64 #include "nouveau/drm/nouveau_drm_public.h"
65
66 struct pipe_screen *
pipe_nouveau_create_screen(int fd,const struct pipe_screen_config * config)67 pipe_nouveau_create_screen(int fd, const struct pipe_screen_config *config)
68 {
69 struct pipe_screen *screen;
70
71 screen = nouveau_drm_screen_create(fd);
72 return screen ? debug_screen_wrap(screen) : NULL;
73 }
74
75 #else
76
77 struct pipe_screen *
pipe_nouveau_create_screen(int fd,const struct pipe_screen_config * config)78 pipe_nouveau_create_screen(int fd, const struct pipe_screen_config *config)
79 {
80 fprintf(stderr, "nouveau: driver missing\n");
81 return NULL;
82 }
83
84 #endif
85
86 #ifdef GALLIUM_PL111
87 #include "pl111/drm/pl111_drm_public.h"
88
89 struct pipe_screen *
pipe_pl111_create_screen(int fd,const struct pipe_screen_config * config)90 pipe_pl111_create_screen(int fd, const struct pipe_screen_config *config)
91 {
92 struct pipe_screen *screen;
93
94 screen = pl111_drm_screen_create(fd);
95 return screen ? debug_screen_wrap(screen) : NULL;
96 }
97
98 #else
99
100 struct pipe_screen *
pipe_pl111_create_screen(int fd,const struct pipe_screen_config * config)101 pipe_pl111_create_screen(int fd, const struct pipe_screen_config *config)
102 {
103 fprintf(stderr, "pl111: driver missing\n");
104 return NULL;
105 }
106
107 #endif
108
109 #ifdef GALLIUM_R300
110 #include "radeon/radeon_winsys.h"
111 #include "radeon/drm/radeon_drm_public.h"
112 #include "r300/r300_public.h"
113
114 struct pipe_screen *
pipe_r300_create_screen(int fd,const struct pipe_screen_config * config)115 pipe_r300_create_screen(int fd, const struct pipe_screen_config *config)
116 {
117 struct radeon_winsys *rw;
118
119 rw = radeon_drm_winsys_create(fd, config, r300_screen_create);
120 return rw ? debug_screen_wrap(rw->screen) : NULL;
121 }
122
123 #else
124
125 struct pipe_screen *
pipe_r300_create_screen(int fd,const struct pipe_screen_config * config)126 pipe_r300_create_screen(int fd, const struct pipe_screen_config *config)
127 {
128 fprintf(stderr, "r300: driver missing\n");
129 return NULL;
130 }
131
132 #endif
133
134 #ifdef GALLIUM_R600
135 #include "radeon/radeon_winsys.h"
136 #include "radeon/drm/radeon_drm_public.h"
137 #include "r600/r600_public.h"
138
139 struct pipe_screen *
pipe_r600_create_screen(int fd,const struct pipe_screen_config * config)140 pipe_r600_create_screen(int fd, const struct pipe_screen_config *config)
141 {
142 struct radeon_winsys *rw;
143
144 rw = radeon_drm_winsys_create(fd, config, r600_screen_create);
145 return rw ? debug_screen_wrap(rw->screen) : NULL;
146 }
147
148 #else
149
150 struct pipe_screen *
pipe_r600_create_screen(int fd,const struct pipe_screen_config * config)151 pipe_r600_create_screen(int fd, const struct pipe_screen_config *config)
152 {
153 fprintf(stderr, "r600: driver missing\n");
154 return NULL;
155 }
156
157 #endif
158
159 #ifdef GALLIUM_RADEONSI
160 #include "radeon/radeon_winsys.h"
161 #include "radeon/drm/radeon_drm_public.h"
162 #include "amdgpu/drm/amdgpu_public.h"
163 #include "radeonsi/si_public.h"
164
165 struct pipe_screen *
pipe_radeonsi_create_screen(int fd,const struct pipe_screen_config * config)166 pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config)
167 {
168 struct radeon_winsys *rw;
169
170 /* First, try amdgpu. */
171 rw = amdgpu_winsys_create(fd, config, radeonsi_screen_create);
172
173 if (!rw)
174 rw = radeon_drm_winsys_create(fd, config, radeonsi_screen_create);
175
176 return rw ? debug_screen_wrap(rw->screen) : NULL;
177 }
178
179 const struct drm_conf_ret *
pipe_radeonsi_configuration_query(enum drm_conf conf)180 pipe_radeonsi_configuration_query(enum drm_conf conf)
181 {
182 static const struct drm_conf_ret xml_options_ret = {
183 .type = DRM_CONF_POINTER,
184 .val.val_pointer =
185 #include "radeonsi/si_driinfo.h"
186 };
187
188 switch (conf) {
189 case DRM_CONF_XML_OPTIONS:
190 return &xml_options_ret;
191 default:
192 break;
193 }
194 return pipe_default_configuration_query(conf);
195 }
196
197 #else
198
199 struct pipe_screen *
pipe_radeonsi_create_screen(int fd,const struct pipe_screen_config * config)200 pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config)
201 {
202 fprintf(stderr, "radeonsi: driver missing\n");
203 return NULL;
204 }
205
206 const struct drm_conf_ret *
pipe_radeonsi_configuration_query(enum drm_conf conf)207 pipe_radeonsi_configuration_query(enum drm_conf conf)
208 {
209 return NULL;
210 }
211
212 #endif
213
214 #ifdef GALLIUM_VMWGFX
215 #include "svga/drm/svga_drm_public.h"
216 #include "svga/svga_public.h"
217
218 struct pipe_screen *
pipe_vmwgfx_create_screen(int fd,const struct pipe_screen_config * config)219 pipe_vmwgfx_create_screen(int fd, const struct pipe_screen_config *config)
220 {
221 struct svga_winsys_screen *sws;
222 struct pipe_screen *screen;
223
224 sws = svga_drm_winsys_screen_create(fd);
225 if (!sws)
226 return NULL;
227
228 screen = svga_screen_create(sws);
229 return screen ? debug_screen_wrap(screen) : NULL;
230 }
231
232 #else
233
234 struct pipe_screen *
pipe_vmwgfx_create_screen(int fd,const struct pipe_screen_config * config)235 pipe_vmwgfx_create_screen(int fd, const struct pipe_screen_config *config)
236 {
237 fprintf(stderr, "svga: driver missing\n");
238 return NULL;
239 }
240
241 #endif
242
243 #ifdef GALLIUM_FREEDRENO
244 #include "freedreno/drm/freedreno_drm_public.h"
245
246 struct pipe_screen *
pipe_freedreno_create_screen(int fd,const struct pipe_screen_config * config)247 pipe_freedreno_create_screen(int fd, const struct pipe_screen_config *config)
248 {
249 struct pipe_screen *screen;
250
251 screen = fd_drm_screen_create(fd);
252 return screen ? debug_screen_wrap(screen) : NULL;
253 }
254
255 #else
256
257 struct pipe_screen *
pipe_freedreno_create_screen(int fd,const struct pipe_screen_config * config)258 pipe_freedreno_create_screen(int fd, const struct pipe_screen_config *config)
259 {
260 fprintf(stderr, "freedreno: driver missing\n");
261 return NULL;
262 }
263
264 #endif
265
266 #ifdef GALLIUM_VIRGL
267 #include "virgl/drm/virgl_drm_public.h"
268 #include "virgl/virgl_public.h"
269
270 struct pipe_screen *
pipe_virgl_create_screen(int fd,const struct pipe_screen_config * config)271 pipe_virgl_create_screen(int fd, const struct pipe_screen_config *config)
272 {
273 struct pipe_screen *screen;
274
275 screen = virgl_drm_screen_create(fd);
276 return screen ? debug_screen_wrap(screen) : NULL;
277 }
278
279 #else
280
281 struct pipe_screen *
pipe_virgl_create_screen(int fd,const struct pipe_screen_config * config)282 pipe_virgl_create_screen(int fd, const struct pipe_screen_config *config)
283 {
284 fprintf(stderr, "virgl: driver missing\n");
285 return NULL;
286 }
287
288 #endif
289
290 #ifdef GALLIUM_VC4
291 #include "vc4/drm/vc4_drm_public.h"
292
293 struct pipe_screen *
pipe_vc4_create_screen(int fd,const struct pipe_screen_config * config)294 pipe_vc4_create_screen(int fd, const struct pipe_screen_config *config)
295 {
296 struct pipe_screen *screen;
297
298 screen = vc4_drm_screen_create(fd);
299 return screen ? debug_screen_wrap(screen) : NULL;
300 }
301
302 #else
303
304 struct pipe_screen *
pipe_vc4_create_screen(int fd,const struct pipe_screen_config * config)305 pipe_vc4_create_screen(int fd, const struct pipe_screen_config *config)
306 {
307 fprintf(stderr, "vc4: driver missing\n");
308 return NULL;
309 }
310
311 #endif
312
313 #ifdef GALLIUM_VC5
314 #include "vc5/drm/vc5_drm_public.h"
315
316 struct pipe_screen *
pipe_vc5_create_screen(int fd,const struct pipe_screen_config * config)317 pipe_vc5_create_screen(int fd, const struct pipe_screen_config *config)
318 {
319 struct pipe_screen *screen;
320
321 screen = vc5_drm_screen_create(fd);
322 return screen ? debug_screen_wrap(screen) : NULL;
323 }
324
325 #else
326
327 struct pipe_screen *
pipe_vc5_create_screen(int fd,const struct pipe_screen_config * config)328 pipe_vc5_create_screen(int fd, const struct pipe_screen_config *config)
329 {
330 fprintf(stderr, "vc5: driver missing\n");
331 return NULL;
332 }
333
334 #endif
335
336 #ifdef GALLIUM_ETNAVIV
337 #include "etnaviv/drm/etnaviv_drm_public.h"
338
339 struct pipe_screen *
pipe_etna_create_screen(int fd,const struct pipe_screen_config * config)340 pipe_etna_create_screen(int fd, const struct pipe_screen_config *config)
341 {
342 struct pipe_screen *screen;
343
344 screen = etna_drm_screen_create(fd);
345 return screen ? debug_screen_wrap(screen) : NULL;
346 }
347
348 #else
349
350 struct pipe_screen *
pipe_etna_create_screen(int fd,const struct pipe_screen_config * config)351 pipe_etna_create_screen(int fd, const struct pipe_screen_config *config)
352 {
353 fprintf(stderr, "etnaviv: driver missing\n");
354 return NULL;
355 }
356
357 #endif
358
359 #ifdef GALLIUM_IMX
360 #include "imx/drm/imx_drm_public.h"
361
362 struct pipe_screen *
pipe_imx_drm_create_screen(int fd,const struct pipe_screen_config * config)363 pipe_imx_drm_create_screen(int fd, const struct pipe_screen_config *config)
364 {
365 struct pipe_screen *screen;
366
367 screen = imx_drm_screen_create(fd);
368 return screen ? debug_screen_wrap(screen) : NULL;
369 }
370
371 #else
372
373 struct pipe_screen *
pipe_imx_drm_create_screen(int fd,const struct pipe_screen_config * config)374 pipe_imx_drm_create_screen(int fd, const struct pipe_screen_config *config)
375 {
376 fprintf(stderr, "imx-drm: driver missing\n");
377 return NULL;
378 }
379
380 #endif
381
382
383 #endif /* DRM_HELPER_H */
384