[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

libdrm: Changes to 'debian-unstable'



 .gitignore                           |   66 
 ChangeLog                            | 9350 ++++++++++++++++++++++
 Makefile.am                          |    2 
 Makefile.in                          |  170 
 README                               |   71 
 aclocal.m4                           |  963 +-
 config.guess                         |   60 
 config.sub                           |   66 
 configure                            | 9387 ++++++++++++-----------
 configure.ac                         |    9 
 debian/changelog                     |   15 
 debian/libdrm2.shlibs                |    2 
 debian/patches/01_default_perms.diff |    6 
 debian/rules                         |   11 
 depcomp                              |   93 
 install-sh                           |  514 -
 libdrm/Makefile.am                   |    5 
 libdrm/Makefile.in                   |  162 
 libdrm/xf86drm.c                     | 1351 ---
 libdrm/xf86drm.h                     |    6 
 libdrm/xf86drmHash.c                 |   20 
 libdrm/xf86drmRandom.c               |   20 
 libdrm/xf86drmSL.c                   |   23 
 libdrm/xf86mm.h                      |  121 
 ltmain.sh                            |  277 
 missing                              |   61 
 shared-core/Makefile.in              |  112 
 shared-core/drm.h                    |  575 -
 shared-core/drm_drawable.c           |  330 
 shared-core/drm_internal.h           |   40 
 shared-core/drm_pciids.txt           |  151 
 shared-core/drm_sarea.h              |   30 
 shared-core/i915_dma.c               |  824 +-
 shared-core/i915_drm.h               |  118 
 shared-core/i915_drv.h               | 1141 ++
 shared-core/i915_irq.c               |  953 +-
 shared-core/i915_mem.c               |  139 
 shared-core/mach64_dma.c             |  507 -
 shared-core/mach64_drm.h             |    4 
 shared-core/mach64_drv.h             |  557 -
 shared-core/mach64_irq.c             |  103 
 shared-core/mach64_state.c           |  237 
 shared-core/mga_dma.c                |  307 
 shared-core/mga_drm.h                |   22 
 shared-core/mga_drv.h                |  178 
 shared-core/mga_irq.c                |   88 
 shared-core/mga_state.c              |  261 
 shared-core/mga_warp.c               |    8 
 shared-core/nouveau_dma.c            |  172 
 shared-core/nouveau_dma.h            |   96 
 shared-core/nouveau_drm.h            |  170 
 shared-core/nouveau_drv.h            |  606 +
 shared-core/nouveau_fifo.c           |  598 +
 shared-core/nouveau_irq.c            |  568 +
 shared-core/nouveau_mem.c            |  784 +
 shared-core/nouveau_notifier.c       |  165 
 shared-core/nouveau_object.c         | 1171 ++
 shared-core/nouveau_reg.h            |  593 +
 shared-core/nouveau_state.c          |  700 +
 shared-core/nouveau_swmthd.c         |  191 
 shared-core/nouveau_swmthd.h         |   33 
 shared-core/nv04_fb.c                |   23 
 shared-core/nv04_fifo.c              |  138 
 shared-core/nv04_graph.c             |  516 +
 shared-core/nv04_instmem.c           |  159 
 shared-core/nv04_mc.c                |   22 
 shared-core/nv04_timer.c             |   53 
 shared-core/nv10_fb.c                |   25 
 shared-core/nv10_fifo.c              |  169 
 shared-core/nv10_graph.c             |  914 ++
 shared-core/nv20_graph.c             |  909 ++
 shared-core/nv40_fb.c                |   62 
 shared-core/nv40_fifo.c              |  209 
 shared-core/nv40_graph.c             | 2195 +++++
 shared-core/nv40_mc.c                |   38 
 shared-core/nv50_fifo.c              |  339 
 shared-core/nv50_graph.c             | 2196 +++++
 shared-core/nv50_instmem.c           |  324 
 shared-core/nv50_mc.c                |   43 
 shared-core/r128_cce.c               |  183 
 shared-core/r128_drm.h               |   22 
 shared-core/r128_drv.h               |   53 
 shared-core/r128_irq.c               |   64 
 shared-core/r128_state.c             |  452 -
 shared-core/r300_cmdbuf.c            |  367 
 shared-core/r300_reg.h               | 1096 +-
 shared-core/r600_microcode.h         |14275 +++++++++++++++++++++++++++++++++++
 shared-core/radeon_cp.c              | 1392 +--
 shared-core/radeon_drm.h             |   41 
 shared-core/radeon_drv.h             |  408 -
 shared-core/radeon_irq.c             |  303 
 shared-core/radeon_mem.c             |  114 
 shared-core/radeon_microcode.h       | 1844 ++++
 shared-core/radeon_state.c           |  894 +-
 shared-core/savage_bci.c             |  211 
 shared-core/savage_drm.h             |    4 
 shared-core/savage_drv.h             |   32 
 shared-core/savage_state.c           |  403 
 shared-core/sis_drv.h                |   29 
 shared-core/sis_mm.c                 |  190 
 shared-core/via_3d_reg.h             |    1 
 shared-core/via_dma.c                |  454 -
 shared-core/via_drm.h                |   48 
 shared-core/via_drv.c                |   51 
 shared-core/via_drv.h                |  115 
 shared-core/via_irq.c                |  232 
 shared-core/via_map.c                |   46 
 shared-core/via_mm.c                 |   49 
 shared-core/via_verifier.c           |   80 
 shared-core/via_verifier.h           |   19 
 shared-core/via_video.c              |   24 
 shared-core/xgi_drm.h                |  133 
 tests/Makefile.am                    |   29 
 tests/auth.c                         |  137 
 tests/dristat.c                      |  279 
 tests/drmstat.c                      |  425 +
 tests/drmtest.c                      |   83 
 tests/drmtest.h                      |   37 
 tests/getclient.c                    |   60 
 tests/getstats.c                     |   51 
 tests/getversion.c                   |   47 
 tests/lock.c                         |  263 
 tests/openclose.c                    |   37 
 tests/setversion.c                   |   84 
 tests/ttmtest/AUTHORS                |    1 
 tests/ttmtest/ChangeLog              |   23 
 tests/ttmtest/Makefile.am            |    1 
 tests/ttmtest/configure.ac           |   33 
 tests/ttmtest/reconf                 |    2 
 tests/ttmtest/src/Makefile.am        |    8 
 tests/ttmtest/src/ttmtest.c          |  430 +
 tests/ttmtest/src/xf86dri.c          |  604 +
 tests/ttmtest/src/xf86dri.h          |  116 
 tests/ttmtest/src/xf86dristr.h       |  390 
 tests/updatedraw.c                   |  148 
 135 files changed, 58145 insertions(+), 12469 deletions(-)

New commits:
commit 94ae442655c1c2862041d801b819d4b5b3435b74
Author: Julien Cristau <jcristau@debian.org>
Date:   Sun Jul 13 19:08:11 2008 +0200

    Prepare changelog for upload

diff --git a/debian/changelog b/debian/changelog
index 9cffe3b..dfad06f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-libdrm (2.3.1-1) UNRELEASED; urgency=low
+libdrm (2.3.1-1) unstable; urgency=low
 
   [ Brice Goglin ]
   * Update upstream URL in debian/copyright.
@@ -16,7 +16,7 @@ libdrm (2.3.1-1) UNRELEASED; urgency=low
   [ Timo Aaltonen ]
   * Bump the shlibs to 2.3.1.
 
- -- Timo Aaltonen <tepsipakki@ubuntu.com>  Tue, 01 Jul 2008 18:20:08 +0300
+ -- Julien Cristau <jcristau@debian.org>  Sun, 13 Jul 2008 19:07:49 +0200
 
 libdrm (2.3.0-4) unstable; urgency=low
 

commit 61df5cad010b99afcad4be79c5d37fb4c8ac9fb6
Author: Julien Cristau <jcristau@debian.org>
Date:   Sun Jul 13 19:06:46 2008 +0200

    debian/rules fixups
    
    don't call configure with --host if we're not cross-building,
    and fix some rules dependencies.

diff --git a/debian/changelog b/debian/changelog
index 5bec6cf..9cffe3b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,8 @@ libdrm (2.3.1-1) UNRELEASED; urgency=low
   * New upstream release (needed for mesa 7.1 and newer xserver).
   * Note: this release removes the memory manager (TTM) interface used by the
     i915tex dri driver.
+  * debian/rules: don't call configure with --host if we're not
+    cross-building, and fix some rules dependencies.
 
   [ Timo Aaltonen ]
   * Bump the shlibs to 2.3.1.
diff --git a/debian/rules b/debian/rules
index ce99c69..cac84aa 100755
--- a/debian/rules
+++ b/debian/rules
@@ -16,6 +16,11 @@ include /usr/share/quilt/quilt.make
 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
 
+ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
+	confflags += --build=$(DEB_HOST_GNU_TYPE)
+else
+	confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
+endif
 
 CFLAGS = -Wall -g
 
@@ -27,10 +32,10 @@ endif
 
 config.status: configure
 	dh_testdir
-	CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --enable-static=yes
+	./configure $(confflags) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --enable-static=yes CFLAGS="$(CFLAGS)"
 
-build: patch build-stamp
-build-stamp:  config.status
+build: build-stamp
+build-stamp: $(QUILT_STAMPFN) config.status
 	dh_testdir
 	$(MAKE)
 	touch build-stamp

commit 08a395624650a68adae791e066e0538999ace611
Author: Julien Cristau <jcristau@debian.org>
Date:   Sun Jul 13 19:01:18 2008 +0200

    Add a note about breaking i915tex_dri.so

diff --git a/debian/changelog b/debian/changelog
index 581a872..5bec6cf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,8 @@ libdrm (2.3.1-1) UNRELEASED; urgency=low
 
   [ Julien Cristau ]
   * New upstream release (needed for mesa 7.1 and newer xserver).
+  * Note: this release removes the memory manager (TTM) interface used by the
+    i915tex dri driver.
 
   [ Timo Aaltonen ]
   * Bump the shlibs to 2.3.1.

commit a08e2c8f3be381251cab345bfec1374962731b52
Author: Timo Aaltonen <tjaalton@pris.hut.fi>
Date:   Tue Jul 1 18:23:19 2008 +0300

    Bump the shlibs to 2.3.1

diff --git a/debian/changelog b/debian/changelog
index 10146f4..581a872 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,7 +9,10 @@ libdrm (2.3.1-1) UNRELEASED; urgency=low
   [ Julien Cristau ]
   * New upstream release (needed for mesa 7.1 and newer xserver).
 
- -- Brice Goglin <Brice.Goglin@ens-lyon.org>  Fri, 13 Jun 2008 11:50:19 +0200
+  [ Timo Aaltonen ]
+  * Bump the shlibs to 2.3.1.
+
+ -- Timo Aaltonen <tepsipakki@ubuntu.com>  Tue, 01 Jul 2008 18:20:08 +0300
 
 libdrm (2.3.0-4) unstable; urgency=low
 
diff --git a/debian/libdrm2.shlibs b/debian/libdrm2.shlibs
index e987c72..ebc4f02 100644
--- a/debian/libdrm2.shlibs
+++ b/debian/libdrm2.shlibs
@@ -1 +1 @@
-libdrm 2 libdrm2 (>= 2.3.0)
+libdrm 2 libdrm2 (>= 2.3.1)

commit f1e04d231a0ae5917b7a59c41915dd2a51814798
Author: Julien Cristau <jcristau@debian.org>
Date:   Tue Jul 1 12:14:03 2008 +0200

    update changelogs and refresh patch

diff --git a/ChangeLog b/ChangeLog
index a0006c8..17934b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+commit 409d6818eba8a2e2938e0f9281c9318928ba5a35
+Author: Dave Airlie <airlied@redhat.com>
+Date:   Tue Jun 3 12:42:49 2008 +1000
+
+    drm: sg alloc should write back the handle to userspace
+    (cherry picked from commit d5ae19ebcf2dc6402872e0575b5786b6e8117b6f)
+
 commit f892b4adf4021e82a7d4f2eb06256d6f4200ed15
 Author: Dave Airlie <airlied@redhat.com>
 Date:   Wed May 28 15:31:18 2008 +1000
diff --git a/debian/changelog b/debian/changelog
index 8eedbc8..10146f4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-libdrm (2.3.1~git20080613-1) UNRELEASED; urgency=low
+libdrm (2.3.1-1) UNRELEASED; urgency=low
 
   [ Brice Goglin ]
   * Update upstream URL in debian/copyright.
@@ -7,7 +7,7 @@ libdrm (2.3.1~git20080613-1) UNRELEASED; urgency=low
   * Install the upstream ChangeLog.
 
   [ Julien Cristau ]
-  * New upstream snapshot (needed for mesa 7.1 and newer xserver).
+  * New upstream release (needed for mesa 7.1 and newer xserver).
 
  -- Brice Goglin <Brice.Goglin@ens-lyon.org>  Fri, 13 Jun 2008 11:50:19 +0200
 
diff --git a/debian/patches/01_default_perms.diff b/debian/patches/01_default_perms.diff
index 371fc05..ed70162 100644
--- a/debian/patches/01_default_perms.diff
+++ b/debian/patches/01_default_perms.diff
@@ -1,8 +1,8 @@
 Index: libdrm/libdrm/xf86drm.h
 ===================================================================
---- libdrm.orig/libdrm/xf86drm.h	2007-04-15 12:37:15.000000000 -0400
-+++ libdrm/libdrm/xf86drm.h	2007-04-15 12:39:16.000000000 -0400
-@@ -46,7 +46,7 @@
+--- libdrm.orig/libdrm/xf86drm.h
++++ libdrm/libdrm/xf86drm.h
+@@ -45,7 +45,7 @@
  /* Default /dev/dri directory permissions 0755 */
  #define DRM_DEV_DIRMODE	 	\
  	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)

commit 409d6818eba8a2e2938e0f9281c9318928ba5a35
Author: Dave Airlie <airlied@redhat.com>
Date:   Tue Jun 3 12:42:49 2008 +1000

    drm: sg alloc should write back the handle to userspace
    (cherry picked from commit d5ae19ebcf2dc6402872e0575b5786b6e8117b6f)

diff --git a/shared-core/drm.h b/shared-core/drm.h
index 0ae04b2..82a486f 100644
--- a/shared-core/drm.h
+++ b/shared-core/drm.h
@@ -701,7 +701,7 @@ struct drm_set_version {
 #define DRM_IOCTL_AGP_BIND		DRM_IOW( 0x36, struct drm_agp_binding)
 #define DRM_IOCTL_AGP_UNBIND		DRM_IOW( 0x37, struct drm_agp_binding)
 
-#define DRM_IOCTL_SG_ALLOC		DRM_IOW( 0x38, struct drm_scatter_gather)
+#define DRM_IOCTL_SG_ALLOC		DRM_IOWR(0x38, struct drm_scatter_gather)
 #define DRM_IOCTL_SG_FREE		DRM_IOW( 0x39, struct drm_scatter_gather)
 
 #define DRM_IOCTL_WAIT_VBLANK		DRM_IOWR(0x3a, union drm_wait_vblank)

commit b5adfe24f5f85bca9bdf1668dbd30454989b86ce
Author: Julien Cristau <jcristau@debian.org>
Date:   Fri Jun 13 17:15:47 2008 +0200

    add missing files

diff --git a/tests/dristat.c b/tests/dristat.c
new file mode 100644
index 0000000..8985316
--- /dev/null
+++ b/tests/dristat.c
@@ -0,0 +1,279 @@
+/* dristat.c -- 
+ * Created: Mon Jan 15 05:05:07 2001 by faith@acm.org
+ *
+ * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ * 
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "xf86drm.h"
+#include "xf86drmRandom.c"
+#include "xf86drmHash.c"
+#include "xf86drm.c"
+
+#define DRM_VERSION 0x00000001
+#define DRM_MEMORY  0x00000002
+#define DRM_CLIENTS 0x00000004
+#define DRM_STATS   0x00000008
+#define DRM_BUSID   0x00000010
+
+static void getversion(int fd)
+{
+    drmVersionPtr version;
+    
+    version = drmGetVersion(fd);
+    if (version) {
+	printf("  Version information:\n");
+	printf("    Name: %s\n", version->name ? version->name : "?");
+	printf("    Version: %d.%d.%d\n",
+	       version->version_major,
+	       version->version_minor,
+	       version->version_patchlevel);
+	printf("    Date: %s\n", version->date ? version->date : "?");
+	printf("    Desc: %s\n", version->desc ? version->desc : "?");
+	drmFreeVersion(version);
+    } else {
+	printf("  No version information available\n");
+    }
+}
+
+static void getbusid(int fd)
+{
+    const char *busid = drmGetBusid(fd);
+    
+    printf("  Busid: %s\n", *busid ? busid : "(not set)");
+    drmFreeBusid(busid);
+}
+
+
+static void getvm(int fd)
+{
+    int             i;
+    const char      *typename;
+    char            flagname[33];
+    drm_handle_t    offset;
+    drmSize         size;
+    drmMapType      type;
+    drmMapFlags     flags;
+    drm_handle_t    handle;
+    int             mtrr;
+
+    printf("  VM map information:\n");
+    printf("  flags: (R)estricted (r)ead/(w)rite (l)ocked (k)ernel (W)rite-combine (L)ock:\n");
+    printf("    slot     offset       size type flags    address mtrr\n");
+
+    for (i = 0;
+	 !drmGetMap(fd, i, &offset, &size, &type, &flags, &handle, &mtrr);
+	 i++) {
+	
+	switch (type) {
+	case DRM_FRAME_BUFFER:   typename = "FB";  break;
+	case DRM_REGISTERS:      typename = "REG"; break;
+	case DRM_SHM:            typename = "SHM"; break;
+	case DRM_AGP:            typename = "AGP"; break;
+	case DRM_SCATTER_GATHER: typename = "SG";  break;
+	default:                 typename = "???"; break;
+	}
+
+	flagname[0] = (flags & DRM_RESTRICTED)      ? 'R' : ' ';
+	flagname[1] = (flags & DRM_READ_ONLY)       ? 'r' : 'w';
+	flagname[2] = (flags & DRM_LOCKED)          ? 'l' : ' ';
+	flagname[3] = (flags & DRM_KERNEL)          ? 'k' : ' ';
+	flagname[4] = (flags & DRM_WRITE_COMBINING) ? 'W' : ' ';
+	flagname[5] = (flags & DRM_CONTAINS_LOCK)   ? 'L' : ' ';
+	flagname[6] = '\0';
+	
+	printf("    %4d 0x%08lx 0x%08lx %3.3s %6.6s 0x%08lx ",
+	       i, offset, (unsigned long)size, typename, flagname, handle);
+	if (mtrr < 0) printf("none\n");
+	else          printf("%4d\n", mtrr);
+    }
+}
+
+static void getclients(int fd)
+{
+    int           i;
+    int           auth;
+    int           pid;
+    int           uid;
+    unsigned long magic;
+    unsigned long iocs;
+    char          buf[64];
+    char          cmd[40];
+    int           procfd;
+    
+    printf("  DRI client information:\n");
+    printf("    a   pid   uid      magic     ioctls   prog\n");
+
+    for (i = 0; !drmGetClient(fd, i, &auth, &pid, &uid, &magic, &iocs); i++) {
+	sprintf(buf, "/proc/%d/cmdline", pid);
+	memset(cmd, 0, sizeof(cmd));
+	if ((procfd = open(buf, O_RDONLY, 0)) >= 0) {
+	    read(procfd, cmd, sizeof(cmd)-1);
+	    close(procfd);
+	}
+	if (*cmd) {
+	    char *pt;
+
+	    for (pt = cmd; *pt; pt++) if (!isprint(*pt)) *pt = ' ';
+	    printf("    %c %5d %5d %10lu %10lu   %s\n",
+		   auth ? 'y' : 'n', pid, uid, magic, iocs, cmd);
+	} else {
+	    printf("    %c %5d %5d %10lu %10lu\n",
+		   auth ? 'y' : 'n', pid, uid, magic, iocs);
+	}
+    }
+}
+
+static void printhuman(unsigned long value, const char *name, int mult)
+{
+    const char *p;
+    double     f;
+				/* Print width 5 number in width 6 space */
+    if (value < 100000) {
+	printf(" %5lu", value);
+	return;
+    }
+
+    p = name;
+    f = (double)value / (double)mult;
+    if (f < 10.0) {
+	printf(" %4.2f%c", f, *p);
+	return;
+    }
+
+    p++;
+    f = (double)value / (double)mult;
+    if (f < 10.0) {
+	printf(" %4.2f%c", f, *p);
+	return;
+    }
+    
+    p++;
+    f = (double)value / (double)mult;
+    if (f < 10.0) {
+	printf(" %4.2f%c", f, *p);
+	return;
+    }
+}
+
+static void getstats(int fd, int i)
+{
+    drmStatsT prev, curr;
+    int       j;
+    double    rate;
+    
+    printf("  System statistics:\n");
+
+    if (drmGetStats(fd, &prev)) return;
+    if (!i) {
+	for (j = 0; j < prev.count; j++) {
+	    printf("    ");
+	    printf(prev.data[j].long_format, prev.data[j].long_name);
+	    if (prev.data[j].isvalue) printf(" 0x%08lx\n", prev.data[j].value);
+	    else                      printf(" %10lu\n", prev.data[j].value);
+	}
+	return;
+    }
+
+    printf("    ");
+    for (j = 0; j < prev.count; j++)
+	if (!prev.data[j].verbose) {
+	    printf(" ");
+	    printf(prev.data[j].rate_format, prev.data[j].rate_name);
+	}
+    printf("\n");
+    
+    for (;;) {
+	sleep(i);
+	if (drmGetStats(fd, &curr)) return;
+	printf("    ");
+	for (j = 0; j < curr.count; j++) {
+	    if (curr.data[j].verbose) continue;
+	    if (curr.data[j].isvalue) {
+		printf(" %08lx", curr.data[j].value);
+	    } else {
+		rate = (curr.data[j].value - prev.data[j].value) / (double)i;
+		printhuman(rate, curr.data[j].mult_names, curr.data[j].mult);
+	    }
+	}
+	printf("\n");
+	memcpy(&prev, &curr, sizeof(prev));
+    }
+    
+}
+
+int main(int argc, char **argv)
+{
+    int  c;
+    int  mask     = 0;
+    int  minor    = 0;
+    int  interval = 0;
+    int  fd;
+    char buf[64];
+    int  i;
+
+    while ((c = getopt(argc, argv, "avmcsbM:i:")) != EOF)
+	switch (c) {
+	case 'a': mask = ~0;                          break;
+	case 'v': mask |= DRM_VERSION;                break;
+	case 'm': mask |= DRM_MEMORY;                 break;
+	case 'c': mask |= DRM_CLIENTS;                break;
+	case 's': mask |= DRM_STATS;                  break;
+	case 'b': mask |= DRM_BUSID;                  break;
+	case 'i': interval = strtol(optarg, NULL, 0); break;
+	case 'M': minor = strtol(optarg, NULL, 0);    break;
+	default:
+	    fprintf( stderr, "Usage: dristat [options]\n\n" );
+	    fprintf( stderr, "Displays DRM information. Use with no arguments to display available cards.\n\n" );
+	    fprintf( stderr, "  -a            Show all available information\n" );
+	    fprintf( stderr, "  -b            Show DRM bus ID's\n" );
+	    fprintf( stderr, "  -c            Display information about DRM clients\n" );
+	    fprintf( stderr, "  -i [interval] Continuously display statistics every [interval] seconds\n" );
+	    fprintf( stderr, "  -v            Display DRM module and card version information\n" );
+	    fprintf( stderr, "  -m            Display memory use information\n" );
+	    fprintf( stderr, "  -s            Display DRM statistics\n" );
+	    fprintf( stderr, "  -M [minor]    Select card by minor number\n" );
+	    return 1;
+	}
+
+    for (i = 0; i < 16; i++) if (!minor || i == minor) {
+	sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, i);
+	fd = drmOpenMinor(i, 1);
+	if (fd >= 0) {
+	    printf("%s\n", buf);
+	    if (mask & DRM_BUSID)   getbusid(fd);
+	    if (mask & DRM_VERSION) getversion(fd);
+	    if (mask & DRM_MEMORY)  getvm(fd);
+	    if (mask & DRM_CLIENTS) getclients(fd);
+	    if (mask & DRM_STATS)   getstats(fd, interval);
+	    close(fd);
+	}
+    }
+
+    return 0; 
+}
diff --git a/tests/drmstat.c b/tests/drmstat.c
new file mode 100644
index 0000000..ed2aeb6
--- /dev/null
+++ b/tests/drmstat.c
@@ -0,0 +1,425 @@
+/* drmstat.c -- DRM device status and testing program
+ * Created: Tue Jan  5 08:19:24 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ * 
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <getopt.h>
+#include <strings.h>
+#include <errno.h>
+#include <signal.h>
+#include <fcntl.h>
+#include "xf86drm.h"
+
+int sigio_fd;
+
+static double usec(struct timeval *end, struct timeval *start)
+{
+    double e = end->tv_sec   * 1000000 + end->tv_usec;
+    double s = start->tv_sec * 1000000 + start->tv_usec;
+
+    return e - s;
+}
+
+static void getversion(int fd)
+{
+    drmVersionPtr version;
+    
+    version = drmGetVersion(fd);
+    if (version) {
+	printf( "Name: %s\n", version->name ? version->name : "?" );
+	printf( "    Version: %d.%d.%d\n",
+		version->version_major,
+		version->version_minor,
+		version->version_patchlevel );
+	printf( "    Date: %s\n", version->date ? version->date : "?" );
+	printf( "    Desc: %s\n", version->desc ? version->desc : "?" );
+	drmFreeVersion(version);
+    } else {
+	printf( "No driver available\n" );
+    }
+}
+	
+void handler(int fd, void *oldctx, void *newctx)
+{
+    printf("Got fd %d\n", fd);
+}
+
+void process_sigio(char *device)
+{
+    int              fd;
+
+    if ((fd = open(device, 0)) < 0) {
+	drmError(-errno, __FUNCTION__);
+	exit(1);
+    }
+
+    sigio_fd = fd;
+    /*  drmInstallSIGIOHandler(fd, handler); */
+    for (;;) sleep(60);
+}
+
+int main(int argc, char **argv)
+{
+    int            c;
+    int            r  = 0;
+    int            fd = -1;
+    drm_handle_t      handle;
+    void           *address;
+    char           *pt;
+    unsigned long  count;
+    unsigned long  offset;
+    unsigned long  size;
+    drm_context_t  context;
+    int            loops;
+    char           buf[1024];
+    int            i;
+    drmBufInfoPtr  info;
+    drmBufMapPtr   bufs;
+    drmLockPtr     lock;
+    int            secs;
+
+    while ((c = getopt(argc, argv,
+		       "lc:vo:O:f:s:w:W:b:r:R:P:L:C:XS:B:F:")) != EOF)
+	switch (c) {
+	case 'F':
+	    count  = strtoul(optarg, NULL, 0);
+	    if (!fork()) {
+		dup(fd);
+		sleep(count);
+	    }
+	    close(fd);
+	    break;
+	case 'v': getversion(fd);                                        break;
+	case 'X':
+	    if ((r = drmCreateContext(fd, &context))) {
+		drmError(r, argv[0]);
+		return 1;
+	    }
+	    printf( "Got %d\n", context);
+	    break;
+	case 'S':
+	    process_sigio(optarg);
+	    break;
+	case 'C':
+	    if ((r = drmSwitchToContext(fd, strtoul(optarg, NULL, 0)))) {
+		drmError(r, argv[0]);
+		return 1;
+	    }
+	    break;
+	case 'c':
+	    if ((r = drmSetBusid(fd,optarg))) {
+		drmError(r, argv[0]);
+		return 1;
+	    }
+	    break;
+	case 'o':
+	    if ((fd = drmOpen(optarg, NULL)) < 0) {
+		drmError(fd, argv[0]);
+		return 1;
+	    }
+	    break;
+	case 'O':
+	    if ((fd = drmOpen(NULL, optarg)) < 0) {
+		drmError(fd, argv[0]);
+		return 1;
+	    }
+	    break;
+	case 'B':		/* Test buffer allocation */
+	    count  = strtoul(optarg, &pt, 0);
+	    size   = strtoul(pt+1, &pt, 0);
+	    secs   = strtoul(pt+1, NULL, 0);
+	    {
+		drmDMAReq      dma;
+		int            *indices, *sizes;
+
+		indices = alloca(sizeof(*indices) * count);
+		sizes   = alloca(sizeof(*sizes)   * count);
+		dma.context         = context;
+		dma.send_count      = 0;
+		dma.request_count   = count;
+		dma.request_size    = size;
+		dma.request_list    = indices;
+		dma.request_sizes   = sizes;
+		dma.flags           = DRM_DMA_WAIT;
+		if ((r = drmDMA(fd, &dma))) {
+		    drmError(r, argv[0]);
+		    return 1;
+		}
+		for (i = 0; i < dma.granted_count; i++) {
+		    printf("%5d: index = %d, size = %d\n",
+			   i, dma.request_list[i], dma.request_sizes[i]);
+		}
+		sleep(secs);
+		drmFreeBufs(fd, dma.granted_count, indices);
+	    }
+	    break;
+	case 'b':
+	    count   = strtoul(optarg, &pt, 0);
+	    size    = strtoul(pt+1, NULL, 0);
+	    if ((r = drmAddBufs(fd, count, size, 0, 65536)) < 0) {
+		drmError(r, argv[0]);
+		return 1;
+	    }
+	    if (!(info = drmGetBufInfo(fd))) {
+		drmError(0, argv[0]);
+		return 1;
+	    }
+	    for (i = 0; i < info->count; i++) {
+		printf("%5d buffers of size %6d (low = %d, high = %d)\n",
+		       info->list[i].count,
+		       info->list[i].size,
+		       info->list[i].low_mark,
+		       info->list[i].high_mark);
+	    }
+	    if ((r = drmMarkBufs(fd, 0.50, 0.80))) {
+		drmError(r, argv[0]);
+		return 1;
+	    }
+	    if (!(info = drmGetBufInfo(fd))) {
+		drmError(0, argv[0]);
+		return 1;
+	    }
+	    for (i = 0; i < info->count; i++) {
+		printf("%5d buffers of size %6d (low = %d, high = %d)\n",
+		       info->list[i].count,
+		       info->list[i].size,
+		       info->list[i].low_mark,
+		       info->list[i].high_mark);
+	    }
+	    printf("===== /proc/dri/0/mem =====\n");
+	    sprintf(buf, "cat /proc/dri/0/mem");
+	    system(buf);
+#if 1
+	    if (!(bufs = drmMapBufs(fd))) {
+		drmError(0, argv[0]);
+		return 1;
+	    }
+	    printf("===============================\n");
+	    printf( "%d bufs\n", bufs->count);
+	    for (i = 0; i < bufs->count; i++) {
+		printf( "  %4d: %8d bytes at %p\n",
+			i,
+			bufs->list[i].total,
+			bufs->list[i].address);
+	    }
+	    printf("===== /proc/dri/0/vma =====\n");
+	    sprintf(buf, "cat /proc/dri/0/vma");
+	    system(buf);
+#endif
+	    break;
+	case 'f':
+	    offset  = strtoul(optarg, &pt, 0);
+	    size    = strtoul(pt+1, NULL, 0);
+	    handle  = 0;
+	    if ((r = drmAddMap(fd, offset, size,
+			       DRM_FRAME_BUFFER, 0, &handle))) {
+		drmError(r, argv[0]);
+		return 1;
+	    }
+	    printf("0x%08lx:0x%04lx added\n", offset, size);
+	    printf("===== /proc/dri/0/mem =====\n");
+	    sprintf(buf, "cat /proc/dri/0/mem");
+	    system(buf);
+	    break;
+	case 'r':
+	case 'R':
+	    offset  = strtoul(optarg, &pt, 0);
+	    size    = strtoul(pt+1, NULL, 0);
+	    handle  = 0;
+	    if ((r = drmAddMap(fd, offset, size,
+			       DRM_REGISTERS,
+			       c == 'R' ? DRM_READ_ONLY : 0,
+			       &handle))) {
+		drmError(r, argv[0]);
+		return 1;
+	    }
+	    printf("0x%08lx:0x%04lx added\n", offset, size);
+	    printf("===== /proc/dri/0/mem =====\n");
+	    sprintf(buf, "cat /proc/dri/0/mem");
+	    system(buf);
+	    break;
+	case 's':
+	    size = strtoul(optarg, &pt, 0);
+	    handle = 0;
+	    if ((r = drmAddMap(fd, 0, size,
+			       DRM_SHM, DRM_CONTAINS_LOCK,
+			       &handle))) {
+		drmError(r, argv[0]);
+		return 1;
+	    }
+	    printf("0x%04lx byte shm added at 0x%08lx\n", size, handle);
+	    sprintf(buf, "cat /proc/dri/0/vm");
+	    system(buf);
+	    break;
+	case 'P':
+	    offset  = strtoul(optarg, &pt, 0);
+	    size    = strtoul(pt+1, NULL, 0);
+	    address = NULL;
+	    if ((r = drmMap(fd, offset, size, &address))) {
+		drmError(r, argv[0]);
+		return 1;
+	    }
+	    printf("0x%08lx:0x%04lx mapped at %p for pid %d\n",
+		   offset, size, address, getpid());
+	    printf("===== /proc/dri/0/vma =====\n");
+	    sprintf(buf, "cat /proc/dri/0/vma");
+	    system(buf);
+	    mprotect((void *)offset, size, PROT_READ);
+	    printf("===== /proc/dri/0/vma =====\n");
+	    sprintf(buf, "cat /proc/dri/0/vma");
+	    system(buf);
+	    break;
+	case 'w':
+	case 'W':
+	    offset  = strtoul(optarg, &pt, 0);
+	    size    = strtoul(pt+1, NULL, 0);
+	    address = NULL;
+	    if ((r = drmMap(fd, offset, size, &address))) {
+		drmError(r, argv[0]);
+		return 1;
+	    }
+	    printf("0x%08lx:0x%04lx mapped at %p for pid %d\n",
+		   offset, size, address, getpid());
+	    printf("===== /proc/%d/maps =====\n", getpid());
+	    sprintf(buf, "cat /proc/%d/maps", getpid());
+	    system(buf);
+	    printf("===== /proc/dri/0/mem =====\n");
+	    sprintf(buf, "cat /proc/dri/0/mem");
+	    system(buf);
+	    printf("===== /proc/dri/0/vma =====\n");
+	    sprintf(buf, "cat /proc/dri/0/vma");
+	    system(buf);
+	    printf("===== READING =====\n");
+	    for (i = 0; i < 0x10; i++)
+		printf("%02x ", (unsigned int)((unsigned char *)address)[i]);
+	    printf("\n");
+	    if (c == 'w') {
+		printf("===== WRITING =====\n");
+		for (i = 0; i < size; i+=2) {
+		    ((char *)address)[i]   = i & 0xff;
+		    ((char *)address)[i+1] = i & 0xff;
+		}
+	    }
+	    printf("===== READING =====\n");
+	    for (i = 0; i < 0x10; i++)
+		printf("%02x ", (unsigned int)((unsigned char *)address)[i]);
+	    printf("\n");
+	    printf("===== /proc/dri/0/vma =====\n");
+	    sprintf(buf, "cat /proc/dri/0/vma");
+	    system(buf);
+	    break;
+	case 'L':
+	    context = strtoul(optarg, &pt, 0);
+	    offset  = strtoul(pt+1, &pt, 0);
+	    size    = strtoul(pt+1, &pt, 0);
+	    loops   = strtoul(pt+1, NULL, 0);
+	    address = NULL;
+	    if ((r = drmMap(fd, offset, size, &address))) {
+		drmError(r, argv[0]);
+		return 1;
+	    }
+	    lock       = address;
+#if 1
+	    {
+		int            counter = 0;
+		struct timeval loop_start, loop_end;
+		struct timeval lock_start, lock_end;
+		double         wt;


Reply to: