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

libdrm: Changes to 'upstream-unstable'



Rebased ref, commits from common ancestor:
commit 18d3cc076b53f2032eed1f9a4b21947f4cb9e4e7
Author: Eric Anholt <eric@anholt.net>
Date:   Wed Jan 14 16:11:32 2009 -0800

    bump version to 2.4.4

diff --git a/configure.ac b/configure.ac
index 11d238c..a842b8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@
 #  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 AC_PREREQ(2.57)
-AC_INIT([libdrm], 2.4.3, [dri-devel@lists.sourceforge.net], libdrm)
+AC_INIT([libdrm], 2.4.4, [dri-devel@lists.sourceforge.net], libdrm)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2])
 

commit 02445eab6432709abe2b06020c014be527d58ead
Author: Eric Anholt <eric@anholt.net>
Date:   Sun Jan 4 17:37:18 2009 -0800

    intel: Retry pin ioctl on -EINTR.

diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c
index c510e5e..7b821de 100644
--- a/libdrm/intel/intel_bufmgr_gem.c
+++ b/libdrm/intel/intel_bufmgr_gem.c
@@ -999,7 +999,10 @@ drm_intel_gem_bo_pin(drm_intel_bo *bo, uint32_t alignment)
     pin.handle = bo_gem->gem_handle;
     pin.alignment = alignment;
 
-    ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_PIN, &pin);
+    do {
+	ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_PIN, &pin);
+    } while (ret == -1 && errno == EINTR);
+
     if (ret != 0)
 	return -errno;
 

commit 65b90fb37744fdd335c59fdc70079fa058301858
Author: Owain G. Ainsworth <oga@openbsd.org>
Date:   Sat Jan 10 18:48:46 2009 +0000

    Don't use DRM_BO_FLAG_NO_MOVE in bufmgr fake. It's a ttm flag.
    
    It's also unused, so worthless.

diff --git a/libdrm/intel/intel_bufmgr_fake.c b/libdrm/intel/intel_bufmgr_fake.c
index 6d8ee85..6c21625 100644
--- a/libdrm/intel/intel_bufmgr_fake.c
+++ b/libdrm/intel/intel_bufmgr_fake.c
@@ -833,7 +833,7 @@ drm_intel_bo_fake_alloc_static(drm_intel_bufmgr *bufmgr, const char *name,
    bo_fake->refcount = 1;
    bo_fake->id = ++bufmgr_fake->buf_nr;
    bo_fake->name = name;
-   bo_fake->flags = BM_PINNED | DRM_BO_FLAG_NO_MOVE;
+   bo_fake->flags = BM_PINNED;
    bo_fake->is_static = 1;
 
    DBG("drm_bo_alloc_static: (buf %d: %s, %d kb)\n", bo_fake->id, bo_fake->name,

commit 13ff0e58c36458a058e5c0676af04000c64a94f6
Author: Owain G. Ainsworth <oga@openbsd.org>
Date:   Sun Jan 11 19:02:07 2009 +0000

    Remove drmModeReplaceFb after it was removed from the kernel.
    
    It is impossible to replace the original semantics of this call purely
    in userland, since the fb_id would change.
    
    after discussion with Dr_Jakob
    
    Signed-Off-By: Owain Ainsworth <oga@openbsd.org>
    Acked-By: Jakob Bornecrantz <jakob@vmware.com>

diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c
index f481428..6ec7d59 100644
--- a/libdrm/xf86drmMode.c
+++ b/libdrm/xf86drmMode.c
@@ -628,27 +628,6 @@ int drmCheckModesettingSupported(const char *busid)
 
 }
 
-int drmModeReplaceFB(int fd, uint32_t buffer_id,
-		     uint32_t width, uint32_t height, uint8_t depth,
-		     uint8_t bpp, uint32_t pitch, uint32_t bo_handle)
-{
-	struct drm_mode_fb_cmd f;
-	int ret;
-
-	f.width = width;
-	f.height = height;
-	f.pitch = pitch;
-	f.bpp = bpp;
-	f.depth = depth;
-	f.handle = bo_handle;
-	f.fb_id = buffer_id;
-
-	if ((ret = drmIoctl(fd, DRM_IOCTL_MODE_REPLACEFB, &f)))
-		return ret;
-
-	return 0;
-}
-
 int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
 			uint16_t *red, uint16_t *green, uint16_t *blue)
 {
diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h
index 965b7be..378afe4 100644
--- a/libdrm/xf86drmMode.h
+++ b/libdrm/xf86drmMode.h
@@ -180,13 +180,6 @@ extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
  */
 extern int drmModeRmFB(int fd, uint32_t bufferId);
 
-/**
- * Replace a framebuffer object with a new one - for resizing the screen.
- */
-extern int drmModeReplaceFB(int fd, uint32_t buffer_id,
-			    uint32_t width, uint32_t height, uint8_t depth,
-			    uint8_t bpp, uint32_t pitch, uint32_t bo_handle);
-
 /*
  * Crtc functions
  */

commit ac8b3308b9432edef5cabe30559004314d42d98c
Author: Ben Skeggs <skeggsb@gmail.com>
Date:   Mon Jan 12 10:16:07 2009 +1000

    nv50: ack nsource to prevent continuous protection fault irqs

diff --git a/shared-core/nouveau_irq.c b/shared-core/nouveau_irq.c
index 2a3d8a0..f4eb72b 100644
--- a/shared-core/nouveau_irq.c
+++ b/shared-core/nouveau_irq.c
@@ -442,9 +442,10 @@ static void
 nv50_pgraph_irq_handler(struct drm_device *dev)
 {
 	struct drm_nouveau_private *dev_priv = dev->dev_private;
-	uint32_t status;
+	uint32_t status, nsource;
 
 	status = NV_READ(NV03_PGRAPH_INTR);
+	nsource = NV_READ(NV03_PGRAPH_NSOURCE);
 
 	if (status & 0x00000020) {
 		nouveau_pgraph_intr_error(dev,
@@ -463,10 +464,29 @@ nv50_pgraph_irq_handler(struct drm_device *dev)
 	}
 
 	if (status & 0x00200000) {
-		nouveau_pgraph_intr_error(dev,
+		int r;
+
+		nouveau_pgraph_intr_error(dev, nsource |
 					  NV03_PGRAPH_NSOURCE_PROTECTION_ERROR);
 
+		DRM_ERROR("magic set 1:\n");
+		for (r = 0x408900; r <= 0x408910; r += 4)
+			DRM_ERROR("\t0x%08x: 0x%08x\n", r, NV_READ(r));
+		NV_WRITE(0x408900, NV_READ(0x408904) | 0xc0000000);
+		for (r = 0x408e08; r <= 0x408e24; r += 4)
+			DRM_ERROR("\t0x%08x: 0x%08x\n", r, NV_READ(r));
+		NV_WRITE(0x408e08, NV_READ(0x408e08) | 0xc0000000);
+
+		DRM_ERROR("magic set 2:\n");
+		for (r = 0x409900; r <= 0x409910; r += 4)
+			DRM_ERROR("\t0x%08x: 0x%08x\n", r, NV_READ(r));
+		NV_WRITE(0x409900, NV_READ(0x409904) | 0xc0000000);
+		for (r = 0x409e08; r <= 0x409e24; r += 4)
+			DRM_ERROR("\t0x%08x: 0x%08x\n", r, NV_READ(r));
+		NV_WRITE(0x409e08, NV_READ(0x409e08) | 0xc0000000);
+
 		status &= ~0x00200000;
+		NV_WRITE(NV03_PGRAPH_NSOURCE, nsource);
 		NV_WRITE(NV03_PGRAPH_INTR, 0x00200000);
 	}
 

commit badc63464cbd64606c6dff9ea561a787d072fd5f
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Wed Jan 7 11:47:52 2009 -0800

    libdrm: add autoconf check for clock_gettime
    
    Should be more portable this way.

diff --git a/configure.ac b/configure.ac
index ccc58ef..11d238c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,13 @@ AC_DEFUN([LIBDRM_CC_TRY_FLAG], [
   AC_MSG_RESULT([$libdrm_cc_flag])
 ])
 
+dnl We use clock_gettime to check for timeouts in drmWaitVBlank
+
+AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
+               [AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt],
+                             [AC_MSG_ERROR([Couldn't find clock_gettime])])])
+AC_SUBST([CLOCK_LIB])
+
 dnl Use lots of warning flags with with gcc and compatible compilers
 
 dnl Note: if you change the following variable, the cache is automatically
diff --git a/libdrm/Makefile.am b/libdrm/Makefile.am
index 71a8718..a568aac 100644
--- a/libdrm/Makefile.am
+++ b/libdrm/Makefile.am
@@ -23,7 +23,7 @@ SUBDIRS = . intel
 libdrm_la_LTLIBRARIES = libdrm.la
 libdrm_ladir = $(libdir)
 libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined
-libdrm_la_LIBADD = -lrt
+libdrm_la_LIBADD = @CLOCK_LIB@
 
 AM_CFLAGS = -I$(top_srcdir)/shared-core
 libdrm_la_SOURCES = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c \

commit ca37077fb78b69a00500827f1db12b70affa1514
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Wed Jan 7 10:48:26 2009 -0800

    libdrm: only check for vblank timeout if we caught EINTR
    
    Michel caught a case where we might overwrite a success or other return
    value with EBUSY, so check the return value before checking for the
    timeout condition.

diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index 3396e28..55df19a 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -1910,13 +1910,16 @@ int drmWaitVBlank(int fd, drmVBlankPtr vbl)
     do {
        ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
        vbl->request.type &= ~DRM_VBLANK_RELATIVE;
-       clock_gettime(CLOCK_MONOTONIC, &cur);
-       /* Timeout after 1s */
-       if (cur.tv_sec > timeout.tv_sec + 1 ||
-	   cur.tv_sec == timeout.tv_sec && cur.tv_nsec >= timeout.tv_nsec) {
-	   errno = EBUSY;
-	   ret = -1;
-	   break;
+       if (ret && errno == EINTR) {
+	       clock_gettime(CLOCK_MONOTONIC, &cur);
+	       /* Timeout after 1s */
+	       if (cur.tv_sec > timeout.tv_sec + 1 ||
+		   (cur.tv_sec == timeout.tv_sec && cur.tv_nsec >=
+		    timeout.tv_nsec)) {
+		       errno = EBUSY;
+		       ret = -1;
+		       break;
+	       }
        }
     } while (ret && errno == EINTR);
 

commit f4f76a6894b40abd77f0ffbf52972127608b9bca
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Wed Jan 7 10:18:08 2009 -0800

    libdrm: add timeout handling to drmWaitVBlank
    
    In some cases, vblank interrupts may be disabled or otherwise broken.
    The kernel has a 3s timeout builtin to handle these cases, but the X
    server's SIGALM for cursor handling may interrupt vblank wait ioctls,
    causing libdrm to restart the ioctl, making the kernel's timeout
    useless.
    
    This change tracks time across ioctl restarts and returns EBUSY to the
    caller if the expected vblank sequence doesn't occur within 1s of the
    first call.
    
    Fixes fdo bz #18041, which is caused by a drmWaitVBlank hanging due to
    the corresponding pipe getting disabled (thus preventing further events
    from coming in).

diff --git a/libdrm/Makefile.am b/libdrm/Makefile.am
index eb63abe..71a8718 100644
--- a/libdrm/Makefile.am
+++ b/libdrm/Makefile.am
@@ -23,6 +23,7 @@ SUBDIRS = . intel
 libdrm_la_LTLIBRARIES = libdrm.la
 libdrm_ladir = $(libdir)
 libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined
+libdrm_la_LIBADD = -lrt
 
 AM_CFLAGS = -I$(top_srcdir)/shared-core
 libdrm_la_SOURCES = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c \
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index 0b5d31f..3396e28 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -42,6 +42,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <signal.h>
+#include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #define stat_t struct stat
@@ -1896,13 +1897,30 @@ int drmScatterGatherFree(int fd, drm_handle_t handle)
  */
 int drmWaitVBlank(int fd, drmVBlankPtr vbl)
 {
+    struct timespec timeout, cur;
     int ret;
 
+    ret = clock_gettime(CLOCK_MONOTONIC, &timeout);
+    if (ret < 0) {
+	fprintf(stderr, "clock_gettime failed: %s\n", strerror(ret));
+	goto out;
+    }
+    timeout.tv_sec++;
+
     do {
-       ret = drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
+       ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
        vbl->request.type &= ~DRM_VBLANK_RELATIVE;
+       clock_gettime(CLOCK_MONOTONIC, &cur);
+       /* Timeout after 1s */
+       if (cur.tv_sec > timeout.tv_sec + 1 ||
+	   cur.tv_sec == timeout.tv_sec && cur.tv_nsec >= timeout.tv_nsec) {
+	   errno = EBUSY;
+	   ret = -1;
+	   break;
+       }
     } while (ret && errno == EINTR);
 
+out:
     return ret;
 }
 

commit a8c548034e38d7fb8afeca100230818b3cfcb9d9
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Mon Dec 29 09:21:58 2008 -0800

    Remove executable from modeprint test dir
    
    Accidentally committed it with the mode setting changes.

diff --git a/tests/modeprint/app b/tests/modeprint/app
deleted file mode 100755
index 82085c8..0000000
Binary files a/tests/modeprint/app and /dev/null differ

commit 58d557c73b9e4ad1964fd083abeec74875c141cb
Author: Robert Noland <rnoland@2hip.net>
Date:   Tue Dec 23 13:56:23 2008 -0500

    [FreeBSD] Fix build on FreeBSD after modesetting import.

diff --git a/bsd-core/drm_mode.h b/bsd-core/drm_mode.h
new file mode 120000
index 0000000..a43f138
--- /dev/null
+++ b/bsd-core/drm_mode.h
@@ -0,0 +1 @@
+../shared-core/drm_mode.h
\ No newline at end of file
diff --git a/shared-core/drm_mode.h b/shared-core/drm_mode.h
index 601d2bd..9b92733 100644
--- a/shared-core/drm_mode.h
+++ b/shared-core/drm_mode.h
@@ -27,11 +27,13 @@
 #ifndef _DRM_MODE_H
 #define _DRM_MODE_H
 
+#ifdef __linux__
 #if !defined(__KERNEL__) && !defined(_KERNEL)
 #include <stdint.h>
 #else
 #include <linux/kernel.h>
 #endif
+#endif
 
 #define DRM_DISPLAY_INFO_LEN	32
 #define DRM_CONNECTOR_NAME_LEN	32

commit b48bd3a036efa3c3aa759759a5be4f80f1c3ac72
Author: Dave Airlie <airlied@redhat.com>
Date:   Tue Dec 23 11:22:44 2008 +1000

    radeon: only write irq regs if irq is enabled

diff --git a/shared-core/radeon_irq.c b/shared-core/radeon_irq.c
index 6956996..836f384 100644
--- a/shared-core/radeon_irq.c
+++ b/shared-core/radeon_irq.c
@@ -44,7 +44,8 @@ void radeon_irq_set_state(struct drm_device *dev, u32 mask, int state)
 	else
 		dev_priv->irq_enable_reg &= ~mask;
 
-	RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg);
+	if (dev->irq_enabled)
+		RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg);
 }
 
 static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state)
@@ -56,7 +57,8 @@ static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state)
 	else
 		dev_priv->r500_disp_irq_reg &= ~mask;
 
-	RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
+	if (dev->irq_enabled)
+		RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
 }
 
 int radeon_enable_vblank(struct drm_device *dev, int crtc)

commit dfd7fdafd8a2bad0d63ced4a969b6278c221c000
Author: Eric Anholt <eric@anholt.net>
Date:   Wed Dec 17 13:55:53 2008 -0800

    intel: Rename plane[AB]* back to pipe[AB]*.
    
    The values are really going to continue meaning pipe, not plane, and that's
    what they're called in the kernel copy of the header.  Userland hasn't ever
    made the switch to pipe!=plane, since userland checks are based on DRM
    version, which is still stuck at 1.6.  However, Mesa did start using
    plane[AB] names, so provide a compat define.

diff --git a/shared-core/i915_drm.h b/shared-core/i915_drm.h
index 628f7f8..04ab4cf 100644
--- a/shared-core/i915_drm.h
+++ b/shared-core/i915_drm.h
@@ -111,14 +111,25 @@ typedef struct drm_i915_sarea {
 	unsigned int rotated_tiled;
 	unsigned int rotated2_tiled;
 
-	int planeA_x;
-	int planeA_y;
-	int planeA_w;
-	int planeA_h;
-	int planeB_x;
-	int planeB_y;
-	int planeB_w;
-	int planeB_h;
+	/* compat defines for the period of time when pipeA_* got renamed
+	 * to planeA_*.  They mean pipe, really.
+	 */
+#define planeA_x pipeA_x
+#define planeA_y pipeA_y
+#define planeA_w pipeA_w
+#define planeA_h pipeA_h
+#define planeB_x pipeB_x
+#define planeB_y pipeB_y
+#define planeB_w pipeB_w
+#define planeB_h pipeB_h
+	int pipeA_x;
+	int pipeA_y;
+	int pipeA_w;
+	int pipeA_h;
+	int pipeB_x;
+	int pipeB_y;
+	int pipeB_w;
+	int pipeB_h;
 
 	/* Triple buffering */
 	drm_handle_t third_handle;

commit 28771e06dfe45027be6618f87335c19e8e88e3f6
Author: Eric Anholt <eric@anholt.net>
Date:   Wed Dec 17 13:47:59 2008 -0800

    intel: Remove linux build of i915 DRM, as it's unmaintained and a user trap.
    
    The code's in the linux kernel.

diff --git a/linux-core/Makefile b/linux-core/Makefile
index 157664e..5235721 100644
--- a/linux-core/Makefile
+++ b/linux-core/Makefile
@@ -63,7 +63,7 @@ MODULE_LIST := drm.o tdfx.o r128.o radeon.o mga.o sis.o savage.o via.o \
 # Modules only for ix86 architectures
 ifneq (,$(findstring 86,$(MACHINE)))
 ARCHX86 := 1
-MODULE_LIST += i810.o i915.o
+MODULE_LIST += i810.o
 endif
 
 ifneq (,$(findstring sparc64,$(MACHINE)))
@@ -281,7 +281,6 @@ CONFIG_DRM_MGA := n
 CONFIG_DRM_I810 := n
 CONFIG_DRM_R128 := n
 CONFIG_DRM_RADEON := n
-CONFIG_DRM_I915 := n
 CONFIG_DRM_SIS := n
 CONFIG_DRM_FFB := n
 CONFIG_DRM_SAVAGE := n
@@ -335,11 +334,6 @@ endif
 ifneq (,$(findstring i810,$(DRM_MODULES)))
 CONFIG_DRM_I810 := m
 endif
-ifneq (,$(findstring i915,$(DRM_MODULES)))
-ifeq ($(OS_HAS_GEM), 1)
-CONFIG_DRM_I915 := m
-endif
-endif
 
 GIT_REVISION := $(shell cd "$(DRMSRCDIR)" && git describe --abbrev=17)
 ifneq ($(GIT_REVISION),)
@@ -354,7 +348,6 @@ $(tdfx-objs):	$(TDFXHEADERS)
 $(r128-objs):	$(R128HEADERS)
 $(mga-objs):	$(MGAHEADERS)
 $(i810-objs):	$(I810HEADERS)
-$(i915-objs):	$(I915HEADERS)
 $(radeon-objs):	$(RADEONHEADERS)
 $(sis-objs):	$(SISHEADERS)
 $(ffb-objs):	$(FFBHEADERS)
diff --git a/linux-core/Makefile.kernel b/linux-core/Makefile.kernel
index e5af2ec..1d577a7 100644
--- a/linux-core/Makefile.kernel
+++ b/linux-core/Makefile.kernel
@@ -19,10 +19,6 @@ tdfx-objs   := tdfx_drv.o
 r128-objs   := r128_drv.o r128_cce.o r128_state.o r128_irq.o
 mga-objs    := mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o
 i810-objs   := i810_drv.o i810_dma.o
-i915-objs   := i915_drv.o i915_dma.o i915_irq.o i915_mem.o i915_fence.o \
-		i915_buffer.o i915_compat.o i915_execbuf.o i915_suspend.o \
-		i915_opregion.o \
-		i915_gem.o i915_gem_debug.o i915_gem_proc.o i915_gem_tiling.o
 nouveau-objs := nouveau_drv.o nouveau_state.o nouveau_fifo.o nouveau_mem.o \
 		nouveau_object.o nouveau_irq.o nouveau_notifier.o nouveau_swmthd.o \
 		nouveau_sgdma.o nouveau_dma.o nouveau_bo.o nouveau_fence.o \
@@ -49,7 +45,6 @@ drm-objs    += drm_ioc32.o
 radeon-objs += radeon_ioc32.o
 mga-objs    += mga_ioc32.o
 r128-objs   += r128_ioc32.o
-i915-objs   += i915_ioc32.o
 nouveau-objs += nouveau_ioc32.o
 xgi-objs    += xgi_ioc32.o
 endif
@@ -60,7 +55,6 @@ obj-$(CONFIG_DRM_R128)	+= r128.o
 obj-$(CONFIG_DRM_RADEON)+= radeon.o
 obj-$(CONFIG_DRM_MGA)	+= mga.o
 obj-$(CONFIG_DRM_I810)	+= i810.o
-obj-$(CONFIG_DRM_I915)	+= i915.o
 obj-$(CONFIG_DRM_SIS)   += sis.o
 obj-$(CONFIG_DRM_FFB)   += ffb.o
 obj-$(CONFIG_DRM_SAVAGE)+= savage.o

commit d221e00105477be824ff8878ba3c06b77efff84f
Author: Eric Anholt <eric@anholt.net>
Date:   Wed Dec 17 13:45:01 2008 -0800

    intel: Sync GEM ioctl comments for easier diffing against the kernel.

diff --git a/shared-core/i915_drm.h b/shared-core/i915_drm.h
index 976ff18..628f7f8 100644
--- a/shared-core/i915_drm.h
+++ b/shared-core/i915_drm.h
@@ -469,8 +469,12 @@ struct drm_i915_gem_pread {
 	uint64_t offset;
 	/** Length of data to read */
 	uint64_t size;
-	/** Pointer to write the data into. */
-	uint64_t data_ptr;	/* void *, but pointers are not 32/64 compatible */
+	/**
+	 * Pointer to write the data into.
+	 *
+	 * This is a fixed-size type for 32/64 compatibility.
+	 */
+	uint64_t data_ptr;
 };
 
 struct drm_i915_gem_pwrite {
@@ -481,8 +485,12 @@ struct drm_i915_gem_pwrite {
 	uint64_t offset;
 	/** Length of data to write */
 	uint64_t size;
-	/** Pointer to read the data from. */
-	uint64_t data_ptr;	/* void *, but pointers are not 32/64 compatible */
+	/**
+	 * Pointer to read the data from.
+	 *
+	 * This is a fixed-size type for 32/64 compatibility.
+	 */
+	uint64_t data_ptr;
 };
 
 struct drm_i915_gem_mmap {
@@ -497,8 +505,12 @@ struct drm_i915_gem_mmap {
 	 * The value will be page-aligned.
 	 */
 	uint64_t size;
-	/** Returned pointer the data was mapped at */
-	uint64_t addr_ptr;	/* void *, but pointers are not 32/64 compatible */
+	/**
+	 * Returned pointer the data was mapped at.
+	 *
+	 * This is a fixed-size type for 32/64 compatibility.
+	 */
+	uint64_t addr_ptr;
 };
 
 struct drm_i915_gem_mmap_gtt {
@@ -643,7 +655,8 @@ struct drm_i915_gem_execbuffer {
 	uint32_t DR1;
 	uint32_t DR4;
 	uint32_t num_cliprects;
-	uint64_t cliprects_ptr;	/* struct drm_clip_rect *cliprects */
+	/** This is a struct drm_clip_rect *cliprects */
+	uint64_t cliprects_ptr;
 };
 
 struct drm_i915_gem_pin {

commit 0243c9f801a35de3465a0321c02f18a4d07ce5b8
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Thu Dec 18 00:02:43 2008 -0500

    modetest: Print more stuff. Prettier.

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index e5a16e1..193057c 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -128,6 +128,22 @@ void dump_encoders(void)
 		       encoder->possible_clones);
 		drmModeFreeEncoder(encoder);
 	}
+	printf("\n");
+}
+
+void dump_mode(struct drm_mode_modeinfo *mode)
+{
+	printf("  %s %.02f %d %d %d %d %d %d %d %d\n",
+	       mode->name,
+	       (float)mode->vrefresh / 1000,
+	       mode->hdisplay,
+	       mode->hsync_start,
+	       mode->hsync_end,
+	       mode->htotal,
+	       mode->vdisplay,
+	       mode->vsync_start,
+	       mode->vsync_end,
+	       mode->vtotal);
 }
 
 void dump_connectors(void)
@@ -160,24 +176,12 @@ void dump_connectors(void)
 		printf("  modes:\n");
 		printf("  name refresh (Hz) hdisp hss hse htot vdisp "
 		       "vss vse vtot)\n");
-		for (j = 0; j < connector->count_modes; j++) {
-			struct drm_mode_modeinfo *mode;
+		for (j = 0; j < connector->count_modes; j++)
+			dump_mode(&connector->modes[j]);
 
-			mode = &connector->modes[j];
-			printf("  %s %.02f %d %d %d %d %d %d %d %d\n",
-			       mode->name,
-			       (float)mode->vrefresh / 1000,
-			       mode->hdisplay,
-			       mode->hsync_start,
-			       mode->hsync_end,
-			       mode->htotal,
-			       mode->vdisplay,
-			       mode->vsync_start,
-			       mode->vsync_end,
-			       mode->vtotal);
-		}
 		drmModeFreeConnector(connector);
 	}
+	printf("\n");
 }
 
 void dump_crtcs(void)
@@ -185,6 +189,8 @@ void dump_crtcs(void)
 	drmModeCrtc *crtc;
 	int i;
 
+	printf("CRTCs:\n");
+	printf("id\tfb\tpos\tsize\n");
 	for (i = 0; i < resources->count_crtcs; i++) {
 		crtc = drmModeGetCrtc(fd, resources->crtcs[i]);
 
@@ -193,8 +199,16 @@ void dump_crtcs(void)
 				resources->crtcs[i], strerror(errno));
 			continue;
 		}
+		printf("%d\t%d\t(%d,%d)\t(%dx%d)\n",
+		       crtc->crtc_id,
+		       crtc->buffer_id,
+		       crtc->x, crtc->y,
+		       crtc->width, crtc->height);
+		dump_mode(&crtc->mode);
+
 		drmModeFreeCrtc(crtc);
 	}
+	printf("\n");
 }
 
 void dump_framebuffers(void)
@@ -202,6 +216,8 @@ void dump_framebuffers(void)
 	drmModeFB *fb;
 	int i;
 
+	printf("Frame buffers:\n");
+	printf("id\tsize\tpitch\n");
 	for (i = 0; i < resources->count_fbs; i++) {
 		fb = drmModeGetFB(fd, resources->fbs[i]);
 
@@ -210,8 +226,13 @@ void dump_framebuffers(void)
 				resources->fbs[i], strerror(errno));
 			continue;
 		}
+		printf("%d\t(%dx%d)\t%d\n",
+		       fb->fb_id,
+		       fb->width, fb->height);
+
 		drmModeFreeFB(fb);
 	}
+	printf("\n");
 }
 
 /*

commit 06ab2f6436e26f77292d53e3ce2fe547d4a79fe3
Author: Eric Anholt <eric@anholt.net>
Date:   Wed Dec 17 10:41:21 2008 -0800

    libdrm: Fix modetest/modeprint to use automake stuff.

diff --git a/.gitignore b/.gitignore
index 796e74c..bd78034 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,4 +65,5 @@ tests/gem_readwrite
 tests/openclose
 tests/setversion
 tests/updatedraw
-tests/modetest
+tests/modeprint/modeprint
+tests/modetest/modetest
diff --git a/configure.ac b/configure.ac
index f4179fa..ccc58ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,4 +119,6 @@ AC_OUTPUT([
 	libdrm/intel/Makefile
 	shared-core/Makefile
 	tests/Makefile
+	tests/modeprint/Makefile
+	tests/modetest/Makefile
 	libdrm.pc])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 02b2ef0..e66d1c8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -15,7 +15,7 @@ libdrmtest_la_LIBADD = \
 
 LDADD = libdrmtest.la
 
-noinst_SUBDIRS = \
+SUBDIRS = \
 	modeprint \
 	modetest
 
diff --git a/tests/modeprint/Makefile b/tests/modeprint/Makefile
deleted file mode 100644
index 70788dc..0000000
--- a/tests/modeprint/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-
-all: app
-
-#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \
-#        -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \
-
-app: modeprint.c
-	@gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm modeprint.c
-
-clean:
-	@rm -f app
-
-run: app
-	@sudo ./test
diff --git a/tests/modeprint/Makefile.am b/tests/modeprint/Makefile.am
new file mode 100644
index 0000000..77f8ec7
--- /dev/null
+++ b/tests/modeprint/Makefile.am
@@ -0,0 +1,13 @@
+AM_CFLAGS = \
+	-I$(top_srcdir)/shared-core \
+	-I$(top_srcdir)/libdrm/intel/ \
+	-I$(top_srcdir)/libdrm
+
+noinst_PROGRAMS = \
+	modeprint
+
+modeprint_SOURCES = \
+	modeprint.c
+modeprint_LDADD = \
+	$(top_builddir)/libdrm/libdrm.la \
+	$(top_builddir)/libdrm/intel/libdrm_intel.la
diff --git a/tests/modeprint/test b/tests/modeprint/test
deleted file mode 100644
index bd1952c..0000000
--- a/tests/modeprint/test
+++ /dev/null
@@ -1 +0,0 @@
-LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app $@
diff --git a/tests/modetest/Makefile b/tests/modetest/Makefile
deleted file mode 100644
index 8583ae8..0000000
--- a/tests/modetest/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-
-all: app
-
-#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \
-#        -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \
-
-app: modetest.c
-	gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../libdrm/intel -I../../shared-core -L../../libdrm/.libs -L../../libdrm/intel/.libs -ldrm -ldrm_intel modetest.c
-
-clean:
-	@rm -f app
-
-run: app
-	sudo ./test
diff --git a/tests/modetest/Makefile.am b/tests/modetest/Makefile.am
new file mode 100644
index 0000000..b89c489
--- /dev/null
+++ b/tests/modetest/Makefile.am
@@ -0,0 +1,13 @@
+AM_CFLAGS = \
+	-I$(top_srcdir)/shared-core \
+	-I$(top_srcdir)/libdrm/intel/ \
+	-I$(top_srcdir)/libdrm
+
+noinst_PROGRAMS = \
+	modetest
+
+modetest_SOURCES = \
+	modetest.c
+modetest_LDADD = \
+	$(top_builddir)/libdrm/libdrm.la \
+	$(top_builddir)/libdrm/intel/libdrm_intel.la
diff --git a/tests/modetest/test b/tests/modetest/test
deleted file mode 100644
index 5bb552e..0000000
--- a/tests/modetest/test
+++ /dev/null
@@ -1,2 +0,0 @@
-export LD_LIBRARY_PATH=../../libdrm/.libs:../../libdrm/intel/.libs
-LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app $@

commit 18f091d136cd44ab397817f8a3e89c21e9561a31
Author: Keith Packard <keithp@keithp.com>
Date:   Mon Dec 15 15:08:12 2008 -0800

    intel: Cache tiling/swizzle state in user mode. Reset tiling on reuse.
    
    Remember tiling mode values provided by appplications, and
    record tiling mode when creating a buffer from another application. This
    eliminates any need to ask the kernel for tiling values and also makes
    reused buffers get the right tiling.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>

diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c
index 5e9350f..c510e5e 100644
--- a/libdrm/intel/intel_bufmgr_gem.c
+++ b/libdrm/intel/intel_bufmgr_gem.c
@@ -127,6 +127,12 @@ struct _drm_intel_bo_gem {
      */
     int swrast;
 
+    /**
+     * Current tiling mode
+     */
+    uint32_t tiling_mode;
+    uint32_t swizzle_mode;
+
     /** Array passed to the DRM containing relocation information. */
     struct drm_i915_gem_relocation_entry *relocs;
     /** Array of bos corresponding to relocs[i].target_handle */
@@ -170,6 +176,17 @@ static unsigned int
 drm_intel_gem_compute_batch_space(drm_intel_bo **bo_array, int count);
 
 static int
+drm_intel_gem_bo_get_tiling(drm_intel_bo *bo, uint32_t *tiling_mode,
+			    uint32_t *swizzle_mode);
+
+static int
+drm_intel_gem_bo_set_tiling(drm_intel_bo *bo, uint32_t *tiling_mode,
+			    uint32_t stride);
+
+static void
+drm_intel_gem_bo_unreference(drm_intel_bo *bo);
+
+static int
 logbase2(int n)
 {
    int i = 1;
@@ -370,6 +387,8 @@ drm_intel_gem_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name,
     bo_gem->validate_index = -1;
     bo_gem->reloc_tree_size = bo_gem->bo.size;
     bo_gem->used_as_reloc_target = 0;
+    bo_gem->tiling_mode = I915_TILING_NONE;
+    bo_gem->swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
 
     DBG("bo_create: buf %d (%s) %ldb\n",
 	bo_gem->gem_handle, bo_gem->name, size);
@@ -391,6 +410,7 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr, const char *name,
     drm_intel_bo_gem *bo_gem;
     int ret;
     struct drm_gem_open open_arg;
+    struct drm_i915_gem_get_tiling get_tiling;
 
     bo_gem = calloc(1, sizeof(*bo_gem));
     if (!bo_gem)
@@ -415,6 +435,15 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr, const char *name,
     bo_gem->gem_handle = open_arg.handle;
     bo_gem->global_name = handle;
 
+    get_tiling.handle = bo_gem->gem_handle;
+    ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling);
+    if (ret != 0) {
+	drm_intel_gem_bo_unreference(&bo_gem->bo);
+	return NULL;
+    }
+    bo_gem->tiling_mode = get_tiling.tiling_mode;
+    bo_gem->swizzle_mode = get_tiling.swizzle_mode;
+
     DBG("bo_create_from_handle: %d (%s)\n", handle, bo_gem->name);
 
     return &bo_gem->bo;
@@ -469,6 +498,7 @@ drm_intel_gem_bo_unreference_locked(drm_intel_bo *bo)
 
     if (--bo_gem->refcount == 0) {
 	struct drm_intel_gem_bo_bucket *bucket;
+	uint32_t tiling_mode;
 
 	if (bo_gem->relocs != NULL) {
 	    int i;
@@ -485,11 +515,13 @@ drm_intel_gem_bo_unreference_locked(drm_intel_bo *bo)
 
 	bucket = drm_intel_gem_bo_bucket_for_size(bufmgr_gem, bo->size);
 	/* Put the buffer into our internal cache for reuse if we can. */
+	tiling_mode = I915_TILING_NONE;
 	if (bo_gem->global_name == 0 &&
 	    bucket != NULL &&
 	    (bucket->max_entries == -1 ||
 	     (bucket->max_entries > 0 &&
-	      bucket->num_entries < bucket->max_entries)))
+	      bucket->num_entries < bucket->max_entries)) &&
+	    drm_intel_gem_bo_set_tiling(bo, &tiling_mode, 0) == 0)
 	{
 	    bo_gem->name = NULL;
 	    bo_gem->validate_index = -1;
@@ -1001,17 +1033,22 @@ drm_intel_gem_bo_set_tiling(drm_intel_bo *bo, uint32_t *tiling_mode,
     struct drm_i915_gem_set_tiling set_tiling;
     int ret;
 
+    if (bo_gem->global_name == 0 && *tiling_mode == bo_gem->tiling_mode)
+	return 0;
+
     set_tiling.handle = bo_gem->gem_handle;
     set_tiling.tiling_mode = *tiling_mode;
     set_tiling.stride = stride;
 
     ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling);
     if (ret != 0) {
-	*tiling_mode = I915_TILING_NONE;
+	*tiling_mode = bo_gem->tiling_mode;
 	return -errno;
     }
+    bo_gem->tiling_mode = set_tiling.tiling_mode;
+    bo_gem->swizzle_mode = set_tiling.swizzle_mode;
 
-    *tiling_mode = set_tiling.tiling_mode;
+    *tiling_mode = bo_gem->tiling_mode;
     return 0;
 }
 
@@ -1019,22 +1056,10 @@ static int
 drm_intel_gem_bo_get_tiling(drm_intel_bo *bo, uint32_t *tiling_mode,
 			    uint32_t *swizzle_mode)
 {
-    drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
     drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
-    struct drm_i915_gem_get_tiling get_tiling;
-    int ret;
-


Reply to: