drmGetRenderDeviceNameFromFd doesn't work on FreeBSD if fd isn't from render node
CC @manu
Updating libdrm to upstream version partially broke --gpu-context=drm
in mpv.
mpv output
--- before
+++ after
@@ -1,74 +1,75 @@
$ mpv --no-config --gpu-context=drm --hwdec=vaapi --msg-level=vo/gpu=v /path/to/foo.mp4
(+) Video --vid=1 (*) (h264 852x480 28.366fps)
(+) Audio --aid=1 (*) (aac 2ch 48000Hz)
[vo/gpu/opengl] Initializing GPU context 'drm'
[vo/gpu/opengl] Initializing KMS
-[vo/gpu/opengl] Device name: /dev/dri/card0
+[vo/gpu/opengl] Device name: /dev/drm/0
[vo/gpu/opengl] Driver: i915 1.6.0 (20181204)
[vo/gpu/opengl/kms] Connector 97 currently connected to encoder 96
[vo/gpu/opengl/kms] Selected Encoder 96 with CRTC 47
[vo/gpu/opengl/kms] Selected mode: 3840x2160 (3840x2160@60.00Hz)
[vo/gpu/opengl] DRM Atomic support found
[vo/gpu/opengl/kms] Using primary plane 30 as draw plane
[vo/gpu/opengl/kms] Using overlay plane 37 as drmprime plane
[vo/gpu] GBM_FORMAT_ARGB8888 supported by draw plane.
[vo/gpu] Creating GBM device
[vo/gpu] Initializing GBM surface (3840 x 2160)
[vo/gpu/opengl] Initializing EGL
[vo/gpu/opengl] EGL_VERSION=1.4
[vo/gpu/opengl] EGL_VENDOR=Mesa Project
[vo/gpu/opengl] EGL_CLIENT_APIS=OpenGL OpenGL_ES
[vo/gpu/opengl] Trying to create Desktop OpenGL context.
[vo/gpu/opengl] Attempting to find EGLConfig matching GBM_FORMAT_ARGB8888
[vo/gpu/opengl] Found matching EGLConfig for GBM_FORMAT_ARGB8888
[vo/gpu/opengl] Initializing EGL surface
[vo/gpu] GL_VERSION='4.6 (Core Profile) Mesa 20.1.0-devel'
[vo/gpu] Detected desktop OpenGL 4.6.
[vo/gpu] GL_VENDOR='Intel Open Source Technology Center'
[vo/gpu] GL_RENDERER='Mesa DRI Intel(R) HD Graphics 530 (SKL GT2)'
[vo/gpu] GL_SHADING_LANGUAGE_VERSION='4.60'
[vo/gpu/opengl] Preparing framebuffer
-[vo/gpu/opengl] Opening render node "/dev/dri/renderD128"
+[vo/gpu/opengl] Opening render node "/dev/dri/renderD0"
+[vo/gpu/opengl] Cannot open render node "/dev/dri/renderD0": No such file or directory. VAAPI hwdec will be disabled
[vo/gpu] Testing FBO format rgba16f
[vo/gpu] Using FBO format rgba16f.
[vo/gpu] No advanced processing required. Enabling dumb mode.
[vo/gpu] Assuming 60.000000 FPS for display sync.
[vo/gpu] Loading hwdec driver 'vaapi-egl'
[vo/gpu/vaapi-egl] using VAAPI EGL interop
[vo/gpu/vaapi-egl] Trying to open a x11 VA display...
[vo/gpu/vaapi-egl] Trying to open a wayland VA display...
[vo/gpu/vaapi-egl] Trying to open a drm VA display...
-[vo/gpu/vaapi-egl/vaapi] Initialized VAAPI: version 1.7
-[vo/gpu/vaapi-egl] Going to probe surface formats (may log bogus errors)...
-[ffmpeg] AVHWDeviceContext: Failed to query surface attributes: 20 (the requested function is not implemented).
-[vo/gpu/vaapi-egl] failed to retrieve libavutil frame constraints
-[vo/gpu/vaapi-egl] Done probing surface formats.
+[vo/gpu/vaapi-egl] Could not create a VA display.
+[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'vdpau-gl'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'drmprime-drm'
[vo/gpu/drmprime-drm] Using primary plane 30 as draw plane
[vo/gpu/drmprime-drm] Using overlay plane 37 as drmprime plane
-Using hardware decoding (vaapi).
AO: [pulse] 48000Hz stereo 2ch float
-VO: [gpu] 852x480 vaapi[nv12]
-[vo/gpu] reconfig to 852x480 vaapi[nv12] bt.601/bt.601-525/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
+VO: [gpu] 852x480 yuv420p
+[vo/gpu] reconfig to 852x480 yuv420p bt.601/bt.601-525/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[vo/gpu] Resize: 3840x2160
[vo/gpu] Window size: 3840x2160 (Borders: l=0 t=0 r=0 b=0)
[vo/gpu] Video source: 852x480 (1:1)
[vo/gpu] Video display: (0, 0) 852x480 -> (3, 0) 3834x2160
[vo/gpu] Video scale: 4.500000/4.500000
[vo/gpu] OSD borders: l=3 t=0 r=3 b=0
[vo/gpu] Video borders: l=3 t=0 r=3 b=0
[vo/gpu] Reported display depth: 8
+[vo/gpu] Texture for plane 0: 852x480
+[vo/gpu] Texture for plane 1: 426x240
+[vo/gpu] Texture for plane 2: 426x240
[vo/gpu] Testing FBO format rgba16f
[vo/gpu] Using FBO format rgba16f.
[vo/gpu] No advanced processing required. Enabling dumb mode.
+[vo/gpu] DR enabled: yes
AV: 00:00:01 / 00:25:56 (0%) A-V: 0.000
[vo/gpu] Reallocating OSD texture to 4096x256.
AV: 00:02:11 / 00:25:56 (8%) A-V: 0.004
[vo/gpu] Releasing VT
AV: 00:02:13 / 00:25:56 (8%) A-V: 0.000
[vo/gpu] Acquiring VT
AV: 00:02:14 / 00:25:56 (8%) A-V: -0.000 Dropped: 1
Exiting... (Quit)
Test case:
$ cc a.c $(pkg-config --cflags --libs libdrm)
$ ./a.out
/dev/dri/renderD0
$ cat a.c
#include <xf86drm.h>
#include <fcntl.h>
#include <stdio.h>
int main()
{
int fd = open("/dev/dri/card0", O_RDWR);
printf("%s\n", drmGetRenderDeviceNameFromFd(fd));
return 0;
}
Edited by Jan Beich