1 #ifndef INLINE_DRM_HELPER_H
2 #define INLINE_DRM_HELPER_H
4 #include "state_tracker/drm_driver.h"
5 #include "target-helpers/inline_debug_helper.h"
7 #if defined(DRI_TARGET)
8 #include "dri_screen.h"
12 #include "target-helpers/inline_sw_helper.h"
13 #include "sw/kms-dri/kms_dri_sw_winsys.h"
17 #include "i915/drm/i915_drm_public.h"
18 #include "i915/i915_public.h"
22 #include "intel/drm/intel_drm_public.h"
23 #include "ilo/ilo_public.h"
27 #include "nouveau/drm/nouveau_drm_public.h"
31 #include "radeon/radeon_winsys.h"
32 #include "radeon/drm/radeon_drm_public.h"
33 #include "r300/r300_public.h"
37 #include "radeon/radeon_winsys.h"
38 #include "radeon/drm/radeon_drm_public.h"
39 #include "r600/r600_public.h"
43 #include "radeon/radeon_winsys.h"
44 #include "radeon/drm/radeon_drm_public.h"
45 #include "amdgpu/drm/amdgpu_public.h"
46 #include "radeonsi/si_public.h"
50 #include "svga/drm/svga_drm_public.h"
51 #include "svga/svga_public.h"
55 #include "freedreno/drm/freedreno_drm_public.h"
59 #include "vc4/drm/vc4_drm_public.h"
63 #include "virgl/drm/virgl_drm_public.h"
64 #include "virgl/virgl_public.h"
67 static char* driver_name
= NULL
;
69 /* XXX: We need to teardown the winsys if *screen_create() fails. */
71 #if defined(GALLIUM_SOFTPIPE)
72 #if defined(DRI_TARGET)
73 #if defined(HAVE_LIBDRM)
76 kms_swrast_create_screen(int fd
)
78 struct sw_winsys
*sws
;
79 struct pipe_screen
*screen
;
81 sws
= kms_dri_create_winsys(fd
);
85 screen
= sw_screen_create(sws
);
86 return screen
? debug_screen_wrap(screen
) : NULL
;
92 #if defined(GALLIUM_I915)
94 static struct pipe_screen
*
95 pipe_i915_create_screen(int fd
)
97 struct i915_winsys
*iws
;
98 struct pipe_screen
*screen
;
100 iws
= i915_drm_winsys_create(fd
);
104 screen
= i915_screen_create(iws
);
105 return screen
? debug_screen_wrap(screen
) : NULL
;
109 #if defined(GALLIUM_ILO)
111 static struct pipe_screen
*
112 pipe_ilo_create_screen(int fd
)
114 struct intel_winsys
*iws
;
115 struct pipe_screen
*screen
;
117 iws
= intel_winsys_create_for_fd(fd
);
121 screen
= ilo_screen_create(iws
);
122 return screen
? debug_screen_wrap(screen
) : NULL
;
126 #if defined(GALLIUM_NOUVEAU)
128 static struct pipe_screen
*
129 pipe_nouveau_create_screen(int fd
)
131 struct pipe_screen
*screen
;
133 screen
= nouveau_drm_screen_create(fd
);
134 return screen
? debug_screen_wrap(screen
) : NULL
;
138 #if defined(GALLIUM_R300)
140 static struct pipe_screen
*
141 pipe_r300_create_screen(int fd
)
143 struct radeon_winsys
*rw
;
145 rw
= radeon_drm_winsys_create(fd
, r300_screen_create
);
146 return rw
? debug_screen_wrap(rw
->screen
) : NULL
;
150 #if defined(GALLIUM_R600)
152 static struct pipe_screen
*
153 pipe_r600_create_screen(int fd
)
155 struct radeon_winsys
*rw
;
157 rw
= radeon_drm_winsys_create(fd
, r600_screen_create
);
158 return rw
? debug_screen_wrap(rw
->screen
) : NULL
;
162 #if defined(GALLIUM_RADEONSI)
164 static struct pipe_screen
*
165 pipe_radeonsi_create_screen(int fd
)
167 struct radeon_winsys
*rw
;
169 /* First, try amdgpu. */
170 rw
= amdgpu_winsys_create(fd
, radeonsi_screen_create
);
173 rw
= radeon_drm_winsys_create(fd
, radeonsi_screen_create
);
175 return rw
? debug_screen_wrap(rw
->screen
) : NULL
;
179 #if defined(GALLIUM_VMWGFX)
181 static struct pipe_screen
*
182 pipe_vmwgfx_create_screen(int fd
)
184 struct svga_winsys_screen
*sws
;
185 struct pipe_screen
*screen
;
187 sws
= svga_drm_winsys_screen_create(fd
);
191 screen
= svga_screen_create(sws
);
192 return screen
? debug_screen_wrap(screen
) : NULL
;
196 #if defined(GALLIUM_FREEDRENO)
198 static struct pipe_screen
*
199 pipe_freedreno_create_screen(int fd
)
201 struct pipe_screen
*screen
;
203 screen
= fd_drm_screen_create(fd
);
204 return screen
? debug_screen_wrap(screen
) : NULL
;
208 #if defined(GALLIUM_VIRGL)
210 static struct pipe_screen
*
211 pipe_virgl_create_screen(int fd
)
213 struct virgl_winsys
*vws
;
214 struct pipe_screen
*screen
;
216 vws
= virgl_drm_winsys_create(fd
);
220 screen
= virgl_create_screen(vws
);
221 return screen
? debug_screen_wrap(screen
) : NULL
;
225 #if defined(GALLIUM_VC4)
227 static struct pipe_screen
*
228 pipe_vc4_create_screen(int fd
)
230 struct pipe_screen
*screen
;
232 screen
= vc4_drm_screen_create(fd
);
233 return screen
? debug_screen_wrap(screen
) : NULL
;
237 inline struct pipe_screen
*
238 dd_create_screen(int fd
)
240 driver_name
= loader_get_driver_for_fd(fd
, _LOADER_GALLIUM
);
244 #if defined(GALLIUM_I915)
245 if (strcmp(driver_name
, "i915") == 0)
246 return pipe_i915_create_screen(fd
);
249 #if defined(GALLIUM_ILO)
250 if (strcmp(driver_name
, "i965") == 0)
251 return pipe_ilo_create_screen(fd
);
254 #if defined(GALLIUM_NOUVEAU)
255 if (strcmp(driver_name
, "nouveau") == 0)
256 return pipe_nouveau_create_screen(fd
);
259 #if defined(GALLIUM_R300)
260 if (strcmp(driver_name
, "r300") == 0)
261 return pipe_r300_create_screen(fd
);
264 #if defined(GALLIUM_R600)
265 if (strcmp(driver_name
, "r600") == 0)
266 return pipe_r600_create_screen(fd
);
269 #if defined(GALLIUM_RADEONSI)
270 if (strcmp(driver_name
, "radeonsi") == 0)
271 return pipe_radeonsi_create_screen(fd
);
274 #if defined(GALLIUM_VMWGFX)
275 if (strcmp(driver_name
, "vmwgfx") == 0)
276 return pipe_vmwgfx_create_screen(fd
);
279 #if defined(GALLIUM_FREEDRENO)
280 if ((strcmp(driver_name
, "kgsl") == 0) || (strcmp(driver_name
, "msm") == 0))
281 return pipe_freedreno_create_screen(fd
);
284 #if defined(GALLIUM_VIRGL)
285 if ((strcmp(driver_name
, "virtio_gpu") == 0))
286 return pipe_virgl_create_screen(fd
);
289 #if defined(GALLIUM_VC4)
290 if (strcmp(driver_name
, "vc4") == 0)
291 return pipe_vc4_create_screen(fd
);
293 #if defined(USE_VC4_SIMULATOR)
294 if (strcmp(driver_name
, "i965") == 0)
295 return pipe_vc4_create_screen(fd
);
308 static const struct drm_conf_ret throttle_ret
= {
313 static const struct drm_conf_ret share_fd_ret
= {
318 static inline const struct drm_conf_ret
*
319 configuration_query(enum drm_conf conf
)
322 case DRM_CONF_THROTTLE
:
323 return &throttle_ret
;
324 case DRM_CONF_SHARE_FD
:
325 return &share_fd_ret
;
332 inline const struct drm_conf_ret
*
333 dd_configuration(enum drm_conf conf
)
338 #if defined(GALLIUM_I915)
339 if (strcmp(driver_name
, "i915") == 0)
340 return configuration_query(conf
);
343 #if defined(GALLIUM_ILO)
344 if (strcmp(driver_name
, "i965") == 0)
345 return configuration_query(conf
);
348 #if defined(GALLIUM_NOUVEAU)
349 if (strcmp(driver_name
, "nouveau") == 0)
350 return configuration_query(conf
);
353 #if defined(GALLIUM_R300)
354 if (strcmp(driver_name
, "r300") == 0)
355 return configuration_query(conf
);
358 #if defined(GALLIUM_R600)
359 if (strcmp(driver_name
, "r600") == 0)
360 return configuration_query(conf
);
363 #if defined(GALLIUM_RADEONSI)
364 if (strcmp(driver_name
, "radeonsi") == 0)
365 return configuration_query(conf
);
368 #if defined(GALLIUM_VMWGFX)
369 if (strcmp(driver_name
, "vmwgfx") == 0)
370 return configuration_query(conf
);
373 #if defined(GALLIUM_FREEDRENO)
374 if ((strcmp(driver_name
, "kgsl") == 0) || (strcmp(driver_name
, "msm") == 0))
375 return configuration_query(conf
);
378 #if defined(GALLIUM_VIRGL)
379 if ((strcmp(driver_name
, "virtio_gpu") == 0))
380 return configuration_query(conf
);
383 #if defined(GALLIUM_VC4)
384 if (strcmp(driver_name
, "vc4") == 0)
385 return configuration_query(conf
);
387 #if defined(USE_VC4_SIMULATOR)
388 if (strcmp(driver_name
, "i965") == 0)
389 return configuration_query(conf
);
395 #endif /* INLINE_DRM_HELPER_H */