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 "i915/drm/i915_drm_public.h"
13 #include "i915/i915_public.h"
17 #include "intel/intel_winsys.h"
18 #include "ilo/ilo_public.h"
22 #include "nouveau/drm/nouveau_drm_public.h"
26 #include "radeon/drm/radeon_winsys.h"
27 #include "radeon/drm/radeon_drm_public.h"
28 #include "r300/r300_public.h"
32 #include "radeon/drm/radeon_winsys.h"
33 #include "radeon/drm/radeon_drm_public.h"
34 #include "r600/r600_public.h"
38 #include "radeon/drm/radeon_winsys.h"
39 #include "radeon/drm/radeon_drm_public.h"
40 #include "radeonsi/si_public.h"
44 #include "svga/drm/svga_drm_public.h"
45 #include "svga/svga_public.h"
49 #include "freedreno/drm/freedreno_drm_public.h"
52 static char* driver_name
= NULL
;
54 /* XXX: We need to teardown the winsys if *screen_create() fails. */
56 #if defined(GALLIUM_I915)
57 #if defined(DRI_TARGET)
59 const __DRIextension
**__driDriverGetExtensions_i915(void);
61 PUBLIC
const __DRIextension
**__driDriverGetExtensions_i915(void)
63 globalDriverAPI
= &galliumdrm_driver_api
;
64 return galliumdrm_driver_extensions
;
68 static struct pipe_screen
*
69 pipe_i915_create_screen(int fd
)
71 struct i915_winsys
*iws
;
72 struct pipe_screen
*screen
;
74 iws
= i915_drm_winsys_create(fd
);
78 screen
= i915_screen_create(iws
);
79 return screen
? debug_screen_wrap(screen
) : NULL
;
83 #if defined(GALLIUM_ILO)
84 #if defined(DRI_TARGET)
86 const __DRIextension
**__driDriverGetExtensions_i965(void);
88 PUBLIC
const __DRIextension
**__driDriverGetExtensions_i965(void)
90 globalDriverAPI
= &galliumdrm_driver_api
;
91 return galliumdrm_driver_extensions
;
95 static struct pipe_screen
*
96 pipe_ilo_create_screen(int fd
)
98 struct intel_winsys
*iws
;
99 struct pipe_screen
*screen
;
101 iws
= intel_winsys_create_for_fd(fd
);
105 screen
= ilo_screen_create(iws
);
106 return screen
? debug_screen_wrap(screen
) : NULL
;
110 #if defined(GALLIUM_NOUVEAU)
111 #if defined(DRI_TARGET)
113 const __DRIextension
**__driDriverGetExtensions_nouveau(void);
115 PUBLIC
const __DRIextension
**__driDriverGetExtensions_nouveau(void)
117 globalDriverAPI
= &galliumdrm_driver_api
;
118 return galliumdrm_driver_extensions
;
122 static struct pipe_screen
*
123 pipe_nouveau_create_screen(int fd
)
125 struct pipe_screen
*screen
;
127 screen
= nouveau_drm_screen_create(fd
);
128 return screen
? debug_screen_wrap(screen
) : NULL
;
132 #if defined(GALLIUM_R300)
133 #if defined(DRI_TARGET)
135 const __DRIextension
**__driDriverGetExtensions_r300(void);
137 PUBLIC
const __DRIextension
**__driDriverGetExtensions_r300(void)
139 globalDriverAPI
= &galliumdrm_driver_api
;
140 return galliumdrm_driver_extensions
;
144 static struct pipe_screen
*
145 pipe_r300_create_screen(int fd
)
147 struct radeon_winsys
*rw
;
149 rw
= radeon_drm_winsys_create(fd
, r300_screen_create
);
150 return rw
? debug_screen_wrap(rw
->screen
) : NULL
;
154 #if defined(GALLIUM_R600)
155 #if defined(DRI_TARGET)
157 const __DRIextension
**__driDriverGetExtensions_r600(void);
159 PUBLIC
const __DRIextension
**__driDriverGetExtensions_r600(void)
161 globalDriverAPI
= &galliumdrm_driver_api
;
162 return galliumdrm_driver_extensions
;
166 static struct pipe_screen
*
167 pipe_r600_create_screen(int fd
)
169 struct radeon_winsys
*rw
;
171 rw
= radeon_drm_winsys_create(fd
, r600_screen_create
);
172 return rw
? debug_screen_wrap(rw
->screen
) : NULL
;
176 #if defined(GALLIUM_RADEONSI)
177 #if defined(DRI_TARGET)
179 const __DRIextension
**__driDriverGetExtensions_radeonsi(void);
181 PUBLIC
const __DRIextension
**__driDriverGetExtensions_radeonsi(void)
183 globalDriverAPI
= &galliumdrm_driver_api
;
184 return galliumdrm_driver_extensions
;
188 static struct pipe_screen
*
189 pipe_radeonsi_create_screen(int fd
)
191 struct radeon_winsys
*rw
;
193 rw
= radeon_drm_winsys_create(fd
, radeonsi_screen_create
);
194 return rw
? debug_screen_wrap(rw
->screen
) : NULL
;
198 #if defined(GALLIUM_VMWGFX)
199 #if defined(DRI_TARGET)
201 const __DRIextension
**__driDriverGetExtensions_vmwgfx(void);
203 PUBLIC
const __DRIextension
**__driDriverGetExtensions_vmwgfx(void)
205 globalDriverAPI
= &galliumdrm_driver_api
;
206 return galliumdrm_driver_extensions
;
210 static struct pipe_screen
*
211 pipe_vmwgfx_create_screen(int fd
)
213 struct svga_winsys_screen
*sws
;
214 struct pipe_screen
*screen
;
216 sws
= svga_drm_winsys_screen_create(fd
);
220 screen
= svga_screen_create(sws
);
221 return screen
? debug_screen_wrap(screen
) : NULL
;
225 #if defined(GALLIUM_FREEDRENO)
226 #if defined(DRI_TARGET)
228 const __DRIextension
**__driDriverGetExtensions_msm(void);
230 PUBLIC
const __DRIextension
**__driDriverGetExtensions_msm(void)
232 globalDriverAPI
= &galliumdrm_driver_api
;
233 return galliumdrm_driver_extensions
;
236 const __DRIextension
**__driDriverGetExtensions_kgsl(void);
238 PUBLIC
const __DRIextension
**__driDriverGetExtensions_kgsl(void)
240 globalDriverAPI
= &galliumdrm_driver_api
;
241 return galliumdrm_driver_extensions
;
245 static struct pipe_screen
*
246 pipe_freedreno_create_screen(int fd
)
248 struct pipe_screen
*screen
;
250 screen
= fd_drm_screen_create(fd
);
251 return screen
? debug_screen_wrap(screen
) : NULL
;
255 inline struct pipe_screen
*
256 dd_create_screen(int fd
)
258 driver_name
= loader_get_driver_for_fd(fd
, _LOADER_GALLIUM
);
262 #if defined(GALLIUM_I915)
263 if (strcmp(driver_name
, "i915") == 0)
264 return pipe_i915_create_screen(fd
);
267 #if defined(GALLIUM_ILO)
268 if (strcmp(driver_name
, "i965") == 0)
269 return pipe_ilo_create_screen(fd
);
272 #if defined(GALLIUM_NOUVEAU)
273 if (strcmp(driver_name
, "nouveau") == 0)
274 return pipe_nouveau_create_screen(fd
);
277 #if defined(GALLIUM_R300)
278 if (strcmp(driver_name
, "r300") == 0)
279 return pipe_r300_create_screen(fd
);
282 #if defined(GALLIUM_R600)
283 if (strcmp(driver_name
, "r600") == 0)
284 return pipe_r600_create_screen(fd
);
287 #if defined(GALLIUM_RADEONSI)
288 if (strcmp(driver_name
, "radeonsi") == 0)
289 return pipe_radeonsi_create_screen(fd
);
292 #if defined(GALLIUM_VMWGFX)
293 if (strcmp(driver_name
, "vmwgfx") == 0)
294 return pipe_vmwgfx_create_screen(fd
);
297 #if defined(GALLIUM_FREEDRENO)
298 if ((strcmp(driver_name
, "kgsl") == 0) || (strcmp(driver_name
, "msm") == 0))
299 return pipe_freedreno_create_screen(fd
);
311 static const struct drm_conf_ret throttle_ret
= {
316 static const struct drm_conf_ret share_fd_ret
= {
321 static const struct drm_conf_ret
*
322 configuration_query(enum drm_conf conf
)
325 case DRM_CONF_THROTTLE
:
326 return &throttle_ret
;
327 case DRM_CONF_SHARE_FD
:
328 return &share_fd_ret
;
335 inline const struct drm_conf_ret
*
336 dd_configuration(enum drm_conf conf
)
341 #if defined(GALLIUM_I915)
342 if (strcmp(driver_name
, "i915") == 0)
346 #if defined(GALLIUM_ILO)
347 if (strcmp(driver_name
, "i965") == 0)
348 return configuration_query(conf
);
351 #if defined(GALLIUM_NOUVEAU)
352 if (strcmp(driver_name
, "nouveau") == 0)
353 return configuration_query(conf
);
356 #if defined(GALLIUM_R300)
357 if (strcmp(driver_name
, "r300") == 0)
358 return configuration_query(conf
);
361 #if defined(GALLIUM_R600)
362 if (strcmp(driver_name
, "r600") == 0)
363 return configuration_query(conf
);
366 #if defined(GALLIUM_RADEONSI)
367 if (strcmp(driver_name
, "radeonsi") == 0)
368 return configuration_query(conf
);
371 #if defined(GALLIUM_VMWGFX)
372 if (strcmp(driver_name
, "vmwgfx") == 0)
373 return configuration_query(conf
);
376 #if defined(GALLIUM_FREEDRENO)
377 if ((strcmp(driver_name
, "kgsl") == 0) || (strcmp(driver_name
, "msm") == 0))
383 #endif /* INLINE_DRM_HELPER_H */