Created attachment 203295 [details]
For libva DRM backend to reliably support headless transcoding I need a way to check if the opened device is a render node. drmGetNodeTypeFromFd() == DRM_NODE_RENDER appears to be the correct way but it doesn't work on FreeBSD.
$ pkg install libdrm pkgconf
$ cc test.c -o test $(pkg-config --cflags --libs libdrm)
unknown (-1) node
Nevermind. I've found a workaround.
Created attachment 203343 [details]
Nah, libva cannot get rid of Linux-specific check without drmGetNodeTypeFromFd. Mesa also wants to check DRM_NODE_RENDER.
Damn, this file is a mess for FreeBSD ...
Anyway I would prefer to have strrchr instead of a for loop and strtok :
int type = drmGetNodeType(strrchr(name, '/') + 1);
Do you plan to submit that upstream ?
(In reply to Emmanuel Vadot from comment #3)
> int type = drmGetNodeType(strrchr(name, '/') + 1);
Works for me.
> Do you plan to submit that upstream ?
Where? drmGetNodeTypeFromFd doesn't support devfs-based systems upstream.
General libdrm upstreaming is outside of scope for this bug. Figuring it out is the maintainer's job. I'm only responsible for libva atm but even there slow upstream feedback doesn't look exciting.
Yeah I saw after that none of that is upstreamed yet.
I may do it but not for now.
Created attachment 203347 [details]
Switch to strrchr() per comment 3. Uploading mainly to avoid ambiguity what was tested.
Looks good to me, let's wait for X11 now.
A commit references this bug:
Date: Sun Jun 30 17:39:05 UTC 2019
New revision: 505442
graphics/libdrm: fix drmGetNodeTypeFromFd
Fix drmGetNodeTypeFromFd, this should have been part of r505441
Submitted by: jbeich
Reviewed by: manu
Committed. No need to merge to quarterly, new branch tonight.