tests: try a render-node device first for VA/DRM displays.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 24 Sep 2014 08:31:21 +0000 (10:31 +0200)
committerXiang, Haihao <haihao.xiang@intel.com>
Fri, 10 Oct 2014 06:54:44 +0000 (14:54 +0800)
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Reviewed-by: Sean V Kelley <sean.v.kelley@intel.com>
(cherry picked from commit e5d6c49c54ed7f6e1dacf9bafaae8fa0ba88db5d)

test/common/va_display_drm.c

index aa9f60a..b6394cd 100644 (file)
@@ -37,12 +37,28 @@ static int drm_fd = -1;
 static VADisplay
 va_open_display_drm(void)
 {
-    drm_fd = open("/dev/dri/card0", O_RDWR);
-    if (drm_fd < 0) {
-        fprintf(stderr, "error: can't open DRM connection!\n");
-        return NULL;
+    VADisplay va_dpy;
+    int i;
+
+    static const char *drm_device_paths[] = {
+        "/dev/dri/renderD128",
+        "/dev/dri/card0",
+        NULL
+    };
+
+    for (i = 0; drm_device_paths[i]; i++) {
+        drm_fd = open(drm_device_paths[i], O_RDWR);
+        if (drm_fd < 0)
+            continue;
+
+        va_dpy = vaGetDisplayDRM(drm_fd);
+        if (va_dpy)
+            return va_dpy;
+
+        close(drm_fd);
+        drm_fd = -1;
     }
-    return vaGetDisplayDRM(drm_fd);
+    return NULL;
 }
 
 static void