virtual framebuffer devices that are created by a modesetting driver have the same parent as the drm card devices. --- libweston/compositor-fbdev.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-)
diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c index 34e6c2f3..139d6624 100644 --- a/libweston/compositor-fbdev.c +++ b/libweston/compositor-fbdev.c @@ -717,8 +717,8 @@ find_framebuffer_device(struct fbdev_backend *b, const char *seat) struct udev_enumerate *e; struct udev_list_entry *entry; const char *path, *device_seat; - char *fb_device; - struct udev_device *device; + char *fb_device, *find_device, *id; + struct udev_device *device, *pci; e = udev_enumerate_new(b->udev); udev_enumerate_add_match_subsystem(e, "graphics"); @@ -727,20 +727,48 @@ find_framebuffer_device(struct fbdev_backend *b, const char *seat) udev_enumerate_scan_devices(e); fb_device = NULL; udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { + bool is_boot_vga = false; path = udev_list_entry_get_name(entry); device = udev_device_new_from_syspath(b->udev, path); + find_device = udev_device_get_devnode(device); if (!device) continue; device_seat = udev_device_get_property_value(device, "ID_SEAT"); if (!device_seat) device_seat = default_seat; - if (!strcmp(device_seat, seat)) { - fb_device = udev_device_get_devnode(device); - udev_enumerate_unref(e); + if (strcmp(device_seat, seat)) { + udev_device_unref(device); + continue; + } + + pci = udev_device_get_parent_with_subsystem_devtype(device, + "pci", NULL); + if (pci) { + id = udev_device_get_sysattr_value(pci, "boot_vga"); + if (id && !strcmp(id, "1")) + is_boot_vga = true; + } + + /* If a framebuffer device was found, and this device isn't + * the boot-VGA device, don't use it. */ + if (!is_boot_vga && fb_device) { + udev_device_unref(device); + continue; + } + + /* There can only be one boot_vga device. Try to use it + * at all costs. */ + if (is_boot_vga) { + fb_device = find_device; break; } - udev_device_unref(device); + + /* Per the (!is_boot_vga && fb_device) test above, only + * trump existing saved devices with boot-VGA devices, so if + * the test ends up here, this must be the first device seen. */ + assert(!fb_device); + fb_device = find_device; } udev_enumerate_unref(e); -- 2.14.1 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel