aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmil Velikov2015-08-16 22:09:06 -0500
committerEmil Velikov2015-08-24 11:36:28 -0500
commitb556ea127e004b734b2a7bf8e67cdcf56312171d (patch)
tree8bf1bf5d926d0e8d8c4593f2b0c55efbedff3073 /xf86drm.h
parent5c42b5e36a4a02e579ec5dcdc3a95ce58538224c (diff)
downloadexternal-libdrm-b556ea127e004b734b2a7bf8e67cdcf56312171d.tar.gz
external-libdrm-b556ea127e004b734b2a7bf8e67cdcf56312171d.tar.xz
external-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);
563#define DRM_NODE_PRIMARY 0 563#define DRM_NODE_PRIMARY 0
564#define DRM_NODE_CONTROL 1 564#define DRM_NODE_CONTROL 1
565#define DRM_NODE_RENDER 2 565#define DRM_NODE_RENDER 2
566#define DRM_NODE_MAX 3
567
566extern int drmOpenWithType(const char *name, const char *busid, 568extern int drmOpenWithType(const char *name, const char *busid,
567 int type); 569 int type);
568 570
@@ -759,6 +761,38 @@ extern int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle);
759extern char *drmGetPrimaryDeviceNameFromFd(int fd); 761extern char *drmGetPrimaryDeviceNameFromFd(int fd);
760extern char *drmGetRenderDeviceNameFromFd(int fd); 762extern char *drmGetRenderDeviceNameFromFd(int fd);
761 763
764#define DRM_BUS_PCI 0
765
766typedef struct _drmPciBusInfo {
767 uint16_t domain;
768 uint8_t bus;
769 uint8_t dev;
770 uint8_t func;
771} drmPciBusInfo, *drmPciBusInfoPtr;
772
773typedef struct _drmPciDeviceInfo {
774 uint16_t vendor_id;
775 uint16_t device_id;
776 uint16_t subvendor_id;
777 uint16_t subdevice_id;
778 uint8_t revision_id;
779} drmPciDeviceInfo, *drmPciDeviceInfoPtr;
780
781typedef struct _drmDevice {
782 char **nodes; /* DRM_NODE_MAX sized array */
783 int available_nodes; /* DRM_NODE_* bitmask */
784 int bustype;
785 union {
786 drmPciBusInfoPtr pci;
787 } businfo;
788 union {
789 drmPciDeviceInfoPtr pci;
790 } deviceinfo;
791} drmDevice, *drmDevicePtr;
792
793extern int drmGetDevices(drmDevicePtr devices[], int max_devices);
794extern void drmFreeDevices(drmDevicePtr devices[], int count);
795
762#if defined(__cplusplus) 796#if defined(__cplusplus)
763} 797}
764#endif 798#endif