summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorHaihao Xiang <haihao.xiang@intel.com>2021-01-13 14:43:20 +0800
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-01-29 14:08:42 +0000
commit85284f4aacc9cfc059c59aa033166fedc247e117 (patch)
tree65f4ad16c5a63281ded27cc60a7d5a4f95ff98f9 /gst-libs
parent23967fc02bf1d9a1ecaf06704d024bdc8904e295 (diff)
libs: display: drm: allow user specify a drm device via an env variable
Currently the default drm device is always used on a system with multiple drm devices. This patch allows user to specify the required drm device via GST_VAAPI_DRM_DEVICE env variable Example: GST_VAAPI_DRM_DEVICE=/dev/dri/renderD129 gst-launch-1.0 videotestsrc ! vaapih264enc ! fakesink Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/409>
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_drm.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_drm.c b/gst-libs/gst/vaapi/gstvaapidisplay_drm.c
index d575ffd9..7f4d3996 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_drm.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_drm.c
@@ -337,15 +337,27 @@ GstVaapiDisplay *
gst_vaapi_display_drm_new (const gchar * device_path)
{
GstVaapiDisplay *display;
- guint types[2], i, num_types = 0;
+ guint types[3], i, num_types = 0;
+ gpointer device_paths[3];
g_mutex_lock (&g_drm_device_type_lock);
- if (device_path)
+ if (device_path) {
+ device_paths[num_types] = (gpointer) device_path;
types[num_types++] = 0;
- else if (g_drm_device_type)
+ } else if (g_drm_device_type) {
+ device_paths[num_types] = (gpointer) device_path;
types[num_types++] = g_drm_device_type;
- else {
+ } else {
+ const gchar *user_choice = g_getenv ("GST_VAAPI_DRM_DEVICE");
+
+ if (user_choice && g_str_has_prefix (user_choice, "/dev/dri/")) {
+ device_paths[num_types] = (gpointer) user_choice;
+ types[num_types++] = 0;
+ }
+
+ device_paths[num_types] = (gpointer) device_path;
types[num_types++] = DRM_DEVICE_RENDERNODES;
+ device_paths[num_types] = (gpointer) device_path;
types[num_types++] = DRM_DEVICE_LEGACY;
}
@@ -353,7 +365,7 @@ gst_vaapi_display_drm_new (const gchar * device_path)
g_drm_device_type = types[i];
display = g_object_new (GST_TYPE_VAAPI_DISPLAY_DRM, NULL);
display = gst_vaapi_display_config (display,
- GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) device_path);
+ GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, device_paths[i]);
if (display || device_path)
break;
}