summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2011-11-25 14:38:45 +0100
committerThomas Hellstrom <thellstrom@vmware.com>2011-11-25 17:06:06 +0100
commit08ca819238f2c2a0494b0bd8452393fc62907cc1 (patch)
tree40cd82714b7f4fd1953c19d55bd4b75d0412190c
parentd7576c2c50dd0f3b7f70f97d9bde4e8b859e89e5 (diff)
vmwgfx: Get the drm device name from the open file descriptor
Rather than hardcoding it. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
-rw-r--r--vmwgfx/vmwgfx_dri2.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/vmwgfx/vmwgfx_dri2.c b/vmwgfx/vmwgfx_dri2.c
index 1fb5d0d..cca686a 100644
--- a/vmwgfx/vmwgfx_dri2.c
+++ b/vmwgfx/vmwgfx_dri2.c
@@ -42,6 +42,7 @@
#include "gc.h"
#include "vmwgfx_saa.h"
#include "wsbm_util.h"
+#include <unistd.h>
typedef struct {
int refcount;
@@ -363,6 +364,9 @@ xorg_dri2_init(ScreenPtr pScreen)
modesettingPtr ms = modesettingPTR(pScrn);
DRI2InfoRec dri2info;
int major, minor;
+ char deviceName[80];
+ char fdPath[80];
+ ssize_t numChar;
if (xf86LoaderCheckSymbol("DRI2Version")) {
DRI2Version(&major, &minor);
@@ -374,9 +378,24 @@ xorg_dri2_init(ScreenPtr pScreen)
dri2info.version = min(DRI2INFOREC_VERSION, 3);
dri2info.fd = ms->fd;
-
dri2info.driverName = "vmwgfx";
- dri2info.deviceName = "/dev/dri/card0"; /* FIXME */
+
+ /*
+ * This way of obtaining the DRM device name is a bit
+ * os-specific. It would be better to obtain it from
+ * drmOpen. Currently this works only for Linux.
+ */
+ snprintf(fdPath, 80, "/proc/self/fd/%d", ms->fd);
+ numChar = readlink(fdPath, deviceName, 80);
+ if (numChar <= 0 || numChar >= 80) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Could not find the drm device name. Disabling dri2.\n");
+ return FALSE;
+ }
+ deviceName[numChar] = 0;
+ dri2info.deviceName = deviceName;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Path of drm device is \"%s\".\n", deviceName);
dri2info.CreateBuffer = dri2_create_buffer;
dri2info.DestroyBuffer = dri2_destroy_buffer;