2012-08-01 13:44:02 +00:00
|
|
|
/*
|
|
|
|
* gstvaapidisplay_drm.c - VA/DRM display abstraction
|
|
|
|
*
|
2013-11-22 05:37:12 +00:00
|
|
|
* Copyright (C) 2012-2013 Intel Corporation
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
2012-08-01 13:44:02 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2.1
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:gstvaapidisplay_drm
|
|
|
|
* @short_description: VA/DRM display abstraction
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysdeps.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <libudev.h>
|
|
|
|
#include <xf86drm.h>
|
|
|
|
#include <va/va_drm.h>
|
|
|
|
#include "gstvaapiutils.h"
|
|
|
|
#include "gstvaapidisplay_priv.h"
|
|
|
|
#include "gstvaapidisplay_drm.h"
|
|
|
|
#include "gstvaapidisplay_drm_priv.h"
|
2014-12-10 17:12:24 +00:00
|
|
|
#include "gstvaapiwindow_drm.h"
|
2012-08-01 13:44:02 +00:00
|
|
|
|
|
|
|
#define DEBUG 1
|
|
|
|
#include "gstvaapidebug.h"
|
|
|
|
|
2013-05-27 11:17:31 +00:00
|
|
|
static const guint g_display_types = 1U << GST_VAAPI_DISPLAY_TYPE_DRM;
|
|
|
|
|
2014-09-24 08:14:24 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
DRM_DEVICE_LEGACY = 1,
|
|
|
|
DRM_DEVICE_RENDERNODES,
|
|
|
|
} DRMDeviceType;
|
|
|
|
|
|
|
|
static DRMDeviceType g_drm_device_type;
|
|
|
|
static GMutex g_drm_device_type_lock;
|
|
|
|
|
2012-08-01 13:44:02 +00:00
|
|
|
/* Get default device path. Actually, the first match in the DRM subsystem */
|
|
|
|
static const gchar *
|
2013-12-20 12:27:07 +00:00
|
|
|
get_default_device_path (GstVaapiDisplay * display)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayDRMPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
|
|
|
const gchar *syspath, *devpath;
|
|
|
|
struct udev *udev = NULL;
|
|
|
|
struct udev_device *device, *parent;
|
|
|
|
struct udev_enumerate *e = NULL;
|
|
|
|
struct udev_list_entry *l;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
if (!priv->device_path_default) {
|
|
|
|
udev = udev_new ();
|
|
|
|
if (!udev)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
e = udev_enumerate_new (udev);
|
|
|
|
if (!e)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
udev_enumerate_add_match_subsystem (e, "drm");
|
2014-09-24 08:14:24 +00:00
|
|
|
switch (g_drm_device_type) {
|
|
|
|
case DRM_DEVICE_LEGACY:
|
|
|
|
udev_enumerate_add_match_sysname (e, "card[0-9]*");
|
|
|
|
break;
|
|
|
|
case DRM_DEVICE_RENDERNODES:
|
|
|
|
udev_enumerate_add_match_sysname (e, "renderD[0-9]*");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GST_ERROR ("unknown drm device type (%d)", g_drm_device_type);
|
|
|
|
goto end;
|
|
|
|
}
|
2013-12-20 12:27:07 +00:00
|
|
|
udev_enumerate_scan_devices (e);
|
|
|
|
udev_list_entry_foreach (l, udev_enumerate_get_list_entry (e)) {
|
|
|
|
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) {
|
|
|
|
udev_device_unref (device);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
devpath = udev_device_get_devnode (device);
|
|
|
|
fd = open (devpath, O_RDWR | O_CLOEXEC);
|
|
|
|
if (fd < 0) {
|
|
|
|
udev_device_unref (device);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->device_path_default = g_strdup (devpath);
|
|
|
|
close (fd);
|
|
|
|
udev_device_unref (device);
|
|
|
|
break;
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
2013-12-20 12:27:07 +00:00
|
|
|
|
|
|
|
end:
|
|
|
|
if (e)
|
|
|
|
udev_enumerate_unref (e);
|
|
|
|
if (udev)
|
|
|
|
udev_unref (udev);
|
|
|
|
}
|
|
|
|
return priv->device_path_default;
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Reconstruct a device path without our prefix */
|
|
|
|
static const gchar *
|
2013-12-20 12:27:07 +00:00
|
|
|
get_device_path (GstVaapiDisplay * display)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayDRMPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
|
|
|
const gchar *device_path = priv->device_path;
|
2012-08-01 13:44:02 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!device_path || *device_path == '\0')
|
|
|
|
return NULL;
|
|
|
|
return device_path;
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Mangle device path with our prefix */
|
2013-05-07 09:39:34 +00:00
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
set_device_path (GstVaapiDisplay * display, const gchar * device_path)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
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;
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set device path from file descriptor */
|
2013-05-07 09:39:34 +00:00
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
set_device_path_from_fd (GstVaapiDisplay * display, gint drm_device)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayDRMPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
|
|
|
const gchar *busid, *path, *str;
|
|
|
|
gsize busid_length, path_length;
|
|
|
|
struct udev *udev = NULL;
|
|
|
|
struct udev_device *device;
|
|
|
|
struct udev_enumerate *e = NULL;
|
|
|
|
struct udev_list_entry *l;
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
|
|
|
g_free (priv->device_path);
|
|
|
|
priv->device_path = NULL;
|
|
|
|
|
|
|
|
if (drm_device < 0)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
busid = drmGetBusid (drm_device);
|
|
|
|
if (!busid)
|
|
|
|
goto end;
|
|
|
|
if (strncmp (busid, "pci:", 4) != 0)
|
|
|
|
goto end;
|
|
|
|
busid += 4;
|
|
|
|
busid_length = strlen (busid);
|
|
|
|
|
|
|
|
udev = udev_new ();
|
|
|
|
if (!udev)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
e = udev_enumerate_new (udev);
|
|
|
|
if (!e)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
udev_enumerate_add_match_subsystem (e, "drm");
|
|
|
|
udev_enumerate_scan_devices (e);
|
|
|
|
udev_list_entry_foreach (l, udev_enumerate_get_list_entry (e)) {
|
|
|
|
path = udev_list_entry_get_name (l);
|
|
|
|
str = strstr (path, busid);
|
|
|
|
if (!str || str <= path || str[-1] != '/')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
path_length = strlen (path);
|
|
|
|
if (str + busid_length >= path + path_length)
|
|
|
|
continue;
|
2014-09-24 08:14:24 +00:00
|
|
|
if (strncmp (&str[busid_length], "/drm/card", 9) != 0 &&
|
|
|
|
strncmp (&str[busid_length], "/drm/renderD", 12) != 0)
|
2013-12-20 12:27:07 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
device = udev_device_new_from_syspath (udev, path);
|
|
|
|
if (!device)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
path = udev_device_get_devnode (device);
|
|
|
|
priv->device_path = g_strdup (path);
|
|
|
|
udev_device_unref (device);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
success = TRUE;
|
2012-08-01 13:44:02 +00:00
|
|
|
|
|
|
|
end:
|
2013-12-20 12:27:07 +00:00
|
|
|
if (e)
|
|
|
|
udev_enumerate_unref (e);
|
|
|
|
if (udev)
|
|
|
|
udev_unref (udev);
|
|
|
|
return success;
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
2013-05-07 09:39:34 +00:00
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_drm_bind_display (GstVaapiDisplay * display,
|
2013-05-07 09:39:34 +00:00
|
|
|
gpointer native_display)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayDRMPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
2012-08-01 13:44:02 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
priv->drm_device = GPOINTER_TO_INT (native_display);
|
|
|
|
priv->use_foreign_display = TRUE;
|
2012-08-01 13:44:02 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!set_device_path_from_fd (display, priv->drm_device))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
2013-05-07 09:39:34 +00:00
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_drm_open_display (GstVaapiDisplay * display,
|
|
|
|
const gchar * name)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayDRMPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
2014-12-02 10:23:29 +00:00
|
|
|
GstVaapiDisplayCache *const cache = GST_VAAPI_DISPLAY_CACHE (display);
|
2013-12-20 12:27:07 +00:00
|
|
|
const GstVaapiDisplayInfo *info;
|
|
|
|
|
|
|
|
if (!set_device_path (display, name))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
info = gst_vaapi_display_cache_lookup_by_name (cache, priv->device_path,
|
2014-12-10 17:02:55 +00:00
|
|
|
g_display_types);
|
2013-12-20 12:27:07 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_drm_close_display (GstVaapiDisplay * display)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayDRMPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
2012-08-01 13:44:02 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (priv->drm_device >= 0) {
|
|
|
|
if (!priv->use_foreign_display)
|
|
|
|
close (priv->drm_device);
|
|
|
|
priv->drm_device = -1;
|
|
|
|
}
|
2012-08-01 13:44:02 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (priv->device_path) {
|
|
|
|
g_free (priv->device_path);
|
|
|
|
priv->device_path = NULL;
|
|
|
|
}
|
2012-08-01 13:44:02 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (priv->device_path_default) {
|
|
|
|
g_free (priv->device_path_default);
|
|
|
|
priv->device_path_default = NULL;
|
|
|
|
}
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_drm_get_display_info (GstVaapiDisplay * display,
|
|
|
|
GstVaapiDisplayInfo * info)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayDRMPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
2014-12-02 10:23:29 +00:00
|
|
|
GstVaapiDisplayCache *const cache = GST_VAAPI_DISPLAY_CACHE (display);
|
2013-12-20 12:27:07 +00:00
|
|
|
const GstVaapiDisplayInfo *cached_info;
|
|
|
|
|
|
|
|
/* Return any cached info even if child has its own VA display */
|
2014-03-07 13:50:14 +00:00
|
|
|
cached_info = gst_vaapi_display_cache_lookup_by_native_display (cache,
|
2014-12-10 17:02:55 +00:00
|
|
|
GINT_TO_POINTER (priv->drm_device), g_display_types);
|
2013-12-20 12:27:07 +00:00
|
|
|
if (cached_info) {
|
|
|
|
*info = *cached_info;
|
2012-08-01 13:44:02 +00:00
|
|
|
return TRUE;
|
2013-12-20 12:27:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, create VA display if there is none already */
|
|
|
|
info->native_display = GINT_TO_POINTER (priv->drm_device);
|
|
|
|
info->display_name = priv->device_path;
|
|
|
|
if (!info->va_display) {
|
|
|
|
info->va_display = vaGetDisplayDRM (priv->drm_device);
|
|
|
|
if (!info->va_display)
|
|
|
|
return FALSE;
|
|
|
|
info->display_type = GST_VAAPI_DISPLAY_TYPE_DRM;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
2014-12-10 17:12:24 +00:00
|
|
|
static GstVaapiWindow *
|
|
|
|
gst_vaapi_display_drm_create_window (GstVaapiDisplay * display, GstVaapiID id,
|
|
|
|
guint width, guint height)
|
|
|
|
{
|
|
|
|
return id != GST_VAAPI_ID_INVALID ?
|
|
|
|
NULL : gst_vaapi_window_drm_new (display, width, height);
|
|
|
|
}
|
|
|
|
|
2013-05-07 09:39:34 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_drm_init (GstVaapiDisplay * display)
|
2013-05-07 09:39:34 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayDRMPrivate *const priv =
|
|
|
|
GST_VAAPI_DISPLAY_DRM_PRIVATE (display);
|
2013-05-07 09:39:34 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
priv->drm_device = -1;
|
2013-05-07 09:39:34 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 13:44:02 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_drm_class_init (GstVaapiDisplayDRMClass * klass)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiMiniObjectClass *const object_class =
|
|
|
|
GST_VAAPI_MINI_OBJECT_CLASS (klass);
|
|
|
|
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
|
|
|
|
|
|
|
|
gst_vaapi_display_class_init (&klass->parent_class);
|
|
|
|
|
|
|
|
object_class->size = sizeof (GstVaapiDisplayDRM);
|
2014-12-10 17:02:55 +00:00
|
|
|
dpy_class->display_type = GST_VAAPI_DISPLAY_TYPE_DRM;
|
2013-12-20 12:27:07 +00:00
|
|
|
dpy_class->init = gst_vaapi_display_drm_init;
|
|
|
|
dpy_class->bind_display = gst_vaapi_display_drm_bind_display;
|
|
|
|
dpy_class->open_display = gst_vaapi_display_drm_open_display;
|
|
|
|
dpy_class->close_display = gst_vaapi_display_drm_close_display;
|
|
|
|
dpy_class->get_display = gst_vaapi_display_drm_get_display_info;
|
2014-12-10 17:12:24 +00:00
|
|
|
dpy_class->create_window = gst_vaapi_display_drm_create_window;
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
2013-05-07 09:39:34 +00:00
|
|
|
static inline const GstVaapiDisplayClass *
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_drm_class (void)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
static GstVaapiDisplayDRMClass g_class;
|
|
|
|
static gsize g_class_init = FALSE;
|
|
|
|
|
|
|
|
if (g_once_init_enter (&g_class_init)) {
|
|
|
|
gst_vaapi_display_drm_class_init (&g_class);
|
|
|
|
g_once_init_leave (&g_class_init, TRUE);
|
|
|
|
}
|
|
|
|
return GST_VAAPI_DISPLAY_CLASS (&g_class);
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_drm_new:
|
|
|
|
* @device_path: the DRM device path
|
|
|
|
*
|
|
|
|
* Opens an DRM file descriptor using @device_path and returns a newly
|
|
|
|
* allocated #GstVaapiDisplay object. The DRM display will be cloed
|
|
|
|
* when the reference count of the object reaches zero.
|
|
|
|
*
|
|
|
|
* If @device_path is NULL, the DRM device path will be automatically
|
|
|
|
* determined as the first positive match in the list of available DRM
|
|
|
|
* devices.
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated #GstVaapiDisplay object
|
|
|
|
*/
|
|
|
|
GstVaapiDisplay *
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_drm_new (const gchar * device_path)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2014-09-24 08:14:24 +00:00
|
|
|
GstVaapiDisplay *display;
|
|
|
|
guint types[2], i, num_types = 0;
|
|
|
|
|
2015-04-14 09:54:54 +00:00
|
|
|
g_mutex_lock (&g_drm_device_type_lock);
|
2014-09-24 08:14:24 +00:00
|
|
|
if (device_path)
|
|
|
|
types[num_types++] = 0;
|
|
|
|
else if (g_drm_device_type)
|
|
|
|
types[num_types++] = g_drm_device_type;
|
|
|
|
else {
|
|
|
|
types[num_types++] = DRM_DEVICE_RENDERNODES;
|
|
|
|
types[num_types++] = DRM_DEVICE_LEGACY;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < num_types; i++) {
|
|
|
|
g_drm_device_type = types[i];
|
|
|
|
display = gst_vaapi_display_new (gst_vaapi_display_drm_class (),
|
|
|
|
GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME, (gpointer) device_path);
|
|
|
|
if (display || device_path)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_mutex_unlock (&g_drm_device_type_lock);
|
|
|
|
return display;
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_drm_new_with_device:
|
|
|
|
* @device: an open DRM device (file descriptor)
|
|
|
|
*
|
|
|
|
* Creates a #GstVaapiDisplay based on the open DRM @device. The
|
|
|
|
* caller still owns the device file descriptor and must call close()
|
|
|
|
* when all #GstVaapiDisplay references are released. Doing so too
|
|
|
|
* early can yield undefined behaviour.
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated #GstVaapiDisplay object
|
|
|
|
*/
|
|
|
|
GstVaapiDisplay *
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_drm_new_with_device (gint device)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (device >= 0, NULL);
|
2012-08-01 13:44:02 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return gst_vaapi_display_new (gst_vaapi_display_drm_class (),
|
|
|
|
GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY, GINT_TO_POINTER (device));
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_drm_get_device:
|
|
|
|
* @display: a #GstVaapiDisplayDRM
|
|
|
|
*
|
|
|
|
* Returns the underlying DRM device file descriptor that was created
|
|
|
|
* by gst_vaapi_display_drm_new() or that was bound from
|
|
|
|
* gst_vaapi_display_drm_new_with_device().
|
|
|
|
*
|
|
|
|
* Return value: the DRM file descriptor attached to @display
|
|
|
|
*/
|
|
|
|
gint
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_drm_get_device (GstVaapiDisplayDRM * display)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_DRM (display), -1);
|
2012-08-01 13:44:02 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return GST_VAAPI_DISPLAY_DRM_DEVICE (display);
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_drm_get_device_path:
|
|
|
|
* @display: a #GstVaapiDisplayDRM
|
|
|
|
*
|
|
|
|
* Returns the underlying DRM device path name was created by
|
|
|
|
* gst_vaapi_display_drm_new() or that was bound from
|
|
|
|
* gst_vaapi_display_drm_new_with_device().
|
|
|
|
*
|
|
|
|
* Note: the #GstVaapiDisplayDRM object owns the resulting string, so
|
|
|
|
* it shall not be deallocated.
|
|
|
|
*
|
|
|
|
* Return value: the DRM device path name attached to @display
|
|
|
|
*/
|
|
|
|
const gchar *
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_drm_get_device_path (GstVaapiDisplayDRM * display)
|
2012-08-01 13:44:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_DRM (display), NULL);
|
2012-08-01 13:44:02 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return get_device_path (GST_VAAPI_DISPLAY_CAST (display));
|
2012-08-01 13:44:02 +00:00
|
|
|
}
|