Skip to content

Commit bfb6b98

Browse files
committed
exclude vgem node and invalid drm node in vainfo
call drm function to avoid invalid node check the name of vgem Signed-off-by: Carl Zhang <[email protected]>
1 parent dc4e5a8 commit bfb6b98

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

common/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ endif
4141

4242
if USE_DRM
4343
source_c += va_display_drm.c
44-
libva_display_cflags += $(DRM_CFLAGS) $(LIBVA_DRM_CFLAGS)
44+
libva_display_cflags += $(DRM_CFLAGS) $(LIBVA_DRM_CFLAGS) $(DRM_CFLAGS)
4545
libva_display_libs += $(DRM_LIBS) $(LIBVA_DRM_LIBS)
4646
endif
4747

common/va_display_drm.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424

2525
#include <stdio.h>
2626
#include <stdlib.h>
27+
#include <string.h>
2728
#include <unistd.h>
2829
#include <fcntl.h>
2930
#ifdef IN_LIBVA
3031
# include "va/drm/va_drm.h"
3132
#else
3233
# include <va/va_drm.h>
3334
#endif
35+
#include <xf86drm.h>
3436
#include "va_display.h"
3537

3638
static int drm_fd = -1;
@@ -41,10 +43,12 @@ va_open_display_drm(void)
4143
{
4244
VADisplay va_dpy;
4345
int i;
44-
46+
drmVersionPtr version;
4547
static const char *drm_device_paths[] = {
4648
"/dev/dri/renderD128",
4749
"/dev/dri/card0",
50+
"/dev/dri/renderD129",
51+
"/dev/dri/card1",
4852
NULL
4953
};
5054

@@ -72,6 +76,18 @@ va_open_display_drm(void)
7276
if (drm_fd < 0)
7377
continue;
7478

79+
version = drmGetVersion(drm_fd);
80+
if (!version) {
81+
close(drm_fd);
82+
continue;
83+
}
84+
if (!strncmp(version->name, "vgem", 4)) {
85+
drmFreeVersion(version);
86+
close(drm_fd);
87+
continue;
88+
}
89+
drmFreeVersion(version);
90+
7591
va_dpy = vaGetDisplayDRM(drm_fd);
7692
if (va_dpy)
7793
return va_dpy;

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ AM_CONDITIONAL(USE_SSP, test "$ssp_cc" = "yes")
144144

145145
# Check for DRM (mandatory)
146146
PKG_CHECK_MODULES([LIBVA_DRM], [libva-drm])
147+
PKG_CHECK_MODULES([DRM], [libdrm])
147148

148149
# Check for libva (for dynamic linking)
149150
LIBVA_API_MIN_VERSION=libva_api_min_version

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ if get_option('drm') != 'false'
2121
require_drm = get_option('drm') == 'true'
2222
drm_deps = [
2323
dependency('libva-drm', required: require_drm),
24+
dependency('drm', required: require_drm),
2425
]
2526
use_drm = true
2627
foreach d : drm_deps

0 commit comments

Comments
 (0)