libdrm: Changes to 'upstream-unstable'
.gitignore | 2
Makefile.am | 4
README | 9
configure.ac | 20
libdrm/Makefile.am | 6
libdrm/intel/Makefile.am | 1
libdrm/intel/intel_bufmgr.c | 7
libdrm/intel/intel_bufmgr.h | 4
libdrm/intel/intel_bufmgr_fake.c | 1
libdrm/intel/intel_bufmgr_gem.c | 161
libdrm/intel/intel_bufmgr_priv.h | 10
libdrm/intel/intel_chipset.h | 71
libdrm/libdrm_lists.h | 2
libdrm/nouveau/Makefile.am | 40
libdrm/nouveau/libdrm_nouveau.pc.in | 10
libdrm/nouveau/nouveau_bo.c | 845 +++
libdrm/nouveau/nouveau_bo.h | 97
libdrm/nouveau/nouveau_channel.c | 178
libdrm/nouveau/nouveau_channel.h | 56
libdrm/nouveau/nouveau_class.h | 8006 ++++++++++++++++++++++++++++++
libdrm/nouveau/nouveau_device.c | 186
libdrm/nouveau/nouveau_device.h | 31
libdrm/nouveau/nouveau_dma.c | 216
libdrm/nouveau/nouveau_dma.h | 154
libdrm/nouveau/nouveau_drmif.h | 59
libdrm/nouveau/nouveau_fence.c | 249
libdrm/nouveau/nouveau_grobj.c | 138
libdrm/nouveau/nouveau_grobj.h | 48
libdrm/nouveau/nouveau_notifier.c | 146
libdrm/nouveau/nouveau_notifier.h | 63
libdrm/nouveau/nouveau_private.h | 203
libdrm/nouveau/nouveau_pushbuf.c | 276 +
libdrm/nouveau/nouveau_pushbuf.h | 160
libdrm/nouveau/nouveau_resource.c | 115
libdrm/nouveau/nouveau_resource.h | 48
libdrm/xf86drm.h | 48
libdrm/xf86drmMode.c | 8
libdrm/xf86drmMode.h | 127
libdrm_intel.pc.in | 10
linux-core/Kconfig | 15
linux-core/Makefile | 30
linux-core/Makefile.kernel | 3
linux-core/drm_compat.c | 29
linux-core/drm_compat.h | 27
linux-core/drm_fops.c | 2
linux-core/i915_buffer.c | 303 -
linux-core/i915_compat.c | 215
linux-core/i915_dma.c | 1
linux-core/i915_drm.h | 1
linux-core/i915_drv.c | 222
linux-core/i915_drv.h | 1
linux-core/i915_execbuf.c | 917 ---
linux-core/i915_fence.c | 273 -
linux-core/i915_gem.c | 2502 ---------
linux-core/i915_gem_debug.c | 202
linux-core/i915_gem_proc.c | 293 -
linux-core/i915_gem_tiling.c | 309 -
linux-core/i915_ioc32.c | 284 -
linux-core/i915_irq.c | 1
linux-core/i915_mem.c | 1
linux-core/i915_opregion.c | 389 -
linux-core/i915_suspend.c | 1
linux-core/nouveau_backlight.c | 175
linux-core/nv_drv.c | 94
linux-core/nv_drv.h | 1
shared-core/i915_drm.h | 2
shared-core/nouveau_drm.h | 123
shared-core/nouveau_drv.h | 7
shared-core/nouveau_fifo.c | 3
shared-core/nouveau_mem.c | 17
shared-core/nouveau_object.c | 7
shared-core/nouveau_reg.h | 6
shared-core/nouveau_state.c | 30
shared-core/nv04_instmem.c | 3
shared-core/nv40_graph.c | 19
shared-core/nv50_fifo.c | 2
shared-core/nv50_graph.c | 18
shared-core/nv50_grctx.h | 9423 ++++++++++++++++++++++++++++++++++++
shared-core/nv50_instmem.c | 7
shared-core/nv_drv.h | 52
tests/modetest/Makefile.am | 6
tests/modetest/modetest.c | 272 -
82 files changed, 21783 insertions(+), 6320 deletions(-)
New commits:
commit a773ce1db8801fcbbdb55b54172c9cd48b92e2d7
Author: Eric Anholt <eric@anholt.net>
Date: Mon Feb 23 13:30:20 2009 -0800
Add libdrm_intel.pc by popular demand.
diff --git a/.gitignore b/.gitignore
index bd78034..ba5440b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,6 +36,8 @@ i915.kld
install-sh
libdrm/config.h.in
libdrm.pc
+libdrm_intel.pc
+libdrm_nouveau.pc
libtool
ltmain.sh
mach64.kld
diff --git a/Makefile.am b/Makefile.am
index 5b1ae60..e105edd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,6 +25,6 @@ AUTOMAKE_OPTIONS = foreign
SUBDIRS = libdrm shared-core tests
pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm.pc
+pkgconfig_DATA = libdrm.pc libdrm_intel.pc
-EXTRA_DIST = libdrm.pc.in
+EXTRA_DIST = libdrm.pc.in libdrm_intel.pc.in
diff --git a/configure.ac b/configure.ac
index b37af72..04933c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -143,4 +143,5 @@ AC_OUTPUT([
tests/Makefile
tests/modeprint/Makefile
tests/modetest/Makefile
- libdrm.pc])
+ libdrm.pc
+ libdrm_intel.pc])
diff --git a/libdrm_intel.pc.in b/libdrm_intel.pc.in
new file mode 100644
index 0000000..ea71cc3
--- /dev/null
+++ b/libdrm_intel.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libdrm
+Description: Userspace interface to kernel DRM services
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -ldrm -ldrm_intel
+Cflags: -I${includedir} -I${includedir}/drm
commit 6feac49398d0f037103a4ae3d5a512badeed61fb
Author: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Date: Mon Feb 23 15:54:18 2009 -0500
Fix DRM_CAS() on Alpha. (#16549)
diff --git a/libdrm/xf86drm.h b/libdrm/xf86drm.h
index f9dd1bf..c1d173c 100644
--- a/libdrm/xf86drm.h
+++ b/libdrm/xf86drm.h
@@ -325,28 +325,28 @@ typedef struct _drmSetVersion {
#elif defined(__alpha__)
-#define DRM_CAS(lock, old, new, ret) \
- do { \
- int old32; \
- int cur32; \
- __asm__ __volatile__( \
- " mb\n" \
- " zap %4, 0xF0, %0\n" \
- " ldl_l %1, %2\n" \
- " zap %1, 0xF0, %1\n" \
- " cmpeq %0, %1, %1\n" \
- " beq %1, 1f\n" \
- " bis %5, %5, %1\n" \
- " stl_c %1, %2\n" \
- "1: xor %1, 1, %1\n" \
- " stl %1, %3" \
- : "=r" (old32), \
- "=&r" (cur32), \
- "=m" (__drm_dummy_lock(lock)),\
- "=m" (ret) \
- : "r" (old), \
- "r" (new)); \
- } while(0)
+#define DRM_CAS(lock, old, new, ret) \
+ do { \
+ int tmp, old32; \
+ __asm__ __volatile__( \
+ " addl $31, %5, %3\n" \
+ "1: ldl_l %0, %2\n" \
+ " cmpeq %0, %3, %1\n" \
+ " beq %1, 2f\n" \
+ " mov %4, %0\n" \
+ " stl_c %0, %2\n" \
+ " beq %0, 3f\n" \
+ " mb\n" \
+ "2: cmpeq %1, 0, %1\n" \
+ ".subsection 2\n" \
+ "3: br 1b\n" \
+ ".previous" \
+ : "=&r"(tmp), "=&r"(ret), \
+ "=m"(__drm_dummy_lock(lock)), \
+ "=&r"(old32) \
+ : "r"(new), "r"(old) \
+ : "memory"); \
+ } while (0)
#elif defined(__sparc__)
@@ -429,7 +429,9 @@ do { register unsigned int __old __asm("o0"); \
#define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
#endif
-#if defined(__alpha__) || defined(__powerpc__)
+#if defined(__alpha__)
+#define DRM_CAS_RESULT(_result) long _result
+#elif defined(__powerpc__)
#define DRM_CAS_RESULT(_result) int _result
#else
#define DRM_CAS_RESULT(_result) char _result
commit 9fc85b4084b69fefab3dbdf1f6cf97ccb47c963a
Author: Kristian Høgsberg <krh@redhat.com>
Date: Mon Feb 23 15:08:03 2009 -0500
modetest: Print names of properties.
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 9a82727..58e0e4c 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -138,7 +138,7 @@ void dump_encoders(void)
printf("\n");
}
-void dump_mode(struct drm_mode_modeinfo *mode)
+void dump_mode(drmModeModeInfo *mode)
{
printf(" %s %.02f %d %d %d %d %d %d %d %d\n",
mode->name,
@@ -153,6 +153,19 @@ void dump_mode(struct drm_mode_modeinfo *mode)
mode->vtotal);
}
+static void
+dump_props(drmModeConnector *connector)
+{
+ drmModePropertyPtr props;
+ int i;
+
+ for (i = 0; i < connector->count_props; i++) {
+ props = drmModeGetProperty(fd, connector->props[i]);
+ printf("\t%s, flags %d\n", props->name, props->flags);
+ drmModeFreeProperty(props);
+ }
+}
+
void dump_connectors(void)
{
drmModeConnector *connector;
@@ -187,6 +200,9 @@ void dump_connectors(void)
dump_mode(&connector->modes[j]);
drmModeFreeConnector(connector);
+
+ printf(" props:\n");
+ dump_props(connector);
}
printf("\n");
}
@@ -252,7 +268,7 @@ void dump_framebuffers(void)
struct connector {
int id;
char mode_str[64];
- struct drm_mode_modeinfo *mode;
+ drmModeModeInfo *mode;
drmModeEncoder *encoder;
int crtc;
};
commit 4a0d19ef4f210cea9e60c5acc355df03723ef808
Author: Pekka Paalanen <pq@iki.fi>
Date: Sun Feb 22 12:40:47 2009 +0200
Fix fix distcheck for optional nouveau stuff.
Tylo.
Signed-off-by: Pekka Paalanen <pq@iki.fi>
diff --git a/configure.ac b/configure.ac
index c1ee938..b37af72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,7 +123,7 @@ if test "x$UDEV" = xyes; then
AC_DEFINE(UDEV, 1, [Have UDEV support])
fi
-AM_CONDITIONAL(HAVE_NOUVEAU, [text "x$NOUVEAU" = xyes])
+AM_CONDITIONAL(HAVE_NOUVEAU, [test "x$NOUVEAU" = xyes])
PKG_CHECK_MODULES(CAIRO, cairo, [HAVE_CAIRO=yes], [HAVE_CAIRO=no])
if test "x$HAVE_CAIRO" = xyes; then
commit 4d5341340fb6df22fffa7d4a214c54c085a1b1cf
Author: Eric Anholt <eric@anholt.net>
Date: Sat Feb 21 10:01:40 2009 -0800
Fix distcheck for optional nouveau stuff.
diff --git a/configure.ac b/configure.ac
index 041374b..c1ee938 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,10 +123,7 @@ if test "x$UDEV" = xyes; then
AC_DEFINE(UDEV, 1, [Have UDEV support])
fi
-if test "x$NOUVEAU" = xyes; then
-NOUVEAU_SUBDIR="nouveau"
-AC_SUBST(NOUVEAU_SUBDIR)
-fi
+AM_CONDITIONAL(HAVE_NOUVEAU, [text "x$NOUVEAU" = xyes])
PKG_CHECK_MODULES(CAIRO, cairo, [HAVE_CAIRO=yes], [HAVE_CAIRO=no])
if test "x$HAVE_CAIRO" = xyes; then
diff --git a/libdrm/Makefile.am b/libdrm/Makefile.am
index 76145bc..4c066e0 100644
--- a/libdrm/Makefile.am
+++ b/libdrm/Makefile.am
@@ -18,7 +18,11 @@
# 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.
-SUBDIRS = . intel @NOUVEAU_SUBDIR@
+if HAVE_NOUVEAU
+NOUVEAU_SUBDIR = nouveau
+endif
+
+SUBDIRS = . intel $(NOUVEAU_SUBDIR)
libdrm_la_LTLIBRARIES = libdrm.la
libdrm_ladir = $(libdir)
commit 2f1cdf79a7b7679f2602f27f18a0737f6e40e490
Author: Eric Anholt <eric@anholt.net>
Date: Sat Feb 21 09:57:19 2009 -0800
Bump version to 2.4.5 for new API additions.
diff --git a/configure.ac b/configure.ac
index dbead72..041374b 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.4, [dri-devel@lists.sourceforge.net], libdrm)
+AC_INIT([libdrm], 2.4.5, [dri-devel@lists.sourceforge.net], libdrm)
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([dist-bzip2])
commit 72abe983adfe7e8dcdcec11f1bc11d0b3daae063
Author: Eric Anholt <eric@anholt.net>
Date: Wed Feb 18 13:06:35 2009 -0800
intel: Add a new bufmgr alloc function to get BOs ready for rendering to.
This avoids using the oldest BO in the BO cache and waiting for it to be
idle before we turn around and render to it with the GPU. Thanks to
Chris Wilson for pointing out how silly we were being.
diff --git a/libdrm/intel/intel_bufmgr.c b/libdrm/intel/intel_bufmgr.c
index 188eac2..25a6828 100644
--- a/libdrm/intel/intel_bufmgr.c
+++ b/libdrm/intel/intel_bufmgr.c
@@ -51,6 +51,13 @@ drm_intel_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name,
return bufmgr->bo_alloc(bufmgr, name, size, alignment);
}
+drm_intel_bo *
+drm_intel_bo_alloc_for_render(drm_intel_bufmgr *bufmgr, const char *name,
+ unsigned long size, unsigned int alignment)
+{
+ return bufmgr->bo_alloc_for_render(bufmgr, name, size, alignment);
+}
+
void
drm_intel_bo_reference(drm_intel_bo *bo)
{
diff --git a/libdrm/intel/intel_bufmgr.h b/libdrm/intel/intel_bufmgr.h
index e8c2e06..111d2af 100644
--- a/libdrm/intel/intel_bufmgr.h
+++ b/libdrm/intel/intel_bufmgr.h
@@ -75,6 +75,10 @@ struct _drm_intel_bo {
drm_intel_bo *drm_intel_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name,
unsigned long size, unsigned int alignment);
+drm_intel_bo *drm_intel_bo_alloc_for_render(drm_intel_bufmgr *bufmgr,
+ const char *name,
+ unsigned long size,
+ unsigned int alignment);
void drm_intel_bo_reference(drm_intel_bo *bo);
void drm_intel_bo_unreference(drm_intel_bo *bo);
int drm_intel_bo_map(drm_intel_bo *bo, int write_enable);
diff --git a/libdrm/intel/intel_bufmgr_fake.c b/libdrm/intel/intel_bufmgr_fake.c
index 6c21625..e7cec35 100644
--- a/libdrm/intel/intel_bufmgr_fake.c
+++ b/libdrm/intel/intel_bufmgr_fake.c
@@ -1503,6 +1503,7 @@ drm_intel_bufmgr_fake_init(int fd,
/* Hook in methods */
bufmgr_fake->bufmgr.bo_alloc = drm_intel_fake_bo_alloc;
+ bufmgr_fake->bufmgr.bo_alloc_for_render = drm_intel_fake_bo_alloc;
bufmgr_fake->bufmgr.bo_reference = drm_intel_fake_bo_reference;
bufmgr_fake->bufmgr.bo_unreference = drm_intel_fake_bo_unreference;
bufmgr_fake->bufmgr.bo_map = drm_intel_fake_bo_map;
diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c
index 51641b7..6ddecf4 100644
--- a/libdrm/intel/intel_bufmgr_gem.c
+++ b/libdrm/intel/intel_bufmgr_gem.c
@@ -52,6 +52,7 @@
#include <sys/types.h>
#include "errno.h"
+#include "libdrm_lists.h"
#include "intel_bufmgr.h"
#include "intel_bufmgr_priv.h"
#include "intel_chipset.h"
@@ -67,7 +68,8 @@
typedef struct _drm_intel_bo_gem drm_intel_bo_gem;
struct drm_intel_gem_bo_bucket {
- drm_intel_bo_gem *head, **tail;
+ drmMMListHead head;
+
/**
* Limit on the number of entries in this bucket.
*
@@ -145,8 +147,8 @@ struct _drm_intel_bo_gem {
/** Mapped address for the buffer, saved across map/unmap cycles */
void *virtual;
- /** free list */
- drm_intel_bo_gem *next;
+ /** BO cache list */
+ drmMMListHead head;
/**
* Boolean of whether this BO and its children have been included in
@@ -323,8 +325,9 @@ drm_intel_setup_reloc_list(drm_intel_bo *bo)
}
static drm_intel_bo *
-drm_intel_gem_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name,
- unsigned long size, unsigned int alignment)
+drm_intel_gem_bo_alloc_internal(drm_intel_bufmgr *bufmgr, const char *name,
+ unsigned long size, unsigned int alignment,
+ int for_render)
{
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bufmgr;
drm_intel_bo_gem *bo_gem;
@@ -353,19 +356,35 @@ drm_intel_gem_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name,
/* Get a buffer out of the cache if available */
if (bucket != NULL && bucket->num_entries > 0) {
struct drm_i915_gem_busy busy;
-
- bo_gem = bucket->head;
- memset(&busy, 0, sizeof(busy));
- busy.handle = bo_gem->gem_handle;
-
- ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_BUSY, &busy);
- alloc_from_cache = (ret == 0 && busy.busy == 0);
-
- if (alloc_from_cache) {
- bucket->head = bo_gem->next;
- if (bo_gem->next == NULL)
- bucket->tail = &bucket->head;
+
+ if (for_render) {
+ /* Allocate new render-target BOs from the tail (MRU)
+ * of the list, as it will likely be hot in the GPU cache
+ * and in the aperture for us.
+ */
+ bo_gem = DRMLISTENTRY(drm_intel_bo_gem, bucket->head.prev, head);
+ DRMLISTDEL(&bo_gem->head);
bucket->num_entries--;
+ alloc_from_cache = 1;
+ } else {
+ /* For non-render-target BOs (where we're probably going to map it
+ * first thing in order to fill it with data), check if the
+ * last BO in the cache is unbusy, and only reuse in that case.
+ * Otherwise, allocating a new buffer is probably faster than
+ * waiting for the GPU to finish.
+ */
+ bo_gem = DRMLISTENTRY(drm_intel_bo_gem, bucket->head.next, head);
+
+ memset(&busy, 0, sizeof(busy));
+ busy.handle = bo_gem->gem_handle;
+
+ ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_BUSY, &busy);
+ alloc_from_cache = (ret == 0 && busy.busy == 0);
+
+ if (alloc_from_cache) {
+ DRMLISTDEL(&bo_gem->head);
+ bucket->num_entries--;
+ }
}
}
pthread_mutex_unlock(&bufmgr_gem->lock);
@@ -406,6 +425,20 @@ drm_intel_gem_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name,
return &bo_gem->bo;
}
+static drm_intel_bo *
+drm_intel_gem_bo_alloc_for_render(drm_intel_bufmgr *bufmgr, const char *name,
+ unsigned long size, unsigned int alignment)
+{
+ return drm_intel_gem_bo_alloc_internal(bufmgr, name, size, alignment, 1);
+}
+
+static drm_intel_bo *
+drm_intel_gem_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name,
+ unsigned long size, unsigned int alignment)
+{
+ return drm_intel_gem_bo_alloc_internal(bufmgr, name, size, alignment, 0);
+}
+
/**
* Returns a drm_intel_bo wrapping the given buffer object handle.
*
@@ -545,9 +578,7 @@ drm_intel_gem_bo_unreference_locked(drm_intel_bo *bo)
bo_gem->reloc_target_bo = NULL;
bo_gem->reloc_count = 0;
- bo_gem->next = NULL;
- *bucket->tail = bo_gem;
- bucket->tail = &bo_gem->next;
+ DRMLISTADDTAIL(&bo_gem->head, &bucket->head);
bucket->num_entries++;
} else {
drm_intel_gem_bo_free(bo);
@@ -827,10 +858,9 @@ drm_intel_bufmgr_gem_destroy(drm_intel_bufmgr *bufmgr)
struct drm_intel_gem_bo_bucket *bucket = &bufmgr_gem->cache_bucket[i];
drm_intel_bo_gem *bo_gem;
- while ((bo_gem = bucket->head) != NULL) {
- bucket->head = bo_gem->next;
- if (bo_gem->next == NULL)
- bucket->tail = &bucket->head;
+ while (!DRMLISTEMPTY(&bucket->head)) {
+ bo_gem = DRMLISTENTRY(drm_intel_bo_gem, bucket->head.next, head);
+ DRMLISTDEL(&bo_gem->head);
bucket->num_entries--;
drm_intel_gem_bo_free(&bo_gem->bo);
@@ -1348,6 +1378,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
bufmgr_gem->max_relocs = batch_size / sizeof(uint32_t) / 2 - 2;
bufmgr_gem->bufmgr.bo_alloc = drm_intel_gem_bo_alloc;
+ bufmgr_gem->bufmgr.bo_alloc_for_render = drm_intel_gem_bo_alloc_for_render;
bufmgr_gem->bufmgr.bo_reference = drm_intel_gem_bo_reference;
bufmgr_gem->bufmgr.bo_unreference = drm_intel_gem_bo_unreference;
bufmgr_gem->bufmgr.bo_map = drm_intel_gem_bo_map;
@@ -1367,7 +1398,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
bufmgr_gem->bufmgr.check_aperture_space = drm_intel_gem_check_aperture_space;
/* Initialize the linked lists for BO reuse cache. */
for (i = 0; i < DRM_INTEL_GEM_BO_BUCKETS; i++)
- bufmgr_gem->cache_bucket[i].tail = &bufmgr_gem->cache_bucket[i].head;
+ DRMINITLISTHEAD(&bufmgr_gem->cache_bucket[i].head);
return &bufmgr_gem->bufmgr;
}
diff --git a/libdrm/intel/intel_bufmgr_priv.h b/libdrm/intel/intel_bufmgr_priv.h
index 76d31e4..82d87b4 100644
--- a/libdrm/intel/intel_bufmgr_priv.h
+++ b/libdrm/intel/intel_bufmgr_priv.h
@@ -51,6 +51,16 @@ struct _drm_intel_bufmgr {
drm_intel_bo *(*bo_alloc)(drm_intel_bufmgr *bufmgr, const char *name,
unsigned long size, unsigned int alignment);
+ /**
+ * Allocate a buffer object, hinting that it will be used as a render target.
+ *
+ * This is otherwise the same as bo_alloc.
+ */
+ drm_intel_bo *(*bo_alloc_for_render)(drm_intel_bufmgr *bufmgr,
+ const char *name,
+ unsigned long size,
+ unsigned int alignment);
+
/** Takes a reference on a buffer object */
void (*bo_reference)(drm_intel_bo *bo);
diff --git a/libdrm/libdrm_lists.h b/libdrm/libdrm_lists.h
index 8e23991..6410f57 100644
--- a/libdrm/libdrm_lists.h
+++ b/libdrm/libdrm_lists.h
@@ -29,6 +29,8 @@
* list handling. No list looping yet.
*/
+#include <stddef.h>
+
typedef struct _drmMMListHead
{
struct _drmMMListHead *prev;
commit a1345338feb7af25c0a9fe02ec16c2b9cce83a9e
Author: Ben Skeggs <bskeggs@redhat.com>
Date: Fri Feb 20 09:25:35 2009 +1000
libdrm/nouveau: free drmVersion after we're done with it
diff --git a/libdrm/nouveau/nouveau_device.c b/libdrm/nouveau/nouveau_device.c
index 9d73039..b5ac854 100644
--- a/libdrm/nouveau/nouveau_device.c
+++ b/libdrm/nouveau/nouveau_device.c
@@ -45,6 +45,7 @@ nouveau_device_open_existing(struct nouveau_device **dev, int close,
ver = drmGetVersion(fd);
if (!ver || ver->version_patchlevel != NOUVEAU_DRM_HEADER_PATCHLEVEL)
return -EINVAL;
+ drmFreeVersion(ver);
nvdev = calloc(1, sizeof(*nvdev));
if (!nvdev)
commit 18f2fcf5aa299fe3b7b56af37e7eefe78c921f61
Author: Ben Skeggs <bskeggs@redhat.com>
Date: Thu Feb 19 19:40:19 2009 +1000
libdrm/nouveau: fix dma debugging
diff --git a/libdrm/nouveau/nouveau_dma.c b/libdrm/nouveau/nouveau_dma.c
index c906799..23da64b 100644
--- a/libdrm/nouveau/nouveau_dma.c
+++ b/libdrm/nouveau/nouveau_dma.c
@@ -21,6 +21,7 @@
*/
#include <stdint.h>
+#include <stdio.h>
#include <assert.h>
#include <errno.h>
commit 6a31b445fa494b992d5ddb115dd022058b787fc2
Author: Pekka Paalanen <pq@iki.fi>
Date: Wed Feb 18 22:46:40 2009 +0200
nouveau: support backlight only when kernel does
Loading nouveau.ko would fail with unknown symbols, if the backlight
class device support is not provided in the kernel. Let's make the
backlight support dependant on the kernel configuration.
This is a bit ugly, the proper way would be to check for the config in
Makefile.kernel whether to build nouveau_backlight.o at all, and if not,
nouveau_drv.h should provide the stubs.
Signed-off-by: Pekka Paalanen <pq@iki.fi>
diff --git a/linux-core/nouveau_backlight.c b/linux-core/nouveau_backlight.c
index 32bb3e5..51c747a 100644
--- a/linux-core/nouveau_backlight.c
+++ b/linux-core/nouveau_backlight.c
@@ -37,6 +37,8 @@
#include "nouveau_drm.h"
#include "nouveau_reg.h"
+#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
+
static int nv40_get_intensity(struct backlight_device *bd)
{
struct drm_device *dev = bl_get_data(bd);
@@ -157,4 +159,17 @@ void nouveau_backlight_exit(struct drm_device *dev)
if (dev_priv->backlight)
backlight_device_unregister(dev_priv->backlight);
-}
+}
+
+#else /* CONFIG_BACKLIGHT_CLASS_DEVICE not set */
+int nouveau_backlight_init(struct drm_device *dev)
+{
+ (void)dev;
+ return 0;
+}
+
+void nouveau_backlight_exit(struct drm_device *dev)
+{
+ (void)dev;
+}
+#endif /* CONFIG_BACKLIGHT_CLASS_DEVICE not set */
commit 25c60cfeca16f2bce38dbf32a57f1edc04c23a19
Author: Matthew Garrett <mjg59@srcf.ucam.org>
Date: Wed Feb 18 13:21:26 2009 +0000
nv40, nv50: fix backlight build for <2.6.29 kernels
Signed-off-by: Matthew Garrett <mjg59@srcf.ucam.org>
Signed-off-by: Pekka Paalanen <pq@iki.fi>
diff --git a/linux-core/nouveau_backlight.c b/linux-core/nouveau_backlight.c
index dc75c44..32bb3e5 100644
--- a/linux-core/nouveau_backlight.c
+++ b/linux-core/nouveau_backlight.c
@@ -60,7 +60,9 @@ static int nv40_set_intensity(struct backlight_device *bd)
}
static struct backlight_ops nv40_bl_ops = {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
.options = BL_CORE_SUSPENDRESUME,
+#endif
.get_brightness = nv40_get_intensity,
.update_status = nv40_set_intensity,
};
@@ -85,7 +87,9 @@ static int nv50_set_intensity(struct backlight_device *bd)
}
static struct backlight_ops nv50_bl_ops = {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
.options = BL_CORE_SUSPENDRESUME,
+#endif
.get_brightness = nv50_get_intensity,
.update_status = nv50_set_intensity,
};
commit 96ce587e8b915afeac38e5f547ba95803c1780f2
Author: Matthew Garrett <mjg59@srcf.ucam.org>
Date: Wed Feb 18 02:08:25 2009 +0000
nouveau: Add in-kernel backlight control support
Several nvidia-based systems don't support backlight control via the
standard ACPI control mechanisms. Instead, it's necessary for the driver
to modify the backlight control registers directly. This patch adds
support for determining whether the registers appear to be in use, and
if so registers a kernel backlight device to control them. The backlight
can then be controlled via existing userspace tools.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
diff --git a/linux-core/Makefile.kernel b/linux-core/Makefile.kernel
index 1e03347..0bea35d 100644
--- a/linux-core/Makefile.kernel
+++ b/linux-core/Makefile.kernel
@@ -22,6 +22,7 @@ i810-objs := i810_drv.o i810_dma.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 \
+ nouveau_backlight.o \
nv04_timer.o \
nv04_mc.o nv40_mc.o nv50_mc.o \
nv04_fb.o nv10_fb.o nv40_fb.o \
diff --git a/linux-core/nouveau_backlight.c b/linux-core/nouveau_backlight.c
new file mode 100644
index 0000000..dc75c44
--- /dev/null
+++ b/linux-core/nouveau_backlight.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2009 Red Hat <mjg@redhat.com>
+ *
+ * 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 THE COPYRIGHT OWNER(S) 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:
+ * Matthew Garrett <mjg@redhat.com>
+ *
+ * Register locations derived from NVClock by Roderick Colenbrander
+ */
+
+#include <linux/backlight.h>
+
+#include "drmP.h"
+#include "nouveau_drv.h"
+#include "nouveau_drm.h"
+#include "nouveau_reg.h"
+
+static int nv40_get_intensity(struct backlight_device *bd)
+{
+ struct drm_device *dev = bl_get_data(bd);
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ int val = (NV_READ(NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK) >> 16;
+
+ return val;
+}
+
+static int nv40_set_intensity(struct backlight_device *bd)
+{
+ struct drm_device *dev = bl_get_data(bd);
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ int val = bd->props.brightness;
+ int reg = NV_READ(NV40_PMC_BACKLIGHT);
+
+ NV_WRITE(NV40_PMC_BACKLIGHT,
+ (val << 16) | (reg & ~NV40_PMC_BACKLIGHT_MASK));
+
+ return 0;
+}
+
+static struct backlight_ops nv40_bl_ops = {
+ .options = BL_CORE_SUSPENDRESUME,
+ .get_brightness = nv40_get_intensity,
+ .update_status = nv40_set_intensity,
+};
+
+static int nv50_get_intensity(struct backlight_device *bd)
+{
+ struct drm_device *dev = bl_get_data(bd);
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+
+ return NV_READ(NV50_PDISPLAY_BACKLIGHT);
+}
+
+static int nv50_set_intensity(struct backlight_device *bd)
+{
+ struct drm_device *dev = bl_get_data(bd);
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ int val = bd->props.brightness;
+
+ NV_WRITE(NV50_PDISPLAY_BACKLIGHT, val | NV50_PDISPLAY_BACKLIGHT_ENABLE);
+
+ return 0;
+}
+
+static struct backlight_ops nv50_bl_ops = {
+ .options = BL_CORE_SUSPENDRESUME,
+ .get_brightness = nv50_get_intensity,
+ .update_status = nv50_set_intensity,
+};
+
+static int nouveau_nv40_backlight_init(struct drm_device *dev)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct backlight_device *bd;
+
+ if (!(NV_READ(NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK))
+ return 0;
+
+ bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev,
+ &nv40_bl_ops);
+ if (IS_ERR(bd))
+ return PTR_ERR(bd);
+
+ dev_priv->backlight = bd;
+ bd->props.max_brightness = 31;
+ bd->props.brightness = nv40_get_intensity(bd);
+ backlight_update_status(bd);
+
+ return 0;
+}
+
+static int nouveau_nv50_backlight_init(struct drm_device *dev)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct backlight_device *bd;
+
+ if (!NV_READ(NV50_PDISPLAY_BACKLIGHT))
+ return 0;
+
+ bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev,
+ &nv50_bl_ops);
+ if (IS_ERR(bd))
+ return PTR_ERR(bd);
+
+ dev_priv->backlight = bd;
+ bd->props.max_brightness = 1025;
+ bd->props.brightness = nv50_get_intensity(bd);
+ backlight_update_status(bd);
+ return 0;
+}
+
+int nouveau_backlight_init(struct drm_device *dev)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+
+ switch (dev_priv->card_type) {
+ case NV_40:
+ case NV_44:
+ return nouveau_nv40_backlight_init(dev);
+ break;
+ case NV_50:
+ return nouveau_nv50_backlight_init(dev);
+ break;
+ }
+ return 0;
+}
+
+void nouveau_backlight_exit(struct drm_device *dev)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+
+ if (dev_priv->backlight)
+ backlight_device_unregister(dev_priv->backlight);
+}
diff --git a/shared-core/nouveau_drv.h b/shared-core/nouveau_drv.h
index 158d6fd..1cd10bf 100644
--- a/shared-core/nouveau_drv.h
+++ b/shared-core/nouveau_drv.h
@@ -318,6 +318,7 @@ struct drm_nouveau_private {
uint32_t *ramin_copy;
uint64_t ramin_size;
} susres;
+ struct backlight_device *backlight;
};
#define NOUVEAU_CHECK_INITIALISED_WITH_RETURN do { \
@@ -468,6 +469,10 @@ extern int nouveau_dma_channel_init(struct drm_device *);
extern void nouveau_dma_channel_takedown(struct drm_device *);
extern int nouveau_dma_wait(struct drm_device *, int size);
+/* nouveau_backlight.c */
+extern int nouveau_backlight_init(struct drm_device *);
+extern void nouveau_backlight_exit(struct drm_device *);
+
/* nv04_fb.c */
extern int nv04_fb_init(struct drm_device *);
extern void nv04_fb_takedown(struct drm_device *);
diff --git a/shared-core/nouveau_reg.h b/shared-core/nouveau_reg.h
index 1ae0177..060abe0 100644
--- a/shared-core/nouveau_reg.h
+++ b/shared-core/nouveau_reg.h
@@ -99,6 +99,8 @@
* the card will hang early on in the X init process.
*/
# define NV_PMC_ENABLE_UNK13 (1<<13)
+#define NV40_PMC_BACKLIGHT 0x000015f0
+# define NV40_PMC_BACKLIGHT_MASK 0x001f0000
#define NV40_PMC_1700 0x00001700
#define NV40_PMC_1704 0x00001704
#define NV40_PMC_1708 0x00001708
@@ -542,6 +544,9 @@
/* This name is a partial guess. */
#define NV50_DISPLAY_SUPERVISOR 0x00610024
+#define NV50_PDISPLAY_BACKLIGHT 0x0061c084
+# define NV50_PDISPLAY_BACKLIGHT_ENABLE 0x80000000
+
/* Fifo commands. These are not regs, neither masks */
#define NV03_FIFO_CMD_JUMP 0x20000000
#define NV03_FIFO_CMD_JUMP_OFFSET_MASK 0x1ffffffc
@@ -591,3 +596,4 @@
#define NV40_RAMFC_UNK_48 0x48
#define NV40_RAMFC_UNK_4C 0x4C
#define NV40_RAMFC_UNK_50 0x50
+
diff --git a/shared-core/nouveau_state.c b/shared-core/nouveau_state.c
index 0b6002c..c9f4329 100644
--- a/shared-core/nouveau_state.c
+++ b/shared-core/nouveau_state.c
@@ -363,6 +363,11 @@ nouveau_card_init(struct drm_device *dev)
ret = nouveau_dma_channel_init(dev);
if (ret) return ret;
+ ret = nouveau_backlight_init(dev);
+ if (ret)
+ DRM_ERROR("Error code %d when trying to register backlight\n",
+ ret);
+
dev_priv->init_state = NOUVEAU_CARD_INIT_DONE;
return 0;
}
@@ -375,6 +380,8 @@ static void nouveau_card_takedown(struct drm_device *dev)
DRM_DEBUG("prev state = %d\n", dev_priv->init_state);
if (dev_priv->init_state != NOUVEAU_CARD_INIT_DOWN) {
+ nouveau_backlight_exit(dev);
+
nouveau_dma_channel_takedown(dev);
engine->fifo.takedown(dev);
commit 0054e14793e585ec0d8e95e3d7b82cbf1a684af8
Author: Pekka Paalanen <pq@iki.fi>
Date: Sat Feb 14 22:22:39 2009 +0200
drm_compat: remove kmap_atomic_prot_pfn()
Reply to: