summaryrefslogtreecommitdiff
path: root/xf86drm.h
diff options
context:
space:
mode:
authorEmil Velikov <emil.l.velikov@gmail.com>2015-08-17 11:09:06 +0800
committerEmil Velikov <emil.l.velikov@gmail.com>2015-08-24 17:36:28 +0100
commitb556ea127e004b734b2a7bf8e67cdcf56312171d (patch)
tree8bf1bf5d926d0e8d8c4593f2b0c55efbedff3073 /xf86drm.h
parent5c42b5e36a4a02e579ec5dcdc3a95ce58538224c (diff)
downloadlibdrm-b556ea127e004b734b2a7bf8e67cdcf56312171d.tar.gz
libdrm-b556ea127e004b734b2a7bf8e67cdcf56312171d.tar.bz2
libdrm-b556ea127e004b734b2a7bf8e67cdcf56312171d.zip
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 <emil.l.velikov@gmail.com> Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Diffstat (limited to 'xf86drm.h')
-rw-r--r--xf86drm.h34
1 files changed, 34 insertions, 0 deletions
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