Path: blob/21.2-virgl/src/gallium/auxiliary/target-helpers/drm_helper.h
4561 views
#ifndef DRM_HELPER_H1#define DRM_HELPER_H23#include <stdio.h>4#include "target-helpers/inline_debug_helper.h"5#include "target-helpers/drm_helper_public.h"6#include "frontend/drm_driver.h"7#include "util/driconf.h"89/**10* Instantiate a drm_driver_descriptor struct.11*/12#define DEFINE_DRM_DRIVER_DESCRIPTOR(descriptor_name, driver, _driconf, _driconf_count, func) \13const struct drm_driver_descriptor descriptor_name = { \14.driver_name = #driver, \15.driconf = _driconf, \16.driconf_count = _driconf_count, \17.create_screen = func, \18};1920/* The static pipe loader refers to the *_driver_descriptor structs for all21* drivers, regardless of whether they are configured in this Mesa build, or22* whether they're included in the specific gallium target. The target (dri,23* vdpau, etc.) will include this header with the #defines for the specific24* drivers it's including, and the disabled drivers will have a descriptor25* with a stub create function logging the failure.26*27* The dynamic pipe loader instead has target/pipeloader/pipe_*.c including28* this header in a pipe_*.so for each driver which will have one driver's29* GALLIUM_* defined. We make a single driver_descriptor entrypoint that is30* dlsym()ed by the dynamic pipe loader.31*/3233#ifdef PIPE_LOADER_DYNAMIC3435#define DRM_DRIVER_DESCRIPTOR(driver, driconf, driconf_count) \36PUBLIC DEFINE_DRM_DRIVER_DESCRIPTOR(driver_descriptor, driver, driconf, driconf_count, pipe_##driver##_create_screen)3738#define DRM_DRIVER_DESCRIPTOR_STUB(driver)3940#define DRM_DRIVER_DESCRIPTOR_ALIAS(driver, alias, driconf, driconf_count)4142#else4344#define DRM_DRIVER_DESCRIPTOR(driver, driconf, driconf_count) \45DEFINE_DRM_DRIVER_DESCRIPTOR(driver##_driver_descriptor, driver, driconf, driconf_count, pipe_##driver##_create_screen)4647#define DRM_DRIVER_DESCRIPTOR_STUB(driver) \48static struct pipe_screen * \49pipe_##driver##_create_screen(int fd, const struct pipe_screen_config *config) \50{ \51fprintf(stderr, #driver ": driver missing\n"); \52return NULL; \53} \54DRM_DRIVER_DESCRIPTOR(driver, NULL, 0)5556#define DRM_DRIVER_DESCRIPTOR_ALIAS(driver, alias, driconf, driconf_count) \57DEFINE_DRM_DRIVER_DESCRIPTOR(alias##_driver_descriptor, alias, driconf, \58driconf_count, pipe_##driver##_create_screen)5960#endif6162#ifdef GALLIUM_KMSRO_ONLY63#undef GALLIUM_V3D64#undef GALLIUM_VC465#undef GALLIUM_FREEDRENO66#undef GALLIUM_ETNAVIV67#undef GALLIUM_PANFROST68#undef GALLIUM_LIMA69#endif7071#ifdef GALLIUM_I91572#include "i915/drm/i915_drm_public.h"73#include "i915/i915_public.h"7475static struct pipe_screen *76pipe_i915_create_screen(int fd, const struct pipe_screen_config *config)77{78struct i915_winsys *iws;79struct pipe_screen *screen;8081iws = i915_drm_winsys_create(fd);82if (!iws)83return NULL;8485screen = i915_screen_create(iws);86return screen ? debug_screen_wrap(screen) : NULL;87}88DRM_DRIVER_DESCRIPTOR(i915, NULL, 0)89#else90DRM_DRIVER_DESCRIPTOR_STUB(i915)91#endif9293#ifdef GALLIUM_IRIS94#include "iris/drm/iris_drm_public.h"9596static struct pipe_screen *97pipe_iris_create_screen(int fd, const struct pipe_screen_config *config)98{99struct pipe_screen *screen;100101screen = iris_drm_screen_create(fd, config);102return screen ? debug_screen_wrap(screen) : NULL;103}104105const driOptionDescription iris_driconf[] = {106#include "iris/driinfo_iris.h"107};108DRM_DRIVER_DESCRIPTOR(iris, iris_driconf, ARRAY_SIZE(iris_driconf))109110#else111DRM_DRIVER_DESCRIPTOR_STUB(iris)112#endif113114#ifdef GALLIUM_CROCUS115#include "crocus/drm/crocus_drm_public.h"116117static struct pipe_screen *118pipe_crocus_create_screen(int fd, const struct pipe_screen_config *config)119{120struct pipe_screen *screen;121122screen = crocus_drm_screen_create(fd, config);123return screen ? debug_screen_wrap(screen) : NULL;124}125126const driOptionDescription crocus_driconf[] = {127#include "crocus/driinfo_crocus.h"128};129DRM_DRIVER_DESCRIPTOR(crocus, crocus_driconf, ARRAY_SIZE(crocus_driconf))130#else131DRM_DRIVER_DESCRIPTOR_STUB(crocus)132#endif133134#ifdef GALLIUM_NOUVEAU135#include "nouveau/drm/nouveau_drm_public.h"136137static struct pipe_screen *138pipe_nouveau_create_screen(int fd, const struct pipe_screen_config *config)139{140struct pipe_screen *screen;141142screen = nouveau_drm_screen_create(fd);143return screen ? debug_screen_wrap(screen) : NULL;144}145DRM_DRIVER_DESCRIPTOR(nouveau, NULL, 0)146147#else148DRM_DRIVER_DESCRIPTOR_STUB(nouveau)149#endif150151#if defined(GALLIUM_VC4) || defined(GALLIUM_V3D)152const driOptionDescription v3d_driconf[] = {153#include "v3d/driinfo_v3d.h"154};155#endif156157#ifdef GALLIUM_KMSRO158#include "kmsro/drm/kmsro_drm_public.h"159160static struct pipe_screen *161pipe_kmsro_create_screen(int fd, const struct pipe_screen_config *config)162{163struct pipe_screen *screen;164165screen = kmsro_drm_screen_create(fd, config);166return screen ? debug_screen_wrap(screen) : NULL;167}168#if defined(GALLIUM_VC4) || defined(GALLIUM_V3D)169DRM_DRIVER_DESCRIPTOR(kmsro, v3d_driconf, ARRAY_SIZE(v3d_driconf))170#else171DRM_DRIVER_DESCRIPTOR(kmsro, NULL, 0)172#endif173174#else175DRM_DRIVER_DESCRIPTOR_STUB(kmsro)176#endif177178#ifdef GALLIUM_R300179#include "radeon/radeon_winsys.h"180#include "radeon/drm/radeon_drm_public.h"181#include "r300/r300_public.h"182183static struct pipe_screen *184pipe_r300_create_screen(int fd, const struct pipe_screen_config *config)185{186struct radeon_winsys *rw;187188rw = radeon_drm_winsys_create(fd, config, r300_screen_create);189return rw ? debug_screen_wrap(rw->screen) : NULL;190}191DRM_DRIVER_DESCRIPTOR(r300, NULL, 0)192193#else194DRM_DRIVER_DESCRIPTOR_STUB(r300)195#endif196197#ifdef GALLIUM_R600198#include "radeon/radeon_winsys.h"199#include "radeon/drm/radeon_drm_public.h"200#include "r600/r600_public.h"201202static struct pipe_screen *203pipe_r600_create_screen(int fd, const struct pipe_screen_config *config)204{205struct radeon_winsys *rw;206207rw = radeon_drm_winsys_create(fd, config, r600_screen_create);208return rw ? debug_screen_wrap(rw->screen) : NULL;209}210DRM_DRIVER_DESCRIPTOR(r600, NULL, 0)211212#else213DRM_DRIVER_DESCRIPTOR_STUB(r600)214#endif215216#ifdef GALLIUM_RADEONSI217#include "radeonsi/si_public.h"218219static struct pipe_screen *220pipe_radeonsi_create_screen(int fd, const struct pipe_screen_config *config)221{222struct pipe_screen *screen = radeonsi_screen_create(fd, config);223224return screen ? debug_screen_wrap(screen) : NULL;225}226227const driOptionDescription radeonsi_driconf[] = {228#include "radeonsi/driinfo_radeonsi.h"229};230DRM_DRIVER_DESCRIPTOR(radeonsi, radeonsi_driconf, ARRAY_SIZE(radeonsi_driconf))231232#else233DRM_DRIVER_DESCRIPTOR_STUB(radeonsi)234#endif235236#ifdef GALLIUM_VMWGFX237#include "svga/drm/svga_drm_public.h"238#include "svga/svga_public.h"239240static struct pipe_screen *241pipe_vmwgfx_create_screen(int fd, const struct pipe_screen_config *config)242{243struct svga_winsys_screen *sws;244struct pipe_screen *screen;245246sws = svga_drm_winsys_screen_create(fd);247if (!sws)248return NULL;249250screen = svga_screen_create(sws);251return screen ? debug_screen_wrap(screen) : NULL;252}253DRM_DRIVER_DESCRIPTOR(vmwgfx, NULL, 0)254255#else256DRM_DRIVER_DESCRIPTOR_STUB(vmwgfx)257#endif258259#ifdef GALLIUM_FREEDRENO260#include "freedreno/drm/freedreno_drm_public.h"261262static struct pipe_screen *263pipe_msm_create_screen(int fd, const struct pipe_screen_config *config)264{265struct pipe_screen *screen;266267screen = fd_drm_screen_create(fd, NULL);268return screen ? debug_screen_wrap(screen) : NULL;269}270DRM_DRIVER_DESCRIPTOR(msm, NULL, 0)271#else272DRM_DRIVER_DESCRIPTOR_STUB(msm)273#endif274DRM_DRIVER_DESCRIPTOR_ALIAS(msm, kgsl, NULL, 0)275276#ifdef GALLIUM_VIRGL277#include "virgl/drm/virgl_drm_public.h"278#include "virgl/virgl_public.h"279280static struct pipe_screen *281pipe_virtio_gpu_create_screen(int fd, const struct pipe_screen_config *config)282{283struct pipe_screen *screen;284285screen = virgl_drm_screen_create(fd, config);286return screen ? debug_screen_wrap(screen) : NULL;287}288289const driOptionDescription virgl_driconf[] = {290#include "virgl/virgl_driinfo.h.in"291};292DRM_DRIVER_DESCRIPTOR(virtio_gpu, virgl_driconf, ARRAY_SIZE(virgl_driconf))293294#else295DRM_DRIVER_DESCRIPTOR_STUB(virtio_gpu)296#endif297298#ifdef GALLIUM_VC4299#include "vc4/drm/vc4_drm_public.h"300301static struct pipe_screen *302pipe_vc4_create_screen(int fd, const struct pipe_screen_config *config)303{304struct pipe_screen *screen;305306screen = vc4_drm_screen_create(fd, config);307return screen ? debug_screen_wrap(screen) : NULL;308}309DRM_DRIVER_DESCRIPTOR(vc4, v3d_driconf, ARRAY_SIZE(v3d_driconf))310#else311DRM_DRIVER_DESCRIPTOR_STUB(vc4)312#endif313314#ifdef GALLIUM_V3D315#include "v3d/drm/v3d_drm_public.h"316317static struct pipe_screen *318pipe_v3d_create_screen(int fd, const struct pipe_screen_config *config)319{320struct pipe_screen *screen;321322screen = v3d_drm_screen_create(fd, config);323return screen ? debug_screen_wrap(screen) : NULL;324}325326DRM_DRIVER_DESCRIPTOR(v3d, v3d_driconf, ARRAY_SIZE(v3d_driconf))327328#else329DRM_DRIVER_DESCRIPTOR_STUB(v3d)330#endif331332#ifdef GALLIUM_PANFROST333#include "panfrost/drm/panfrost_drm_public.h"334335static struct pipe_screen *336pipe_panfrost_create_screen(int fd, const struct pipe_screen_config *config)337{338struct pipe_screen *screen;339340screen = panfrost_drm_screen_create(fd);341return screen ? debug_screen_wrap(screen) : NULL;342}343DRM_DRIVER_DESCRIPTOR(panfrost, NULL, 0)344345#else346DRM_DRIVER_DESCRIPTOR_STUB(panfrost)347#endif348349#ifdef GALLIUM_ETNAVIV350#include "etnaviv/drm/etnaviv_drm_public.h"351352static struct pipe_screen *353pipe_etnaviv_create_screen(int fd, const struct pipe_screen_config *config)354{355struct pipe_screen *screen;356357screen = etna_drm_screen_create(fd);358return screen ? debug_screen_wrap(screen) : NULL;359}360DRM_DRIVER_DESCRIPTOR(etnaviv, NULL, 0)361362#else363DRM_DRIVER_DESCRIPTOR_STUB(etnaviv)364#endif365366#ifdef GALLIUM_TEGRA367#include "tegra/drm/tegra_drm_public.h"368369static struct pipe_screen *370pipe_tegra_create_screen(int fd, const struct pipe_screen_config *config)371{372struct pipe_screen *screen;373374screen = tegra_drm_screen_create(fd);375376return screen ? debug_screen_wrap(screen) : NULL;377}378DRM_DRIVER_DESCRIPTOR(tegra, NULL, 0)379380#else381DRM_DRIVER_DESCRIPTOR_STUB(tegra)382#endif383384#ifdef GALLIUM_LIMA385#include "lima/drm/lima_drm_public.h"386387static struct pipe_screen *388pipe_lima_create_screen(int fd, const struct pipe_screen_config *config)389{390struct pipe_screen *screen;391392screen = lima_drm_screen_create(fd);393return screen ? debug_screen_wrap(screen) : NULL;394}395DRM_DRIVER_DESCRIPTOR(lima, NULL, 0)396397#else398DRM_DRIVER_DESCRIPTOR_STUB(lima)399#endif400401#ifdef GALLIUM_ZINK402#include "zink/zink_public.h"403404static struct pipe_screen *405pipe_zink_create_screen(int fd, const struct pipe_screen_config *config)406{407struct pipe_screen *screen;408screen = zink_drm_create_screen(fd, config);409return screen ? debug_screen_wrap(screen) : NULL;410}411412const driOptionDescription zink_driconf[] = {413#include "zink/driinfo_zink.h"414};415DRM_DRIVER_DESCRIPTOR(zink, zink_driconf, ARRAY_SIZE(zink_driconf))416417#else418DRM_DRIVER_DESCRIPTOR_STUB(zink)419#endif420421#endif /* DRM_HELPER_H */422423424