Android: use symlinks for driver loading
authorRob Herring <robh@kernel.org>
Tue, 23 May 2017 00:04:48 +0000 (19:04 -0500)
committerRob Herring <robh@kernel.org>
Thu, 29 Jun 2017 14:09:49 +0000 (09:09 -0500)
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 <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Rob Herring <robh@kernel.org>
14 files changed:
src/egl/drivers/dri2/egl_dri2.c
src/gallium/drivers/freedreno/Android.mk
src/gallium/drivers/i915/Android.mk
src/gallium/drivers/nouveau/Android.mk
src/gallium/drivers/pl111/Android.mk
src/gallium/drivers/r300/Android.mk
src/gallium/drivers/r600/Android.mk
src/gallium/drivers/radeonsi/Android.mk
src/gallium/drivers/softpipe/Android.mk
src/gallium/drivers/svga/Android.mk
src/gallium/drivers/vc4/Android.mk
src/gallium/drivers/virgl/Android.mk
src/gallium/targets/dri/Android.mk
src/gbm/backends/dri/gbm_dri.c

index f81bd3512d0954a36b4b4a24cd2d9c5943600202..cf26242702074ec8ba69999be65e4a9b66b73866 100644 (file)
@@ -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) {
index 330e824204264ade1cdd8a03e5028bdfeaf0dee2..7b543097987c45a82267ddb1b985c623cdc03e24 100644 (file)
@@ -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
index 6860770167fcbf6a19676820230f63b985144aeb..f00915473bac82bdc6a58977d996a1b7b480bce9 100644 (file)
@@ -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
index af379bcc4b3e93d0061bbb238bda9e49cc129503..2de22e73ec187fcde71e21fa094092f81c5c2ac5 100644 (file)
@@ -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
index 0b00b4e9ce069d47885b88e92f262a0246e1a2f7..00a123ed7a51bf04a470350c9657cfb14376edc7 100644 (file)
@@ -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
index 0c89cdbb147274ba9322d6a3705803314d74ee0d..7b1c1055ef48747878475c5f073f67761073e2fb 100644 (file)
@@ -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
index 2d89f49cd5a4790e6f3e8340cb33a3c573dd66b0..1683cfa09c9eed99306fd7e5c1c88bbc7b6023fa 100644 (file)
@@ -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)
index 5676c55983fc8d48a14db9d38d8fe9d6da08237e..6fff91f6f75498e6e8c5f538cf04e66414096481 100644 (file)
@@ -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) \
index dc0fe9dcdbd9c8abc7f1eb81ef54f685f1be07c9..29cc317327c3004da552631535fbed1e1c8a57db 100644 (file)
@@ -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
index 9ed837fb22ad6ec4678f19289da06341b6d41563..154cfc4c5969c84e5f935420a629fe69a635fea3 100644 (file)
@@ -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
index 0dd70e5a0a5a3651f1a3b636e310709359d2f9d7..715c021afb82b9d34ef226b0ad5c8704c874a167 100644 (file)
@@ -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
index 010e15144c9be39e68647b9c9a003493afb21d69..0067dfa702e1e79bb177a4d23ecc042338616bad 100644 (file)
@@ -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
index 8c8fb5d3d1ca3214c0666b6d9358ae7b920e8e75..f16391daa4c0435e148ef62e0d64c6d57a2723e8 100644 (file)
@@ -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)
index 19be440d48e31e3a7dc8bec8726fb815888675bf..53e590855be4dadd48dd3570deecd8fbc97f8e22 100644 (file)
@@ -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) {