Skip to contentSkip to conversation

xf86drm: Make drmNodeIsDRM() public.

PATCH In review Christopher James Halse Rogers 4 participants 4 messages Nov 20, 2018 – Dec 18, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xf86drm: Make drmNodeIsDRM() public.

I have wanted this code in Mir, so it's plausibly useful elsewhere, particularly if the DRM device major number is going to become dynamic.

---
 xf86drm.c | 2 +-
 xf86drm.h | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
xf86drm.c +1 -1
index 10df682b..f32cb1bb 100644
@@ -2767,7 +2767,7 @@ drm_public char *drmGetDeviceNameFromFd(int fd)
     return strdup(name);
 }
 
-static bool drmNodeIsDRM(int maj, int min)
+drm_public bool drmNodeIsDRM(int maj, int min)
 {
 #ifdef __linux__
     char path[64];
xf86drm.h +3 -0
index 7773d71a..6dc92180 100644
@@ -37,6 +37,7 @@
 #include <stdarg.h>
 #include <sys/types.h>
 #include <stdint.h>
+#include <stdbool.h>
 #include <drm.h>
 
 #if defined(__cplusplus)
@@ -783,6 +784,8 @@ extern int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle);
 extern char *drmGetPrimaryDeviceNameFromFd(int fd);
 extern char *drmGetRenderDeviceNameFromFd(int fd);
 
+extern bool drmNodeIsDRM(int major, int minor);
+
 #define DRM_BUS_PCI       0
 #define DRM_BUS_USB       1
 #define DRM_BUS_PLATFORM  2
Signature · 6 lines
2.19.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Hi Christopher,

Quoted 5 lines · Christopher James Halse Rogers

I have wanted this code in Mir, so it's plausibly useful elsewhere, particularly if the DRM device major number is going to become dynamic.

Can you elaborate/link to the code that uses the major/minor? Fiddling with those manually is rather error prone most often than not.

Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 11 lines · Emil Velikov

Hi Christopher,

Quoted 5 lines · Christopher James Halse Rogers

I have wanted this code in Mir, so it's plausibly useful elsewhere, particularly if the DRM device major number is going to become dynamic.

Can you elaborate/link to the code that uses the major/minor? Fiddling with those manually is rather error prone most often than not.

Yeah, I think this shouldn't be part of the API.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
In reply to Emil Velikov
Quoted 11 lines · Emil Velikov

Hi Christopher,

Quoted 5 lines · Christopher James Halse Rogers

I have wanted this code in Mir, so it's plausibly useful elsewhere, particularly if the DRM device major number is going to become dynamic.

Can you elaborate/link to the code that uses the major/minor? Fiddling with those manually is rather error prone most often than not.

We have an internal API that mirrors that of logind - taking a (major,minor) pair and returning a usable fd. For input devices, that just means opened O_NONBLOCK; for DRM devices it means calling SetMaster.

Here's the relevant (non-logind) implementation: https://github.com/MirServer/mir/blob/master/src/server/console/linux_virtual_terminal.cpp#L634

Since we by necessity end up pulling out the devnode I guess we could match on a /dev/dri prefix instead. I just noticed this function while doing the drmIsMaster patch and thought it would be convenient for us!

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel