Mesa (master): egl/android: simplify device open/probe

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 24 10:58:05 UTC 2018


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

Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Wed Aug  8 15:40:56 2018 +0100

egl/android: simplify device open/probe

Currently droid_probe_device, does not do any 'probing' but filtering
out a device if it doesn't match the vendor string given.

Rename the function, straighten the return type and call it only as
needed - an actual vendor string is provided.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
Reviewed-by: Tomasz Figa <tfiga at chromium.org>

---

 src/egl/drivers/dri2/platform_android.c | 52 ++++++++++++---------------------
 1 file changed, 18 insertions(+), 34 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 24fd776961..1f9fe27ab8 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1404,31 +1404,20 @@ error:
    return false;
 }
 
-typedef enum {
-   probe_fail = -1,
-   probe_success = 0,
-   probe_filtered_out = 1,
-} probe_ret_t;
-
-static probe_ret_t
-droid_probe_device(_EGLDisplay *disp, int fd, const char *vendor)
+static int
+droid_filter_device(_EGLDisplay *disp, int fd, const char *vendor)
 {
-   int ret;
-
    drmVersionPtr ver = drmGetVersion(fd);
    if (!ver)
-      return probe_fail;
+      return -1;
 
-   if (vendor && strcmp(vendor, ver->name) != 0) {
-      ret = probe_filtered_out;
-      goto cleanup;
+   if (strcmp(vendor, ver->name) != 0) {
+      drmFreeVersion(ver);
+      return -1;
    }
 
-   ret = probe_success;
-
-cleanup:
    drmFreeVersion(ver);
-   return ret;
+   return 0;
 }
 
 static int
@@ -1462,25 +1451,20 @@ droid_open_device(_EGLDisplay *disp)
          continue;
       }
 
-      int ret = droid_probe_device(disp, fd, vendor_name);
-      switch (ret) {
-      case probe_success:
-         goto success;
-      case probe_filtered_out:
-         /* Set as fallback */
-         if (fallback_fd == -1)
+      if (vendor_name && droid_filter_device(disp, fd, vendor_name)) {
+         /* Match requested, but not found - set as fallback */
+         if (fallback_fd == -1) {
             fallback_fd = fd;
-         break;
-      case probe_fail:
-         break;
-      }
+         } else {
+            close(fd);
+            fd = -1;
+         }
 
-      if (fallback_fd != fd)
-         close(fd);
-      fd = -1;
+         continue;
+      }
+      /* Found a device */
+      break;
    }
-
-success:
    drmFreeDevices(devices, num_devices);
 
    if (fallback_fd < 0 && fd < 0) {




More information about the mesa-commit mailing list