[Mesa-dev] [PATCH] Android: use symlinks for driver loading
Rob Herring
robh at kernel.org
Wed Jun 28 14:59:11 UTC 2017
Instead of having special driver loading logic for Android, create
symlinks to gallium_dri.so so we can use the standard loading logic.
Signed-off-by: Rob Herring <robh at kernel.org>
---
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 f81bd3512d09..cf2624270207 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 330e82420426..7b543097987c 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 6860770167fc..f00915473bac 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 af379bcc4b3e..2de22e73ec18 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 0b00b4e9ce06..00a123ed7a51 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 0c89cdbb1472..7b1c1055ef48 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 2d89f49cd5a4..1683cfa09c9e 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 5676c55983fc..6fff91f6f754 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 dc0fe9dcdbd9..29cc317327c3 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 9ed837fb22ad..154cfc4c5969 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 0dd70e5a0a5a..715c021afb82 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 010e15144c9b..0067dfa702e1 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 8c8fb5d3d1ca..f16391daa4c0 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 19be440d48e3..53e590855be4 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.11.0
More information about the mesa-dev
mailing list