diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2011-11-28 14:51:36 +0100 |
---|---|---|
committer | Thomas Hellstrom <thellstrom@vmware.com> | 2011-11-28 19:36:26 +0100 |
commit | 995d86ceb0ae8cf2904100405ba6710c89f7f1b7 (patch) | |
tree | e5b3666e1123976e1808718bfe03795e01bef832 | |
parent | 08ca819238f2c2a0494b0bd8452393fc62907cc1 (diff) | |
download | xf86-video-vmware-995d86ceb0ae8cf2904100405ba6710c89f7f1b7.tar.gz xf86-video-vmware-995d86ceb0ae8cf2904100405ba6710c89f7f1b7.tar.bz2 xf86-video-vmware-995d86ceb0ae8cf2904100405ba6710c89f7f1b7.zip |
vmwgfx: Make the drm device name persistent
The DRI2 code doesn't copy the device name, but assumes the storage
is persistent.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
Reviewed-by: Alan Hourihane <alanh@vmware.com>
-rw-r--r-- | vmwgfx/vmwgfx_dri2.c | 18 | ||||
-rw-r--r-- | vmwgfx/vmwgfx_driver.h | 3 |
2 files changed, 13 insertions, 8 deletions
diff --git a/vmwgfx/vmwgfx_dri2.c b/vmwgfx/vmwgfx_dri2.c index cca686a..3f9d00a 100644 --- a/vmwgfx/vmwgfx_dri2.c +++ b/vmwgfx/vmwgfx_dri2.c @@ -44,6 +44,8 @@ #include "wsbm_util.h" #include <unistd.h> +#define VMWGFX_FD_PATH_LEN 80 + typedef struct { int refcount; PixmapPtr pPixmap; @@ -364,8 +366,7 @@ xorg_dri2_init(ScreenPtr pScreen) modesettingPtr ms = modesettingPTR(pScrn); DRI2InfoRec dri2info; int major, minor; - char deviceName[80]; - char fdPath[80]; + char fdPath[VMWGFX_FD_PATH_LEN]; ssize_t numChar; if (xf86LoaderCheckSymbol("DRI2Version")) { @@ -385,17 +386,18 @@ xorg_dri2_init(ScreenPtr pScreen) * 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) { + memset(fdPath, 0, VMWGFX_FD_PATH_LEN); + snprintf(fdPath, VMWGFX_FD_PATH_LEN - 1, "/proc/self/fd/%d", ms->fd); + numChar = readlink(fdPath, ms->dri2_device_name, VMWGFX_DRI_DEVICE_LEN); + if (numChar <= 0 || numChar >= VMWGFX_DRI_DEVICE_LEN) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Could not find the drm device name. Disabling dri2.\n"); return FALSE; } - deviceName[numChar] = 0; - dri2info.deviceName = deviceName; + ms->dri2_device_name[numChar] = 0; + dri2info.deviceName = ms->dri2_device_name; xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Path of drm device is \"%s\".\n", deviceName); + "Path of drm device is \"%s\".\n", ms->dri2_device_name); dri2info.CreateBuffer = dri2_create_buffer; dri2info.DestroyBuffer = dri2_destroy_buffer; diff --git a/vmwgfx/vmwgfx_driver.h b/vmwgfx/vmwgfx_driver.h index aaa95f1..f6c9ec0 100644 --- a/vmwgfx/vmwgfx_driver.h +++ b/vmwgfx/vmwgfx_driver.h @@ -55,6 +55,8 @@ #define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg); #define debug_printf(...) +#define VMWGFX_DRI_DEVICE_LEN 80 + typedef struct { int lastInstance; @@ -119,6 +121,7 @@ typedef struct _modesettingRec struct xa_tracker *xat; #ifdef DRI2 Bool dri2_available; + char dri2_device_name[VMWGFX_DRI_DEVICE_LEN]; #endif } modesettingRec, *modesettingPtr; |