~kennylevinsen/seatd-devel

seatd: drm: Support drm-subtree drivers on FreeBSD v1 SUPERSEDED

~jrtc27: 1
 drm: Support drm-subtree drivers on FreeBSD

 1 files changed, 10 insertions(+), 10 deletions(-)
#889294 running alpine.yml
#889295 running archlinux.yml
#889296 running freebsd.yml
#889297 running netbsd.yml
On Wed, Nov 30 2022 at 07:43:32 PM +00:00:00, Jessica Clarke 
<jrtc27@jrtc27.com> wrote:
Next
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~kennylevinsen/seatd-devel/patches/37035/mbox | git am -3
Learn more about email & git

[PATCH seatd] drm: Support drm-subtree drivers on FreeBSD Export this patch

From: Jessica Clarke <jrtc27@jrtc27.com>

The drm-kmod drivers use linuxkpi and end up with /dev/drm being the
canonical path for the devices, but the drm-subtree drivers use drmkpi
which has them appear under /dev/dri like Linux. Thus, adapt path_is_drm
to recognise both on FreeBSD.
---
 common/drm.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/drm.c b/common/drm.c
index 45ed7e5..cb57a0f 100644
--- a/common/drm.c
+++ b/common/drm.c
@@ -11,6 +11,7 @@
#define DRM_IOCTL_DROP_MASTER DRM_IO(0x1f)

#define STRLEN(s) ((sizeof(s) / sizeof(s[0])) - 1)
#define STR_HAS_PREFIX(prefix, s) (strncmp(prefix, s, STRLEN(prefix)) == 0)

int drm_set_master(int fd) {
	return ioctl(fd, DRM_IOCTL_SET_MASTER, 0);
@@ -20,17 +21,16 @@ int drm_drop_master(int fd) {
	return ioctl(fd, DRM_IOCTL_DROP_MASTER, 0);
}

#if defined(__linux__) || defined(__NetBSD__)
#if defined(__linux__) || defined(__NetBSD__) || defined(__FreeBSD__)
int path_is_drm(const char *path) {
	static const char prefix[] = "/dev/dri/";
	static const int prefixlen = STRLEN(prefix);
	return strncmp(prefix, path, prefixlen) == 0;
}
#elif defined(__FreeBSD__)
int path_is_drm(const char *path) {
	static const char prefix[] = "/dev/drm/";
	static const int prefixlen = STRLEN(prefix);
	return strncmp(prefix, path, prefixlen) == 0;
	if (STR_HAS_PREFIX("/dev/dri/", path))
		return 1;
#ifdef __FreeBSD__
	/* Some drivers have /dev/dri/X symlinked to /dev/drm/X */
	if (STR_HAS_PREFIX("/dev/drm/", path))
		return 1;
#endif
	return 0;
}
#else
#error Unsupported platform
-- 
2.34.5
Ah, is this something new or did I just completely miss it when working 
on FreeBSD?

CI on mailing list patches was down for a moment, but here is a manual 
rerun on alpine: https://builds.sr.ht/~kennylevinsen/job/895142 - fails 
on check-format.

On Wed, Nov 23 2022 at 02:12:42 AM +00:00:00, ~jrtc27 
<jrtc27@git.sr.ht> wrote: