From 5ee46f6751dc03b9981f1a8d9da76b31fa3c1a1f Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Fri, 30 Mar 2018 13:41:39 +0200 Subject: [PATCH] display: drm: Allow finding DRM paths out of the PCI subsystem This removes hard-coded checks on the parent subsystem of potential DRM devices. These checks were set to exlude devices that do not originate from the PCI bus, which is only a valid approach on x86 devices. Other devices may have a DRM device originating from the platform subsystem, so the checks that were previously restricted to PCI are extended to cover platform devices as well. https://bugzilla.gnome.org/show_bug.cgi?id=794840 Signed-off-by: Paul Kocialkowski --- gst-libs/gst/vaapi/gstvaapidisplay_drm.c | 25 ++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_drm.c b/gst-libs/gst/vaapi/gstvaapidisplay_drm.c index 95becdb873..ef68187aad 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_drm.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay_drm.c @@ -56,6 +56,7 @@ typedef enum static DRMDeviceType g_drm_device_type; static GMutex g_drm_device_type_lock; +static const gchar *allowed_subsystems[] = { "pci", "platform", NULL }; static gboolean supports_vaapi (int fd) @@ -83,6 +84,7 @@ get_default_device_path (GstVaapiDisplay * display) struct udev_device *device, *parent; struct udev_enumerate *e = NULL; struct udev_list_entry *l; + gint i; int fd; if (!priv->device_path_default) { @@ -111,7 +113,13 @@ get_default_device_path (GstVaapiDisplay * display) syspath = udev_list_entry_get_name (l); device = udev_device_new_from_syspath (udev, syspath); parent = udev_device_get_parent (device); - if (strcmp (udev_device_get_subsystem (parent), "pci") != 0) { + + for (i = 0; allowed_subsystems[i] != NULL; i++) + if (strcmp (udev_device_get_subsystem (parent), + allowed_subsystems[i]) == 0) + break; + + if (allowed_subsystems[i] == NULL) { udev_device_unref (device); continue; } @@ -185,6 +193,7 @@ set_device_path_from_fd (GstVaapiDisplay * display, gint drm_device) struct udev_enumerate *e = NULL; struct udev_list_entry *l; gboolean success = FALSE; + gint i; g_free (priv->device_path); priv->device_path = NULL; @@ -195,10 +204,18 @@ set_device_path_from_fd (GstVaapiDisplay * display, gint drm_device) busid = drmGetBusid (drm_device); if (!busid) goto end; - if (strncmp (busid, "pci:", 4) != 0) + + for (i = 0; allowed_subsystems[i] != NULL; i++) { + busid_length = strlen (allowed_subsystems[i]); + + if (strncmp (busid, allowed_subsystems[i], busid_length) == 0) { + busid += busid_length + 1; + busid_length = strlen (busid); + } + } + + if (allowed_subsystems[i] == NULL) goto end; - busid += 4; - busid_length = strlen (busid); udev = udev_new (); if (!udev)