diff options
author | Jon Smirl <[email protected]> | 2004-06-26 17:16:42 +0000 |
---|---|---|
committer | Jon Smirl <[email protected]> | 2004-06-26 17:16:42 +0000 |
commit | c2bffec91a5b6ba72514c875b70dbc96ac97431d (patch) | |
tree | 3c5f963b8cec93217b18cdec35c50f0c45b3339e /src/glx/mini/drmtest.c | |
parent | e16f6e3f234391027b300ec2ca8b56fc13aac825 (diff) |
Mesa-solo builds with these changes. There are still more fixups needed to
get individual drivers working again. This converts miniglx to the new
dri interface. Thanks to Erdi Chen for the new interface code.
Diffstat (limited to 'src/glx/mini/drmtest.c')
-rw-r--r-- | src/glx/mini/drmtest.c | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/src/glx/mini/drmtest.c b/src/glx/mini/drmtest.c deleted file mode 100644 index f9cad3994e0..00000000000 --- a/src/glx/mini/drmtest.c +++ /dev/null @@ -1,140 +0,0 @@ -#include <assert.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> -#include "xf86drm.h" - -char *pciBusID = "PCI:1:0:0"; -#define DRM_PAGE_SIZE 4096 -void *pSAREA; - - -static int client( void ) -{ - int fd, ret, err; - drmContext clientContext; - - fprintf(stderr, "Opening client drm\n"); - - fd = drmOpen(NULL,pciBusID); - if (fd < 0) { - fprintf(stderr, "failed to open DRM: %s\n", strerror(-fd)); - return 1; - } - - - fprintf(stderr, "Create server context\n"); - if ((err = drmCreateContext(fd, &clientContext)) != 0) { - fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); - return 0; - } - - - fprintf(stderr, "DRM_LOCK( %d %p %d )\n", fd, pSAREA, clientContext); - DRM_LOCK(fd, pSAREA, clientContext, 0); - fprintf(stderr, "locked\n"); - DRM_UNLOCK(fd, pSAREA, clientContext); - fprintf(stderr, "DRM_UNLOCK finished\n"); - - - fprintf(stderr, "Closing client drm: %d\n", fd); - ret = drmClose(fd); - fprintf(stderr, "done %d\n", ret); - - return ret; -} - -int main( int argc, char *argv[] ) -{ - char *drmModuleName = "radeon"; - int drmFD; - int err; - int SAREASize; - drmHandle hSAREA; - drmContext serverContext; - - /* Note that drmOpen will try to load the kernel module, if needed. */ - drmFD = drmOpen(drmModuleName, NULL ); - if (drmFD < 0) { - /* failed to open DRM */ - fprintf(stderr, "[drm] drmOpen failed\n"); - return 0; - } - - - if ((err = drmSetBusid(drmFD, pciBusID)) < 0) { - drmClose(drmFD); - fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n", - drmFD, pciBusID, strerror(-err)); - return 0; - } - - - SAREASize = DRM_PAGE_SIZE; - - if (drmAddMap( drmFD, - 0, - SAREASize, - DRM_SHM, - DRM_CONTAINS_LOCK, - &hSAREA) < 0) - { - drmClose(drmFD); - fprintf(stderr, "[drm] drmAddMap failed\n"); - return 0; - } - - fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n", - SAREASize, hSAREA); - - if (drmMap( drmFD, - hSAREA, - SAREASize, - (drmAddressPtr)(&pSAREA)) < 0) - { - drmClose(drmFD); - fprintf(stderr, "[drm] drmMap failed\n"); - return 0; - } - - memset(pSAREA, 0, SAREASize); - fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n", - hSAREA, pSAREA, SAREASize); - - fprintf(stderr, "Create server context\n"); - if ((err = drmCreateContext(drmFD, &serverContext)) != 0) { - fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); - return 0; - } - - - fprintf(stderr, "DRM_LOCK( %d %p %d )\n", drmFD, pSAREA, serverContext); - DRM_LOCK(drmFD, pSAREA, serverContext, 0); - fprintf(stderr, "locked\n"); - DRM_UNLOCK(drmFD, pSAREA, serverContext); - fprintf(stderr, "DRM_UNLOCK finished\n"); - - - client(); - - - fprintf(stderr, "DRM_LOCK( %d %p %d )\n", drmFD, pSAREA, serverContext); - DRM_LOCK(drmFD, pSAREA, serverContext, 0); - fprintf(stderr, "locked\n"); - DRM_UNLOCK(drmFD, pSAREA, serverContext); - fprintf(stderr, "DRM_UNLOCK finished\n"); - - - drmUnmap(pSAREA, SAREASize); - fprintf(stderr, "[drm] unmapped SAREA 0x%08lx from %p, size %d\n", - hSAREA, pSAREA, SAREASize); - pSAREA = 0; - - fprintf(stderr, "%s: Closing DRM fd\n", __FUNCTION__); - (void)drmClose(drmFD); - - return 0; -} - - - |