|
|
259529d |
From f36a392a969a0b3045f2832495fc1ccfd4bf90e5 Mon Sep 17 00:00:00 2001
|
|
|
259529d |
From: "Xiang, Haihao" <haihao.xiang@intel.com>
|
|
|
259529d |
Date: Fri, 23 Jun 2017 09:13:01 +0800
|
|
|
259529d |
Subject: [PATCH 01/02] vainfo: add an option "--device" to specify a drm
|
|
|
259529d |
device
|
|
|
259529d |
|
|
|
259529d |
This option is only available when the drm display is specified in the
|
|
|
259529d |
command line
|
|
|
259529d |
|
|
|
259529d |
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
|
|
|
259529d |
---
|
|
|
259529d |
common/va_display.c | 24 ++++++++++++++++++++++++
|
|
|
259529d |
common/va_display_drm.c | 21 +++++++++++++++++++++
|
|
|
259529d |
2 files changed, 45 insertions(+)
|
|
|
259529d |
|
|
|
259529d |
diff --git a/common/va_display.c b/common/va_display.c
|
|
|
259529d |
index 68aa43f..30a25ae 100644
|
|
|
259529d |
--- a/common/va_display.c
|
|
|
259529d |
+++ b/common/va_display.c
|
|
|
259529d |
@@ -56,6 +56,7 @@ static const VADisplayHooks *g_display_hooks_available[] = {
|
|
|
259529d |
};
|
|
|
259529d |
|
|
|
259529d |
static const char *g_display_name;
|
|
|
259529d |
+const char *g_drm_device_name;
|
|
|
259529d |
|
|
|
259529d |
static const char *
|
|
|
259529d |
get_display_name(int argc, char *argv[])
|
|
|
259529d |
@@ -76,6 +77,25 @@ get_display_name(int argc, char *argv[])
|
|
|
259529d |
return display_name;
|
|
|
259529d |
}
|
|
|
259529d |
|
|
|
259529d |
+static const char *
|
|
|
259529d |
+get_drm_device_name(int argc, char *argv[])
|
|
|
259529d |
+{
|
|
|
259529d |
+ const char *device_name = NULL;
|
|
|
259529d |
+ int i;
|
|
|
259529d |
+
|
|
|
259529d |
+ for (i = 1; i < argc; i++) {
|
|
|
259529d |
+ if (argv[i] && (strcmp(argv[i], "--device") != 0))
|
|
|
259529d |
+ continue;
|
|
|
259529d |
+ argv[i] = NULL;
|
|
|
259529d |
+
|
|
|
259529d |
+ if (++i < argc) {
|
|
|
259529d |
+ device_name = argv[i];
|
|
|
259529d |
+ argv[i] = NULL;
|
|
|
259529d |
+ }
|
|
|
259529d |
+ }
|
|
|
259529d |
+ return device_name;
|
|
|
259529d |
+}
|
|
|
259529d |
+
|
|
|
259529d |
static void
|
|
|
259529d |
print_display_names(void)
|
|
|
259529d |
{
|
|
|
259529d |
@@ -104,6 +124,7 @@ void
|
|
|
259529d |
va_init_display_args(int *argc, char *argv[])
|
|
|
259529d |
{
|
|
|
259529d |
const char *display_name;
|
|
|
259529d |
+ const char *device_name;
|
|
|
259529d |
|
|
|
259529d |
display_name = get_display_name(*argc, argv);
|
|
|
259529d |
if (display_name && strcmp(display_name, "help") == 0) {
|
|
|
259529d |
@@ -112,6 +133,9 @@ va_init_display_args(int *argc, char *argv[])
|
|
|
259529d |
}
|
|
|
259529d |
g_display_name = display_name;
|
|
|
259529d |
|
|
|
259529d |
+ if (g_display_name && strcmp(g_display_name, "drm") == 0)
|
|
|
259529d |
+ g_drm_device_name = get_drm_device_name(*argc, argv);
|
|
|
259529d |
+
|
|
|
259529d |
sanitize_args(argc, argv);
|
|
|
259529d |
}
|
|
|
259529d |
|
|
|
259529d |
diff --git a/common/va_display_drm.c b/common/va_display_drm.c
|
|
|
259529d |
index b6394cd..4d9c656 100644
|
|
|
259529d |
--- a/common/va_display_drm.c
|
|
|
259529d |
+++ b/common/va_display_drm.c
|
|
|
259529d |
@@ -23,6 +23,7 @@
|
|
|
259529d |
*/
|
|
|
259529d |
|
|
|
259529d |
#include <stdio.h>
|
|
|
259529d |
+#include <stdlib.h>
|
|
|
259529d |
#include <unistd.h>
|
|
|
259529d |
#include <fcntl.h>
|
|
|
259529d |
#ifdef IN_LIBVA
|
|
|
259529d |
@@ -33,6 +34,7 @@
|
|
|
259529d |
#include "va_display.h"
|
|
|
259529d |
|
|
|
259529d |
static int drm_fd = -1;
|
|
|
259529d |
+extern const char *g_drm_device_name;
|
|
|
259529d |
|
|
|
259529d |
static VADisplay
|
|
|
259529d |
va_open_display_drm(void)
|
|
|
259529d |
@@ -46,6 +48,25 @@ va_open_display_drm(void)
|
|
|
259529d |
NULL
|
|
|
259529d |
};
|
|
|
259529d |
|
|
|
259529d |
+ if (g_drm_device_name) {
|
|
|
259529d |
+ drm_fd = open(g_drm_device_name, O_RDWR);
|
|
|
259529d |
+ if (drm_fd < 0) {
|
|
|
259529d |
+ printf("Failed to open the given device!\n");
|
|
|
259529d |
+ exit(1);
|
|
|
259529d |
+ return NULL;
|
|
|
259529d |
+ }
|
|
|
259529d |
+
|
|
|
259529d |
+ va_dpy = vaGetDisplayDRM(drm_fd);
|
|
|
259529d |
+ if (va_dpy)
|
|
|
259529d |
+ return va_dpy;
|
|
|
259529d |
+
|
|
|
259529d |
+ printf("Failed to a DRM display for the given device\n");
|
|
|
259529d |
+ close(drm_fd);
|
|
|
259529d |
+ drm_fd = -1;
|
|
|
259529d |
+ exit(1);
|
|
|
259529d |
+ return NULL;
|
|
|
259529d |
+ }
|
|
|
259529d |
+
|
|
|
259529d |
for (i = 0; drm_device_paths[i]; i++) {
|
|
|
259529d |
drm_fd = open(drm_device_paths[i], O_RDWR);
|
|
|
259529d |
if (drm_fd < 0)
|
|
|
259529d |
--
|
|
|
259529d |
2.13.6
|
|
|
259529d |
|