- ifdef check around the sysfs handling - only Linux has comprehensive sysfs - compile and run-time test Cc: Chih-Wei Huang <cwhuang@xxxxxxxxxxxx> Cc: Mauro Rossi <issor.oruam@xxxxxxxxx> Signed-off-by: Emil Velikov <emil.l.velikov@xxxxxxxxx> --- Chih-Wei, Mauro Here is a quick WIP which should get you going. I have _not_ tested it so it might need some polish - please submit once you're happy with it. --- xf86drm.c | 53 ++++++++++++++++++++++++++++++++++++++++++----------- xf86drm.h | 2 ++ 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/xf86drm.c b/xf86drm.c index b49d42f7..13162b81 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -3948,8 +3948,9 @@ process_device(drmDevicePtr *device, const char *d_name, { struct stat sbuf; char node[PATH_MAX + 1]; - int node_type, subsystem_type; + int node_type, subsystem_type, ret; unsigned int maj, min; + FILE *fp; node_type = drmGetNodeType(d_name); if (node_type < 0) @@ -3972,20 +3973,49 @@ process_device(drmDevicePtr *device, const char *d_name, switch (subsystem_type) { case DRM_BUS_PCI: case DRM_BUS_VIRTIO: - return drmProcessPciDevice(device, node, node_type, maj, min, - fetch_deviceinfo, flags); + ret = drmProcessPciDevice(device, node, node_type, maj, min, + fetch_deviceinfo, flags); case DRM_BUS_USB: - return drmProcessUsbDevice(device, node, node_type, maj, min, - fetch_deviceinfo, flags); + ret = drmProcessUsbDevice(device, node, node_type, maj, min, + fetch_deviceinfo, flags); case DRM_BUS_PLATFORM: - return drmProcessPlatformDevice(device, node, node_type, maj, min, - fetch_deviceinfo, flags); + ret = drmProcessPlatformDevice(device, node, node_type, maj, min, + fetch_deviceinfo, flags); case DRM_BUS_HOST1X: - return drmProcessHost1xDevice(device, node, node_type, maj, min, - fetch_deviceinfo, flags); + ret = drmProcessHost1xDevice(device, node, node_type, maj, min, + fetch_deviceinfo, flags); default: return -1; - } + } + if (!(flags & DRM_DEVICE_GET_BOOT_VGA)) + return ret; + + snprintf(node, sizeof(node), "/sys/dev/char/%d:%d/device/boot_vga", + maj, min); + + fp = fopen(path, "r"); + if (!fp) { +#ifdef BOOT_VGA_FATAL + free(*device); + *device = NULL; + return -errno; +#else + return 0; +#endif + } + + ret = fscanf(fp, "%d", &(device->boot_vga)); + fclose(fp); + if (ret != 1) { +#ifdef BOOT_VGA_FATAL + free(*device); + *device = NULL; + return -errno; +#else + return 0; +#endif + } + return 0; } /* Consider devices located on the same bus as duplicate and fold the respective @@ -4014,7 +4044,8 @@ static void drmFoldDuplicatedDevices(drmDevicePtr local_devices[], int count) static int drm_device_validate_flags(uint32_t flags) { - return (flags & ~DRM_DEVICE_GET_PCI_REVISION); + return (flags & ~(DRM_DEVICE_GET_PCI_REVISION | + DRM_DEVICE_GET_BOOT_VGA)); } static bool diff --git a/xf86drm.h b/xf86drm.h index 7b85079a..da6f7e26 100644 --- a/xf86drm.h +++ b/xf86drm.h @@ -885,6 +885,7 @@ typedef struct _drmDevice { drmPlatformDeviceInfoPtr platform; drmHost1xDeviceInfoPtr host1x; } deviceinfo; + int boot_vga; } drmDevice, *drmDevicePtr; extern int drmGetDevice(int fd, drmDevicePtr *device); @@ -894,6 +895,7 @@ extern int drmGetDevices(drmDevicePtr devices[], int max_devices); extern void drmFreeDevices(drmDevicePtr devices[], int count); #define DRM_DEVICE_GET_PCI_REVISION (1 << 0) +#define DRM_DEVICE_GET_BOOT_VGA (1 << 1) extern int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device); extern int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices); -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel