summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2011-08-18 10:24:25 +0800
committerChia-I Wu <[email protected]>2011-08-21 02:01:48 +0800
commit4b2b0b9fb8d41e7a8df4cdc49d498fcfb99139df (patch)
treec0a23e33fff0a1a42a5e1d502bcfe4dae237c8bb
parent15418a850575b2a33132165605293ed835b4be53 (diff)
targets/egl-static: do not rely on libudev on Android
There is no libudev on Android. Use DRM to get the PCI ID directly. Reviewed-by: Benjamin Franzke <[email protected]>
-rw-r--r--src/gallium/targets/egl-static/egl.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/gallium/targets/egl-static/egl.c b/src/gallium/targets/egl-static/egl.c
index 568f5498dd4..6e5f6f30b11 100644
--- a/src/gallium/targets/egl-static/egl.c
+++ b/src/gallium/targets/egl-static/egl.c
@@ -109,6 +109,70 @@ out:
return (*chip_id >= 0);
}
+#elif defined(PIPE_OS_ANDROID)
+
+#include <xf86drm.h>
+/* for i915 */
+#include <i915_drm.h>
+/* for radeon */
+#include <radeon_drm.h>
+/* for util_strcmp */
+#include "util/u_string.h"
+
+static boolean
+drm_fd_get_pci_id(int fd, int *vendor_id, int *chip_id)
+{
+ drmVersionPtr version;
+
+ *chip_id = -1;
+
+ version = drmGetVersion(fd);
+ if (!version) {
+ _eglLog(_EGL_WARNING, "invalid drm fd");
+ return FALSE;
+ }
+ if (!version->name) {
+ _eglLog(_EGL_WARNING, "unable to determine the driver name");
+ drmFreeVersion(version);
+ return FALSE;
+ }
+
+ if (util_strcmp(version->name, "i915") == 0) {
+ struct drm_i915_getparam gp;
+ int ret;
+
+ *vendor_id = 0x8086;
+
+ memset(&gp, 0, sizeof(gp));
+ gp.param = I915_PARAM_CHIPSET_ID;
+ gp.value = chip_id;
+ ret = drmCommandWriteRead(fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
+ if (ret) {
+ _eglLog(_EGL_WARNING, "failed to get param for i915");
+ *chip_id = -1;
+ }
+ }
+ else if (util_strcmp(version->name, "radeon") == 0) {
+ struct drm_radeon_info info;
+ int ret;
+
+ *vendor_id = 0x1002;
+
+ memset(&info, 0, sizeof(info));
+ info.request = RADEON_INFO_DEVICE_ID;
+ info.value = (unsigned long) chip_id;
+ ret = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
+ if (ret) {
+ _eglLog(_EGL_WARNING, "failed to get info for radeon");
+ *chip_id = -1;
+ }
+ }
+
+ drmFreeVersion(version);
+
+ return (*chip_id >= 0);
+}
+
#else
static boolean