From a3d98ca62febdfbe035d655cb7c1f849bccfa105 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 22 May 2017 19:04:48 -0500 Subject: [PATCH] Android: use symlinks for driver loading Instead of having special driver loading logic for Android, create symlinks to gallium_dri.so so we can use the standard loading logic. Reviewed-by: Eric Anholt Reviewed-by: Emil Velikov Signed-off-by: Rob Herring --- src/egl/drivers/dri2/egl_dri2.c | 9 --------- src/gallium/drivers/freedreno/Android.mk | 1 + src/gallium/drivers/i915/Android.mk | 1 + src/gallium/drivers/nouveau/Android.mk | 1 + src/gallium/drivers/pl111/Android.mk | 1 + src/gallium/drivers/r300/Android.mk | 1 + src/gallium/drivers/r600/Android.mk | 1 + src/gallium/drivers/radeonsi/Android.mk | 1 + src/gallium/drivers/softpipe/Android.mk | 1 + src/gallium/drivers/svga/Android.mk | 1 + src/gallium/drivers/vc4/Android.mk | 1 + src/gallium/drivers/virgl/Android.mk | 1 + src/gallium/targets/dri/Android.mk | 10 ++++++++++ src/gbm/backends/dri/gbm_dri.c | 9 --------- 14 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index f81bd3512d0..cf262427020 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -516,15 +516,6 @@ dri2_open_driver(_EGLDisplay *disp) /* not need continue to loop all paths once the driver is found */ if (dri2_dpy->driver != NULL) break; - -#ifdef ANDROID - snprintf(path, sizeof path, "%.*s/gallium_dri.so", len, p); - dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); - if (dri2_dpy->driver == NULL) - _eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, dlerror()); - else - break; -#endif } if (dri2_dpy->driver == NULL) { diff --git a/src/gallium/drivers/freedreno/Android.mk b/src/gallium/drivers/freedreno/Android.mk index 330e8242042..7b543097987 100644 --- a/src/gallium/drivers/freedreno/Android.mk +++ b/src/gallium/drivers/freedreno/Android.mk @@ -50,6 +50,7 @@ include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ifneq ($(HAVE_GALLIUM_FREEDRENO),) +GALLIUM_TARGET_DRIVERS += msm $(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_freedreno) $(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) endif diff --git a/src/gallium/drivers/i915/Android.mk b/src/gallium/drivers/i915/Android.mk index 6860770167f..f00915473ba 100644 --- a/src/gallium/drivers/i915/Android.mk +++ b/src/gallium/drivers/i915/Android.mk @@ -36,5 +36,6 @@ include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ifneq ($(HAVE_GALLIUM_I915),) +GALLIUM_TARGET_DRIVERS += i915 $(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_i915) endif diff --git a/src/gallium/drivers/nouveau/Android.mk b/src/gallium/drivers/nouveau/Android.mk index af379bcc4b3..2de22e73ec1 100644 --- a/src/gallium/drivers/nouveau/Android.mk +++ b/src/gallium/drivers/nouveau/Android.mk @@ -43,6 +43,7 @@ include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ifneq ($(HAVE_GALLIUM_NOUVEAU),) +GALLIUM_TARGET_DRIVERS += nouveau $(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_nouveau) $(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) endif diff --git a/src/gallium/drivers/pl111/Android.mk b/src/gallium/drivers/pl111/Android.mk index 0b00b4e9ce0..00a123ed7a5 100644 --- a/src/gallium/drivers/pl111/Android.mk +++ b/src/gallium/drivers/pl111/Android.mk @@ -34,5 +34,6 @@ include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ifneq ($(HAVE_GALLIUM_PL111),) +GALLIUM_TARGET_DRIVERS += pl111 $(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_pl111) endif diff --git a/src/gallium/drivers/r300/Android.mk b/src/gallium/drivers/r300/Android.mk index 0c89cdbb147..7b1c1055ef4 100644 --- a/src/gallium/drivers/r300/Android.mk +++ b/src/gallium/drivers/r300/Android.mk @@ -42,6 +42,7 @@ include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ifneq ($(HAVE_GALLIUM_R300),) +GALLIUM_TARGET_DRIVERS += r300 $(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_radeon) $(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) endif diff --git a/src/gallium/drivers/r600/Android.mk b/src/gallium/drivers/r600/Android.mk index 2d89f49cd5a..1683cfa09c9 100644 --- a/src/gallium/drivers/r600/Android.mk +++ b/src/gallium/drivers/r600/Android.mk @@ -49,6 +49,7 @@ include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ifneq ($(HAVE_GALLIUM_R600),) +GALLIUM_TARGET_DRIVERS += r600 $(eval GALLIUM_LIBS += \ $(LOCAL_MODULE) \ libmesa_winsys_radeon) diff --git a/src/gallium/drivers/radeonsi/Android.mk b/src/gallium/drivers/radeonsi/Android.mk index 5676c55983f..6fff91f6f75 100644 --- a/src/gallium/drivers/radeonsi/Android.mk +++ b/src/gallium/drivers/radeonsi/Android.mk @@ -49,6 +49,7 @@ include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ifneq ($(HAVE_GALLIUM_RADEONSI),) +GALLIUM_TARGET_DRIVERS += radeonsi $(eval GALLIUM_LIBS += \ $(LOCAL_MODULE) \ $(LOCAL_STATIC_LIBRARIES) \ diff --git a/src/gallium/drivers/softpipe/Android.mk b/src/gallium/drivers/softpipe/Android.mk index dc0fe9dcdbd..29cc317327c 100644 --- a/src/gallium/drivers/softpipe/Android.mk +++ b/src/gallium/drivers/softpipe/Android.mk @@ -37,5 +37,6 @@ include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ifneq ($(HAVE_GALLIUM_SOFTPIPE),) +GALLIUM_TARGET_DRIVERS += swrast $(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_sw_dri) endif diff --git a/src/gallium/drivers/svga/Android.mk b/src/gallium/drivers/svga/Android.mk index 9ed837fb22a..154cfc4c596 100644 --- a/src/gallium/drivers/svga/Android.mk +++ b/src/gallium/drivers/svga/Android.mk @@ -40,5 +40,6 @@ include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ifneq ($(HAVE_GALLIUM_VMWGFX),) +GALLIUM_TARGET_DRIVERS := vmwgfx $(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_svga) endif diff --git a/src/gallium/drivers/vc4/Android.mk b/src/gallium/drivers/vc4/Android.mk index 0dd70e5a0a5..715c021afb8 100644 --- a/src/gallium/drivers/vc4/Android.mk +++ b/src/gallium/drivers/vc4/Android.mk @@ -38,5 +38,6 @@ include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ifneq ($(HAVE_GALLIUM_VC4),) +GALLIUM_TARGET_DRIVERS += vc4 $(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_vc4) endif diff --git a/src/gallium/drivers/virgl/Android.mk b/src/gallium/drivers/virgl/Android.mk index 010e15144c9..0067dfa702e 100644 --- a/src/gallium/drivers/virgl/Android.mk +++ b/src/gallium/drivers/virgl/Android.mk @@ -34,5 +34,6 @@ include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ifneq ($(HAVE_GALLIUM_VIRGL),) +GALLIUM_TARGET_DRIVERS += virtio_gpu $(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_virgl libmesa_winsys_virgl_vtest) endif diff --git a/src/gallium/targets/dri/Android.mk b/src/gallium/targets/dri/Android.mk index 8c8fb5d3d1c..f16391daa4c 100644 --- a/src/gallium/targets/dri/Android.mk +++ b/src/gallium/targets/dri/Android.mk @@ -58,5 +58,15 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \ # sort GALLIUM_SHARED_LIBS to remove any duplicates LOCAL_SHARED_LIBRARIES += $(sort $(GALLIUM_SHARED_LIBS)) +ifneq ($(filter 5 6 7, $(MESA_ANDROID_MAJOR_VERSION)),) +LOCAL_POST_INSTALL_CMD := \ + $(foreach l, lib lib64, \ + mkdir -p $(TARGET_OUT_SHARED_LIBRARIES)/$(l)/$(MESA_DRI_MODULE_REL_PATH); \ + $(foreach d, $(GALLIUM_TARGET_DRIVERS), ln -sf gallium_dri.so $(TARGET_OUT)/$(l)/$(MESA_DRI_MODULE_REL_PATH)/$(d)_dri.so;) \ + ) +else +LOCAL_MODULE_SYMLINKS := $(foreach d, $(GALLIUM_TARGET_DRIVERS), $(d)_dri.so) +endif + include $(GALLIUM_COMMON_MK) include $(BUILD_SHARED_LIBRARY) diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 19be440d48e..53e590855be 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -354,15 +354,6 @@ dri_open_driver(struct gbm_dri_device *dri) /* not need continue to loop all paths once the driver is found */ if (dri->driver != NULL) break; - -#ifdef ANDROID - snprintf(path, sizeof path, "%.*s/gallium_dri.so", len, p); - dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); - if (dri->driver == NULL) - sprintf("failed to open %s: %s\n", path, dlerror()); - else - break; -#endif } if (dri->driver == NULL) { -- 2.30.2