diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_drm.c b/gst-libs/gst/vaapi/gstvaapidisplay_drm.c
index 56da235..db2c5f2 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_drm.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_drm.c
@@ -52,9 +52,62 @@ typedef enum
 static DRMDeviceType g_drm_device_type;
 static GMutex g_drm_device_type_lock;
 
-/* Get default device path. Actually, the first match in the DRM subsystem */
-static const gchar *
-get_default_device_path (GstVaapiDisplay * display)
+/* This routine really should be in glib
+ *
+ * It takes a pointer to a variable which is an array of strings, such as
+ * produced by g_strdupv, and a null-terminated variable argument list of new
+ * entries which it adds to the array, resizing it as needed.
+ *
+ * It is permissible for the pointed-to variable to be NULL, in which case a
+ * new array is created and initialized with a NULL terminator. Each of the
+ * zero-or-more valid strings which follow before the final NULL are
+ * duplicated before being added to the new list.
+ *
+ * On success it modifies the passed in variable to point to the updated array
+ * of strings, and returns a pointer to that same array.
+ *
+ * On failure it returns NULL and the passed-in first parameter is unmodified.
+ *
+ * The resulting array should eventually be freed with g_strfreev()
+ *
+ */
+static gchar **
+vstrdupv (gchar *** paos, ...)
+{
+  va_list va;
+  gchar **tmp;
+  gchar **pa = *paos;
+  int n = 0;                    // new array entries
+  int c = 0;                    // current array entries
+
+  if (pa) {
+    while (*pa++)
+      c++;
+    pa = *paos;
+  }
+
+  va_start (va, paos);
+  while (va_arg (va, gchar *))
+    n++;
+  va_end (va);
+
+  pa = realloc (pa, (n + c + 1) * sizeof (gchar *));    // Add 1 for final NULL
+
+  if (pa) {
+    va_start (va, paos);
+    while (n--)
+      pa[c++] = g_strdup (va_arg (va, gchar *));
+    pa[c] = NULL;
+    va_end (va);
+    *paos = pa;
+  }
+
+  return pa;
+}
+
+/* Get a list of possible device paths to try opening */
+static gchar **
+get_device_path_list (GstVaapiDisplay * display)
 {
   GstVaapiDisplayDRMPrivate *const priv =
       GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
@@ -65,7 +118,7 @@ get_default_device_path (GstVaapiDisplay * display)
   struct udev_list_entry *l;
   int fd;
 
-  if (!priv->device_path_default) {
+  if (!priv->device_path_list) {
     udev = udev_new ();
     if (!udev)
       goto end;
@@ -103,10 +156,9 @@ get_default_device_path (GstVaapiDisplay * display)
         continue;
       }
 
-      priv->device_path_default = g_strdup (devpath);
+      vstrdupv (&priv->device_path_list, devpath, NULL);
       close (fd);
       udev_device_unref (device);
-      break;
     }
 
   end:
@@ -115,7 +167,7 @@ get_default_device_path (GstVaapiDisplay * display)
     if (udev)
       udev_unref (udev);
   }
-  return priv->device_path_default;
+  return priv->device_path_list;
 }
 
 /* Reconstruct a device path without our prefix */
@@ -131,25 +183,6 @@ get_device_path (GstVaapiDisplay * display)
   return device_path;
 }
 
-/* Mangle device path with our prefix */
-static gboolean
-set_device_path (GstVaapiDisplay * display, const gchar * device_path)
-{
-  GstVaapiDisplayDRMPrivate *const priv =
-      GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
-
-  g_free (priv->device_path);
-  priv->device_path = NULL;
-
-  if (!device_path) {
-    device_path = get_default_device_path (display);
-    if (!device_path)
-      return FALSE;
-  }
-  priv->device_path = g_strdup (device_path);
-  return priv->device_path != NULL;
-}
-
 /* Set device path from file descriptor */
 static gboolean
 set_device_path_from_fd (GstVaapiDisplay * display, gint drm_device)
@@ -242,23 +275,45 @@ gst_vaapi_display_drm_open_display (GstVaapiDisplay * display,
   GstVaapiDisplayDRMPrivate *const priv =
       GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
   GstVaapiDisplayCache *const cache = GST_VAAPI_DISPLAY_CACHE (display);
-  const GstVaapiDisplayInfo *info;
-
-  if (!set_device_path (display, name))
-    return FALSE;
-
-  info = gst_vaapi_display_cache_lookup_by_name (cache, priv->device_path,
-      g_display_types);
-  if (info) {
-    priv->drm_device = GPOINTER_TO_INT (info->native_display);
-    priv->use_foreign_display = TRUE;
-  } else {
-    priv->drm_device = open (get_device_path (display), O_RDWR | O_CLOEXEC);
-    if (priv->drm_device < 0)
-      return FALSE;
-    priv->use_foreign_display = FALSE;
+  gchar **pathptr = get_device_path_list (display);
+  gboolean foreign = FALSE;
+  int dev = -1;
+
+  while (*pathptr) {
+    const GstVaapiDisplayInfo *info =
+        gst_vaapi_display_cache_lookup_by_name (cache, *pathptr,
+        g_display_types);
+    if (info) {
+      dev = GPOINTER_TO_INT (info->native_display);
+      foreign = TRUE;
+      break;
+    } else {
+      gint major_version, minor_version;
+
+      dev = open (*pathptr, O_RDWR | O_CLOEXEC);
+      if (dev >= 0) {
+        /* as we might have more than one gpu we check if they support
+         * libVA and pass the first one that supports LibVA*/
+        VADisplay va_dpy = vaGetDisplayDRM (dev);
+        if (vaInitialize (va_dpy, &major_version,
+                &minor_version) == VA_STATUS_SUCCESS) {
+          vaTerminate (va_dpy);
+          break;
+        } else {
+          close (dev);
+          dev = -1;
+        }
+      }
+    }
+    pathptr++;
   }
-  return TRUE;
+  if (dev >= 0) {
+    priv->device_path = g_strdup (*pathptr);
+    priv->drm_device = dev;
+    priv->use_foreign_display = foreign;
+    return TRUE;
+  } else
+    return FALSE;
 }
 
 static void
@@ -278,9 +333,9 @@ gst_vaapi_display_drm_close_display (GstVaapiDisplay * display)
     priv->device_path = NULL;
   }
 
-  if (priv->device_path_default) {
-    g_free (priv->device_path_default);
-    priv->device_path_default = NULL;
+  if (priv->device_path_list) {
+    g_strfreev (priv->device_path_list);
+    priv->device_path_list = NULL;
   }
 }
 
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_drm_priv.h b/gst-libs/gst/vaapi/gstvaapidisplay_drm_priv.h
index 0fa295a..98b6ca1 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_drm_priv.h
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_drm_priv.h
@@ -53,7 +53,7 @@ typedef struct _GstVaapiDisplayDRMClass         GstVaapiDisplayDRMClass;
 
 struct _GstVaapiDisplayDRMPrivate
 {
-  gchar *device_path_default;
+  gchar **device_path_list; // Null-terminated list of device-paths
   gchar *device_path;
   gint drm_device;
   guint use_foreign_display:1;  // Foreign native_display?
