xf86drm: add plumbing to not retrieve PCI device revision

Will be used with the drmGetDevice[s]2 API.

Cc: Michel Dänzer <michel@daenzer.net>
Cc: Nicolai Hähnle <nhaehnle@gmail.com>
Cc: Mauro Santos <registo.mailling@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98502
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
main
Emil Velikov 2016-11-30 17:13:51 +00:00 committed by Emil Velikov
parent b40a65d448
commit 138d23117c
1 changed files with 9 additions and 5 deletions

View File

@ -2947,7 +2947,8 @@ static int drmGetMaxNodeName(void)
} }
static int drmParsePciDeviceInfo(int maj, int min, static int drmParsePciDeviceInfo(int maj, int min,
drmPciDeviceInfoPtr device) drmPciDeviceInfoPtr device,
uint32_t flags)
{ {
#ifdef __linux__ #ifdef __linux__
char path[PATH_MAX + 1]; char path[PATH_MAX + 1];
@ -3000,7 +3001,8 @@ void drmFreeDevices(drmDevicePtr devices[], int count)
static int drmProcessPciDevice(drmDevicePtr *device, static int drmProcessPciDevice(drmDevicePtr *device,
const char *node, int node_type, const char *node, int node_type,
int maj, int min, bool fetch_deviceinfo) int maj, int min, bool fetch_deviceinfo,
uint32_t flags)
{ {
const int max_node_str = ALIGN(drmGetMaxNodeName(), sizeof(void *)); const int max_node_str = ALIGN(drmGetMaxNodeName(), sizeof(void *));
int ret, i; int ret, i;
@ -3039,7 +3041,7 @@ static int drmProcessPciDevice(drmDevicePtr *device,
addr += sizeof(drmPciBusInfo); addr += sizeof(drmPciBusInfo);
(*device)->deviceinfo.pci = (drmPciDeviceInfoPtr)addr; (*device)->deviceinfo.pci = (drmPciDeviceInfoPtr)addr;
ret = drmParsePciDeviceInfo(maj, min, (*device)->deviceinfo.pci); ret = drmParsePciDeviceInfo(maj, min, (*device)->deviceinfo.pci, flags);
if (ret) if (ret)
goto free_device; goto free_device;
} }
@ -3095,6 +3097,7 @@ int drmGetDevice(int fd, drmDevicePtr *device)
int ret, i, node_count; int ret, i, node_count;
int max_count = 16; int max_count = 16;
dev_t find_rdev; dev_t find_rdev;
uint32_t flags = 0;
if (fd == -1 || device == NULL) if (fd == -1 || device == NULL)
return -EINVAL; return -EINVAL;
@ -3142,7 +3145,7 @@ int drmGetDevice(int fd, drmDevicePtr *device)
switch (subsystem_type) { switch (subsystem_type) {
case DRM_BUS_PCI: case DRM_BUS_PCI:
ret = drmProcessPciDevice(&d, node, node_type, maj, min, true); ret = drmProcessPciDevice(&d, node, node_type, maj, min, true, flags);
if (ret) if (ret)
goto free_devices; goto free_devices;
@ -3216,6 +3219,7 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices)
int maj, min; int maj, min;
int ret, i, node_count, device_count; int ret, i, node_count, device_count;
int max_count = 16; int max_count = 16;
uint32_t flags = 0;
local_devices = calloc(max_count, sizeof(drmDevicePtr)); local_devices = calloc(max_count, sizeof(drmDevicePtr));
if (local_devices == NULL) if (local_devices == NULL)
@ -3251,7 +3255,7 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices)
switch (subsystem_type) { switch (subsystem_type) {
case DRM_BUS_PCI: case DRM_BUS_PCI:
ret = drmProcessPciDevice(&device, node, node_type, ret = drmProcessPciDevice(&device, node, node_type,
maj, min, devices != NULL); maj, min, devices != NULL, flags);
if (ret) if (ret)
goto free_devices; goto free_devices;