|
34 | 34 | #include <fcntl.h> |
35 | 35 | #include <unistd.h> |
36 | 36 | #include <linux/input.h> |
| 37 | +#ifdef __linux__ |
37 | 38 | #include <linux/vt.h> |
| 39 | +#endif |
38 | 40 | #include <assert.h> |
39 | 41 | #include <sys/mman.h> |
40 | 42 | #include <dlfcn.h> |
@@ -3739,11 +3741,26 @@ drm_device_is_kms(struct drm_backend *b, struct udev_device *device) |
3739 | 3741 | static struct udev_device* |
3740 | 3742 | find_primary_gpu(struct drm_backend *b, const char *seat) |
3741 | 3743 | { |
| 3744 | + struct udev_device *device; |
| 3745 | +#ifndef __FreeBSD__ |
| 3746 | + struct udev_device *drm_device, *pci; |
3742 | 3747 | struct udev_enumerate *e; |
3743 | 3748 | struct udev_list_entry *entry; |
3744 | 3749 | const char *path, *device_seat, *id; |
3745 | | - struct udev_device *device, *drm_device, *pci; |
| 3750 | +#endif |
3746 | 3751 |
|
| 3752 | +#ifdef __FreeBSD__ |
| 3753 | + // libudev-devd doesn't support matching |
| 3754 | + device = udev_device_new_from_syspath(b->udev, "/dev/dri/card0"); |
| 3755 | + /* Make sure this device is actually capable of modesetting; |
| 3756 | + * if this call succeeds, b->drm.{fd,filename} will be set, |
| 3757 | + * and any old values freed. */ |
| 3758 | + if (!drm_device_is_kms(b, device)) { |
| 3759 | + udev_device_unref(device); |
| 3760 | + device = NULL; |
| 3761 | + } |
| 3762 | + return device; |
| 3763 | +#else |
3747 | 3764 | e = udev_enumerate_new(b->udev); |
3748 | 3765 | udev_enumerate_add_match_subsystem(e, "drm"); |
3749 | 3766 | udev_enumerate_add_match_sysname(e, "card[0-9]*"); |
@@ -3811,6 +3828,7 @@ find_primary_gpu(struct drm_backend *b, const char *seat) |
3811 | 3828 |
|
3812 | 3829 | udev_enumerate_unref(e); |
3813 | 3830 | return drm_device; |
| 3831 | +#endif |
3814 | 3832 | } |
3815 | 3833 |
|
3816 | 3834 | static void |
|
0 commit comments