summaryrefslogtreecommitdiff
path: root/lib/libdrm/xf86drm.c
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2010-03-31 06:31:46 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2010-03-31 06:31:46 +0000
commit816f287c2b0ba396b7dea04bf6c4ea044659576b (patch)
tree8b6aa64196234d9da2557eab6a1cf47fc841d060 /lib/libdrm/xf86drm.c
parent4d6ac936345b34f44235d7724cf472c881b67d1c (diff)
update libdrm to 2.4.15.
This diff seems larger than it is since upstream reindented some sources. This updates libdrm_intel to -current (which only affect the GEM code) and libdrm to 2.4.15. bumping both minor versions. Discussed with matthieu@
Diffstat (limited to 'lib/libdrm/xf86drm.c')
-rw-r--r--lib/libdrm/xf86drm.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/lib/libdrm/xf86drm.c b/lib/libdrm/xf86drm.c
index 83a985a8f..7c3bb3929 100644
--- a/lib/libdrm/xf86drm.c
+++ b/lib/libdrm/xf86drm.c
@@ -221,22 +221,22 @@ static int drmMatchBusID(const char *id1, const char *id2)
/* Try to match old/new-style PCI bus IDs. */
if (strncasecmp(id1, "pci", 3) == 0) {
- int o1, b1, d1, f1;
- int o2, b2, d2, f2;
+ unsigned int o1, b1, d1, f1;
+ unsigned int o2, b2, d2, f2;
int ret;
- ret = sscanf(id1, "pci:%04x:%02x:%02x.%d", &o1, &b1, &d1, &f1);
+ ret = sscanf(id1, "pci:%04x:%02x:%02x.%u", &o1, &b1, &d1, &f1);
if (ret != 4) {
o1 = 0;
- ret = sscanf(id1, "PCI:%d:%d:%d", &b1, &d1, &f1);
+ ret = sscanf(id1, "PCI:%u:%u:%u", &b1, &d1, &f1);
if (ret != 3)
return 0;
}
- ret = sscanf(id2, "pci:%04x:%02x:%02x.%d", &o2, &b2, &d2, &f2);
+ ret = sscanf(id2, "pci:%04x:%02x:%02x.%u", &o2, &b2, &d2, &f2);
if (ret != 4) {
o2 = 0;
- ret = sscanf(id2, "PCI:%d:%d:%d", &b2, &d2, &f2);
+ ret = sscanf(id2, "PCI:%u:%u:%u", &b2, &d2, &f2);
if (ret != 3)
return 0;
}
@@ -2388,24 +2388,54 @@ void drmCloseOnce(int fd)
}
}
-#ifdef NOTYET
int drmSetMaster(int fd)
{
+#ifdef NOTYET
int ret;
fprintf(stderr,"Setting master \n");
ret = ioctl(fd, DRM_IOCTL_SET_MASTER, 0);
return ret;
+#endif
+ return 0;
}
int drmDropMaster(int fd)
{
+#ifdef NOTYET
int ret;
fprintf(stderr,"Dropping master \n");
ret = ioctl(fd, DRM_IOCTL_DROP_MASTER, 0);
return ret;
-}
#endif
+ return 0;
+}
+
+char *drmGetDeviceNameFromFd(int fd)
+{
+ char name[128];
+ struct stat sbuf;
+ dev_t d;
+ int i;
+
+ /* The whole drmOpen thing is a fiasco and we need to find a way
+ * back to just using open(2). For now, however, lets just make
+ * things worse with even more ad hoc directory walking code to
+ * discover the device file name. */
+
+ fstat(fd, &sbuf);
+ d = sbuf.st_rdev;
+
+ for (i = 0; i < DRM_MAX_MINOR; i++) {
+ snprintf(name, sizeof name, DRM_DEV_NAME, DRM_DIR_NAME, i);
+ if (stat(name, &sbuf) == 0 && sbuf.st_rdev == d)
+ break;
+ }
+ if (i == DRM_MAX_MINOR)
+ return NULL;
+
+ return drmStrdup(name);
+}
#ifdef X_PRIVSEP
static int