return default_idx;
}
+static int device_select_find_boot_vga_vid_did(struct device_pci_info *pci_infos,
+ uint32_t device_count)
+{
+ char path[1024];
+ int fd;
+ int default_idx = -1;
+ uint8_t boot_vga = 0;
+ ssize_t size_ret;
+ #pragma pack(push, 1)
+ struct id {
+ uint16_t vid;
+ uint16_t did;
+ }id;
+ #pragma pack(pop)
+
+ for (unsigned i = 0; i < 64; i++) {
+ snprintf(path, 1023, "/sys/class/drm/card%d/device/boot_vga", i);
+ fd = open(path, O_RDONLY);
+ if (fd != -1) {
+ uint8_t val;
+ size_ret = read(fd, &val, 1);
+ close(fd);
+ if (size_ret == 1 && val == '1')
+ boot_vga = 1;
+ } else {
+ return default_idx;
+ }
+
+ if (boot_vga) {
+ snprintf(path, 1023, "/sys/class/drm/card%d/device/config", i);
+ fd = open(path, O_RDONLY);
+ if (fd != -1) {
+ size_ret = read(fd, &id, 4);
+ close(fd);
+ if (size_ret != 4)
+ return default_idx;
+ } else {
+ return default_idx;
+ }
+ break;
+ }
+ }
+
+ if (!boot_vga)
+ return default_idx;
+
+ for (unsigned i = 0; i < device_count; ++i) {
+ if (id.vid == pci_infos[i].dev_info.vendor_id &&
+ id.did == pci_infos[i].dev_info.device_id) {
+ default_idx = i;
+ break;
+ }
+ }
+
+ return default_idx;
+}
+
static int device_select_find_boot_vga_default(struct device_pci_info *pci_infos,
uint32_t device_count)
{
default_idx = device_select_find_wayland_pci_default(pci_infos, physical_device_count);
if (default_idx == -1 && info->has_xcb)
default_idx = device_select_find_xcb_pci_default(pci_infos, physical_device_count);
- if (default_idx == -1 && info->has_pci_bus)
- default_idx = device_select_find_boot_vga_default(pci_infos, physical_device_count);
+ if (default_idx == -1) {
+ if (info->has_vulkan11 && info->has_pci_bus)
+ default_idx = device_select_find_boot_vga_default(pci_infos, physical_device_count);
+ else
+ default_idx = device_select_find_boot_vga_vid_did(pci_infos, physical_device_count);
+ }
if (default_idx == -1 && cpu_count)
default_idx = device_select_find_non_cpu(pci_infos, physical_device_count);
-
/* DRI_PRIME=1 handling - pick any other device than default. */
if (default_idx != -1 && dri_prime_is_one && physical_device_count > (cpu_count + 1)) {
if (default_idx == 0 || default_idx == 1)