From b556ea127e004b734b2a7bf8e67cdcf56312171d Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Mon, 17 Aug 2015 11:09:06 +0800 Subject: drm: add interface to get drm devices on the system v3 For mutiple GPU support, the devices on the system should be enumerated to get necessary information about each device, and the drmGetDevices interface is added for this. Currently only PCI devices are supported for the enumeration. Typical usage: int count; drmDevicePtr *foo; count = drmGetDevices(NULL, 0); foo = calloc(count, sizeof(drmDevicePtr)); count = drmGetDevices(foo, count); /* find proper device, open correct device node, etc */ drmFreeDevices(foo, count); free(foo); v2: [Jammy Zhou] - return a list of devices, rather than nodes v3: [Jammy Zhou] - fix the signed extension for PCI device info Signed-off-by: Emil Velikov Signed-off-by: Jammy Zhou --- xf86drm.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'xf86drm.h') diff --git a/xf86drm.h b/xf86drm.h index 360e04af..e82ca844 100644 --- a/xf86drm.h +++ b/xf86drm.h @@ -563,6 +563,8 @@ extern int drmOpen(const char *name, const char *busid); #define DRM_NODE_PRIMARY 0 #define DRM_NODE_CONTROL 1 #define DRM_NODE_RENDER 2 +#define DRM_NODE_MAX 3 + extern int drmOpenWithType(const char *name, const char *busid, int type); @@ -759,6 +761,38 @@ extern int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle); extern char *drmGetPrimaryDeviceNameFromFd(int fd); extern char *drmGetRenderDeviceNameFromFd(int fd); +#define DRM_BUS_PCI 0 + +typedef struct _drmPciBusInfo { + uint16_t domain; + uint8_t bus; + uint8_t dev; + uint8_t func; +} drmPciBusInfo, *drmPciBusInfoPtr; + +typedef struct _drmPciDeviceInfo { + uint16_t vendor_id; + uint16_t device_id; + uint16_t subvendor_id; + uint16_t subdevice_id; + uint8_t revision_id; +} drmPciDeviceInfo, *drmPciDeviceInfoPtr; + +typedef struct _drmDevice { + char **nodes; /* DRM_NODE_MAX sized array */ + int available_nodes; /* DRM_NODE_* bitmask */ + int bustype; + union { + drmPciBusInfoPtr pci; + } businfo; + union { + drmPciDeviceInfoPtr pci; + } deviceinfo; +} drmDevice, *drmDevicePtr; + +extern int drmGetDevices(drmDevicePtr devices[], int max_devices); +extern void drmFreeDevices(drmDevicePtr devices[], int count); + #if defined(__cplusplus) } #endif -- cgit v1.2.1