VADriverContextP const pDriverContext = pDisplayContext->pDriverContext;
return (pDriverContext &&
- pDriverContext->display_type == VA_DISPLAY_DRM);
+ ((pDriverContext->display_type & VA_DISPLAY_MAJOR_MASK) ==
+ VA_DISPLAY_DRM));
}
static void
if (status != VA_STATUS_SUCCESS)
return status;
- ret = drmGetMagic(drm_state->fd, &magic);
- if (ret < 0)
- return VA_STATUS_ERROR_OPERATION_FAILED;
-
- if (!va_drm_is_authenticated(drm_state->fd)) {
- if (!va_drm_authenticate(drm_state->fd, magic))
- return VA_STATUS_ERROR_OPERATION_FAILED;
- if (!va_drm_is_authenticated(drm_state->fd))
+ /* Authentication is only needed for a legacy DRM device */
+ if (ctx->display_type != VA_DISPLAY_DRM_RENDERNODES) {
+ ret = drmGetMagic(drm_state->fd, &magic);
+ if (ret < 0)
return VA_STATUS_ERROR_OPERATION_FAILED;
+
+ if (!va_drm_is_authenticated(drm_state->fd)) {
+ if (!va_drm_authenticate(drm_state->fd, magic))
+ return VA_STATUS_ERROR_OPERATION_FAILED;
+ if (!va_drm_is_authenticated(drm_state->fd))
+ return VA_STATUS_ERROR_OPERATION_FAILED;
+ }
}
drm_state->auth_type = VA_DRM_AUTH_CUSTOM;
VADisplayContextP pDisplayContext = NULL;
VADriverContextP pDriverContext = NULL;
struct drm_state *drm_state = NULL;
+ int is_render_nodes;
- if (fd < 0)
+ if (fd < 0 || (is_render_nodes = VA_DRM_IsRenderNodeFd(fd)) < 0)
return NULL;
/* Create new entry */
if (!pDriverContext)
goto error;
pDriverContext->native_dpy = NULL;
- pDriverContext->display_type = VA_DISPLAY_DRM;
+ pDriverContext->display_type = is_render_nodes ?
+ VA_DISPLAY_DRM_RENDERNODES : VA_DISPLAY_DRM;
pDriverContext->drm_state = drm_state;
pDisplayContext = calloc(1, sizeof(*pDisplayContext));
#include "sysdeps.h"
#include <xf86drm.h>
+#include <sys/stat.h>
#include "va_drm_utils.h"
#include "va_drmcommon.h"
*driver_name_ptr = driver_name;
return VA_STATUS_SUCCESS;
}
+
+/* Checks whether the file descriptor is a DRM Render-Nodes one */
+int
+VA_DRM_IsRenderNodeFd(int fd)
+{
+ struct stat st;
+ const char *name;
+
+ /* Check by device node */
+ if (fstat(fd, &st) == 0)
+ return S_ISCHR(st.st_mode) && (st.st_rdev & 0x80);
+
+ /* Check by device name */
+ name = drmGetDeviceNameFromFd(fd);
+ if (name)
+ return strncmp(name, "/dev/dri/renderD", 16) == 0;
+
+ /* Unrecoverable error */
+ return -1;
+}
VA_DISPLAY_ANDROID = 0x20,
/** \brief VA/DRM API is used, through vaGetDisplayDRM() entry-point. */
VA_DISPLAY_DRM = 0x30,
+ /** \brief VA/DRM API is used, with a render-node device path */
+ VA_DISPLAY_DRM_RENDERNODES = (VA_DISPLAY_DRM | (1 << 0)),
/** \brief VA/Wayland API is used, through vaGetDisplayWl() entry-point. */
VA_DISPLAY_WAYLAND = 0x40,
};