diff --git a/sys/msdk/gstmsdkcontext.c b/sys/msdk/gstmsdkcontext.c index 012efe615c..df635c7ffe 100644 --- a/sys/msdk/gstmsdkcontext.c +++ b/sys/msdk/gstmsdkcontext.c @@ -34,6 +34,7 @@ #ifndef _WIN32 #include #include +#include #include #include #endif @@ -76,6 +77,31 @@ get_device_id (void) const gchar *devnode_path; const gchar *devnode_files[2] = { "renderD[0-9]*", "card[0-9]*" }; int fd = -1, i; + const gchar *user_choice = g_getenv ("GST_MSDK_DRM_DEVICE"); + + if (user_choice) { + if (g_str_has_prefix (user_choice, "/dev/dri/")) + fd = open (user_choice, O_RDWR | O_CLOEXEC); + + if (fd >= 0) { + drmVersionPtr drm_version = drmGetVersion (fd); + + if (!drm_version || strncmp (drm_version->name, "i915", 4)) { + GST_WARNING ("The specified device isn't an Intel device, " + "use the default device instead"); + drmFreeVersion (drm_version); + close (fd); + fd = -1; + } else { + GST_DEBUG ("Opened the specified drm device %s", user_choice); + drmFreeVersion (drm_version); + return fd; + } + } else { + GST_WARNING ("The specified device isn't a valid drm device, " + "use the default device instead"); + } + } client = g_udev_client_new (NULL); if (!client) diff --git a/sys/msdk/meson.build b/sys/msdk/meson.build index 2c817b62f2..98570e5baa 100644 --- a/sys/msdk/meson.build +++ b/sys/msdk/meson.build @@ -124,8 +124,9 @@ else libva_dep = dependency('libva-drm', required: get_option('msdk')) libdl_dep = cc.find_library('dl', required: get_option('msdk')) libgudev_dep = dependency('gudev-1.0', required: get_option('msdk')) - msdk_deps = declare_dependency(dependencies: [libva_dep, libdl_dep, libgudev_dep]) - msdk_deps_found = libva_dep.found() and libdl_dep.found() and libgudev_dep.found() + libdrm_dep = dependency('libdrm', required: get_option('msdk')) + msdk_deps = declare_dependency(dependencies: [libva_dep, libdl_dep, libgudev_dep, libdrm_dep]) + msdk_deps_found = libva_dep.found() and libdl_dep.found() and libgudev_dep.found() and libdrm_dep.found() endif if msdk_deps_found