1 /*
2  * Copyright © 2019 Red Hat
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 #ifndef DEVICE_SELECT_H
24 #define DEVICE_SELECT_H
25 
26 #include <stdbool.h>
27 #include <stdint.h>
28 #include "xf86drm.h"
29 
30 /* We don't use `drmPciDeviceInfo` because it uses 16-bit ids,
31  * instead of Vulkan's 32-bit ones. */
32 struct device_info {
33   uint32_t vendor_id;
34   uint32_t device_id;
35 };
36 
37 struct device_pci_info {
38   struct device_info dev_info;
39   drmPciBusInfo bus_info;
40   bool has_bus_info;
41   bool cpu_device;
42 };
43 
44 #ifdef VK_USE_PLATFORM_XCB_KHR
45 int device_select_find_xcb_pci_default(struct device_pci_info *devices, uint32_t device_count);
46 #else
device_select_find_xcb_pci_default(struct device_pci_info * devices,uint32_t device_count)47 static inline int device_select_find_xcb_pci_default(struct device_pci_info *devices, uint32_t device_count) { return -1; }
48 #endif
49 
50 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
51 int device_select_find_wayland_pci_default(struct device_pci_info *devices, uint32_t device_count);
52 #else
device_select_find_wayland_pci_default(struct device_pci_info * devices,uint32_t device_count)53 static inline int device_select_find_wayland_pci_default(struct device_pci_info *devices, uint32_t device_count) { return -1; }
54 #endif
55 
56 #endif
57