Mesa (master): android: make DRM optional

Chia-I Wu olv at kemper.freedesktop.org
Sat Aug 27 03:04:55 PDT 2011


Module: Mesa
Branch: master
Commit: 09b5f1fd61bfbb5afdaee81687a9c74c70a62b8a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=09b5f1fd61bfbb5afdaee81687a9c74c70a62b8a

Author: Chia-I Wu <olv at lunarg.com>
Date:   Thu Aug 25 21:36:19 2011 +0800

android: make DRM optional

For BOARD_GPU_DRIVERS=swrast build, DRM is not needed.

---

 Android.mk                                         |    8 ++++++--
 src/gallium/state_trackers/egl/Android.mk          |   10 ++++++++--
 .../state_trackers/egl/android/native_android.cpp  |   14 ++++++++++++++
 src/gallium/targets/egl-static/Android.mk          |   13 ++++++++++---
 src/gallium/targets/egl-static/egl.c               |    2 +-
 5 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/Android.mk b/Android.mk
index 9dbb3c9..ed68aec 100644
--- a/Android.mk
+++ b/Android.mk
@@ -38,7 +38,7 @@ DRM_GRALLOC_TOP := hardware/drm_gralloc
 classic_drivers :=
 gallium_drivers := swrast i915g nouveau r300g r600g vmwgfx
 
-MESA_GPU_DRIVERS := $(BOARD_GPU_DRIVERS)
+MESA_GPU_DRIVERS := $(strip $(BOARD_GPU_DRIVERS))
 
 # warn about invalid drivers
 invalid_drivers := $(filter-out \
@@ -97,12 +97,16 @@ LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_egl
 
 LOCAL_SHARED_LIBRARIES := \
 	libglapi \
-	libdrm \
 	libdl \
 	libhardware \
 	liblog \
 	libcutils
 
+# hardware drivers require DRM
+ifneq ($(MESA_GPU_DRIVERS),swrast)
+LOCAL_SHARED_LIBRARIES += libdrm
+endif
+
 ifeq ($(strip $(MESA_BUILD_GALLIUM)),true)
 
 gallium_DRIVERS :=
diff --git a/src/gallium/state_trackers/egl/Android.mk b/src/gallium/state_trackers/egl/Android.mk
index e459bd4..13b013b 100644
--- a/src/gallium/state_trackers/egl/Android.mk
+++ b/src/gallium/state_trackers/egl/Android.mk
@@ -45,8 +45,14 @@ LOCAL_CFLAGS := -DHAVE_ANDROID_BACKEND
 LOCAL_C_INCLUDES := \
 	$(GALLIUM_TOP)/state_trackers/egl \
 	$(GALLIUM_TOP)/winsys/sw \
-	$(MESA_TOP)/src/egl/main \
-	$(DRM_GRALLOC_TOP)
+	$(MESA_TOP)/src/egl/main
+
+# swrast only
+ifeq ($(MESA_GPU_DRIVERS),swrast)
+LOCAL_CFLAGS += -DANDROID_BACKEND_NO_DRM
+else
+LOCAL_C_INCLUDES += $(DRM_GRALLOC_TOP)
+endif
 
 LOCAL_MODULE := libmesa_st_egl
 
diff --git a/src/gallium/state_trackers/egl/android/native_android.cpp b/src/gallium/state_trackers/egl/android/native_android.cpp
index 211d6a2..338427d 100644
--- a/src/gallium/state_trackers/egl/android/native_android.cpp
+++ b/src/gallium/state_trackers/egl/android/native_android.cpp
@@ -136,6 +136,8 @@ get_pipe_format(int native)
    return fmt;
 }
 
+#ifndef ANDROID_BACKEND_NO_DRM
+
 #include <gralloc_drm_handle.h>
 static int
 get_handle_name(buffer_handle_t handle)
@@ -148,6 +150,16 @@ get_handle_name(buffer_handle_t handle)
    return (dh) ? dh->name : 0;
 }
 
+#else
+
+static int
+get_handle_name(buffer_handle_t handle)
+{
+   return 0;
+}
+
+#endif /* ANDROID_BACKEND_NO_DRM */
+
 /**
  * Import an android_native_buffer_t allocated by the server.
  */
@@ -581,6 +593,7 @@ android_display_init_drm(struct native_display *ndpy)
    const hw_module_t *mod;
    int fd, err;
 
+#ifndef ANDROID_BACKEND_NO_DRM
    /* get the authorized fd from gralloc */
    err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &mod);
    if (!err) {
@@ -594,6 +607,7 @@ android_display_init_drm(struct native_display *ndpy)
       adpy->base.screen =
          adpy->event_handler->new_drm_screen(&adpy->base, NULL, fd);
    }
+#endif
 
    if (adpy->base.screen) {
       LOGI("using DRM screen");
diff --git a/src/gallium/targets/egl-static/Android.mk b/src/gallium/targets/egl-static/Android.mk
index 8bdbeda..21b6dc2 100644
--- a/src/gallium/targets/egl-static/Android.mk
+++ b/src/gallium/targets/egl-static/Android.mk
@@ -39,13 +39,20 @@ LOCAL_C_INCLUDES := \
 	$(GALLIUM_TOP)/state_trackers/vega \
 	$(GALLIUM_TOP)/state_trackers/egl \
 	$(MESA_TOP)/src/egl/main \
-	$(MESA_TOP)/src/mesa \
-	$(DRM_TOP)/include/drm \
-	$(DRM_TOP)
+	$(MESA_TOP)/src/mesa
 
 # swrast
 LOCAL_CFLAGS += -DGALLIUM_SOFTPIPE
 
+# swrast only
+ifeq ($(MESA_GPU_DRIVERS),swrast)
+LOCAL_CFLAGS += -D_EGL_NO_DRM
+else
+LOCAL_C_INCLUDES += \
+	$(DRM_TOP)/include/drm \
+	$(DRM_TOP)
+endif
+
 ifneq ($(filter i915g, $(MESA_GPU_DRIVERS)),)
 LOCAL_CFLAGS += -D_EGL_PIPE_I915=1
 endif
diff --git a/src/gallium/targets/egl-static/egl.c b/src/gallium/targets/egl-static/egl.c
index 5a66e3c..adf1229 100644
--- a/src/gallium/targets/egl-static/egl.c
+++ b/src/gallium/targets/egl-static/egl.c
@@ -109,7 +109,7 @@ out:
    return (*chip_id >= 0);
 }
 
-#elif defined(PIPE_OS_ANDROID)
+#elif defined(PIPE_OS_ANDROID) && !defined(_EGL_NO_DRM)
 
 #include <xf86drm.h>
 /* for i915 */



More information about the mesa-commit mailing list