libdrm: Changes to 'upstream-experimental'
configure.ac | 5
include/drm/i915_drm.h | 14 ++
intel/intel_bufmgr.c | 8 +
intel/intel_bufmgr.h | 2
intel/intel_bufmgr_gem.c | 51 +++++++--
intel/intel_bufmgr_priv.h | 4
libkms/Makefile.am | 4
libkms/internal.h | 2
libkms/linux.c | 4
libkms/radeon.c | 242 ++++++++++++++++++++++++++++++++++++++++++++
nouveau/Makefile.am | 2
nouveau/nouveau_channel.c | 37 +++---
nouveau/nouveau_grobj.c | 11 +-
nouveau/nouveau_pushbuf.h | 38 ------
nouveau/nouveau_reloc.c | 34 ++++--
nouveau/nv04_pushbuf.h | 66 ++++++++++++
nouveau/nvc0_pushbuf.h | 92 ++++++++++++++++
tests/modeprint/Makefile.am | 4
tests/modeprint/modeprint.c | 4
tests/modetest/Makefile.am | 4
tests/modetest/modetest.c | 137 ++++++++++++++----------
21 files changed, 623 insertions(+), 142 deletions(-)
New commits:
commit a926a043b8079a8e283aa231e3c2347f5ad5864f
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Tue Mar 1 18:24:14 2011 +0000
configure: Bump version to 2.4.24
New kernel headers.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
diff --git a/configure.ac b/configure.ac
index 23ccedf..1998204 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.60)
-AC_INIT([libdrm], 2.4.23, [dri-devel@lists.sourceforge.net], libdrm)
+AC_INIT([libdrm], 2.4.24, [dri-devel@lists.sourceforge.net], libdrm)
AC_USE_SYSTEM_EXTENSIONS
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([dist-bzip2])
commit 0209428b3918c4336018da9293cdcbf7f8fedfb6
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Tue Mar 1 16:01:53 2011 +0000
intel: Add I915_PARAM_HAS_RELAXED_DELTA
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index 98e1597..adc2392 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -281,6 +281,7 @@ typedef struct drm_i915_irq_wait {
#define I915_PARAM_HAS_RELAXED_FENCING 12
#define I915_PARAM_HAS_COHERENT_RINGS 13
#define I915_PARAM_HAS_EXEC_CONSTANTS 14
+#define I915_PARAM_HAS_RELAXED_DELTA 15
typedef struct drm_i915_getparam {
int param;
commit e6018c25ca63fa6066d8fa6e57373030d07b0392
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date: Tue Feb 22 19:11:07 2011 +0100
intel: Fixup for the fix for relaxed tiling on gen2
This is Fail.
First patch to libdrm, and I've borked it up.
Noticed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 9b324d9..f5ab0a6 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -767,7 +767,7 @@ drm_intel_gem_bo_alloc_tiled(drm_intel_bufmgr *bufmgr, const char *name,
else if (tiling == I915_TILING_Y)
height_alignment = 32;
/* i8xx has a interleaved 2-row tile layout */
- if (IS_GEN2(bufmgr_gem))
+ if (IS_GEN2(bufmgr_gem) && tiling != I915_TILING_NONE)
height_alignment *= 2;
aligned_y = ALIGN(y, height_alignment);
commit 9a71ed93f48f4b319148913a6b56751f6341f078
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date: Tue Feb 22 18:53:56 2011 +0100
intel: fix relaxed tiling on gen2
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 3cdffce..9b324d9 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -744,7 +744,7 @@ drm_intel_gem_bo_alloc_tiled(drm_intel_bufmgr *bufmgr, const char *name,
uint32_t tiling;
do {
- unsigned long aligned_y;
+ unsigned long aligned_y, height_alignment;
tiling = *tiling_mode;
@@ -760,12 +760,16 @@ drm_intel_gem_bo_alloc_tiled(drm_intel_bufmgr *bufmgr, const char *name,
* too so we try to be careful.
*/
aligned_y = y;
- if (tiling == I915_TILING_NONE)
- aligned_y = ALIGN(y, 2);
- else if (tiling == I915_TILING_X)
- aligned_y = ALIGN(y, 8);
+ height_alignment = 2;
+
+ if (tiling == I915_TILING_X)
+ height_alignment = 8;
else if (tiling == I915_TILING_Y)
- aligned_y = ALIGN(y, 32);
+ height_alignment = 32;
+ /* i8xx has a interleaved 2-row tile layout */
+ if (IS_GEN2(bufmgr_gem))
+ height_alignment *= 2;
+ aligned_y = ALIGN(y, height_alignment);
stride = x * cpp;
stride = drm_intel_gem_bo_tile_pitch(bufmgr_gem, stride, tiling_mode);
commit a697fb6acad7992c3d23bb6a663663694782eb7b
Author: Benjamin Franzke <benjaminfranzke@googlemail.com>
Date: Thu Feb 17 20:36:42 2011 +0100
modetest: Do no flip twice to a current front buffer
The incorrect order was:
fb, other_fb, other_fb, fb_id, other_fb, ..
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 6a40820..bd0f0a0 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -614,7 +614,7 @@ set_mode(struct connector *c, int count, int page_flip)
c[i].swap_count = 0;
c[i].fb_id[0] = fb_id;
c[i].fb_id[1] = other_fb_id;
- c[i].current_fb_id = fb_id;
+ c[i].current_fb_id = other_fb_id;
}
memset(&evctx, 0, sizeof evctx);
commit 51c6ae4c3a0e5527d3c6e1632b21546baaba0b29
Author: Benjamin Franzke <benjaminfranzke@googlemail.com>
Date: Thu Feb 17 14:09:12 2011 +0100
tests/modeprint: Output masks as hex numbers
diff --git a/tests/modeprint/modeprint.c b/tests/modeprint/modeprint.c
index 4c612f4..09b8df0 100644
--- a/tests/modeprint/modeprint.c
+++ b/tests/modeprint/modeprint.c
@@ -193,8 +193,8 @@ int printEncoder(int fd, drmModeResPtr res, drmModeEncoderPtr encoder, uint32_t
printf("\tid :%i\n", id);
printf("\tcrtc_id :%d\n", encoder->crtc_id);
printf("\ttype :%d\n", encoder->encoder_type);
- printf("\tpossible_crtcs :%d\n", encoder->possible_crtcs);
- printf("\tpossible_clones :%d\n", encoder->possible_clones);
+ printf("\tpossible_crtcs :0x%x\n", encoder->possible_crtcs);
+ printf("\tpossible_clones :0x%x\n", encoder->possible_clones);
return 0;
}
commit 17762467850618323f59e91702e3fc0749fbceac
Author: Benjamin Franzke <benjaminfranzke@googlemail.com>
Date: Thu Feb 17 14:07:58 2011 +0100
tests/modeprint: Remove needless dependency on drm_intel
diff --git a/tests/modeprint/Makefile.am b/tests/modeprint/Makefile.am
index 2ae0fdc..c4862ac 100644
--- a/tests/modeprint/Makefile.am
+++ b/tests/modeprint/Makefile.am
@@ -1,6 +1,5 @@
AM_CFLAGS = \
-I$(top_srcdir)/include/drm \
- -I$(top_srcdir)/intel/ \
-I$(top_srcdir)
noinst_PROGRAMS = \
@@ -9,5 +8,4 @@ noinst_PROGRAMS = \
modeprint_SOURCES = \
modeprint.c
modeprint_LDADD = \
- $(top_builddir)/libdrm.la \
- $(top_builddir)/intel/libdrm_intel.la
+ $(top_builddir)/libdrm.la
commit 8fef29093fae2a08f8c1cb4946687bf4bb62a1ca
Author: Benjamin Franzke <benjaminfranzke@googlemail.com>
Date: Thu Feb 17 10:47:47 2011 +0100
modetest: Create buffers using libkms
diff --git a/tests/modetest/Makefile.am b/tests/modetest/Makefile.am
index 16f5e99..2191242 100644
--- a/tests/modetest/Makefile.am
+++ b/tests/modetest/Makefile.am
@@ -1,6 +1,6 @@
AM_CFLAGS = \
-I$(top_srcdir)/include/drm \
- -I$(top_srcdir)/intel/ \
+ -I$(top_srcdir)/libkms/ \
-I$(top_srcdir) \
$(CAIRO_CFLAGS)
@@ -11,5 +11,5 @@ modetest_SOURCES = \
modetest.c
modetest_LDADD = \
$(top_builddir)/libdrm.la \
- $(top_builddir)/intel/libdrm_intel.la \
+ $(top_builddir)/libkms/libkms.la \
$(CAIRO_LIBS)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index f3a04d0..6a40820 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -51,8 +51,7 @@
#include "xf86drm.h"
#include "xf86drmMode.h"
-#include "intel_bufmgr.h"
-#include "i915_drm.h"
+#include "libkms.h"
#ifdef HAVE_CAIRO
#include <math.h>
@@ -354,29 +353,49 @@ connector_find_mode(struct connector *c)
c->crtc = c->encoder->crtc_id;
}
-static drm_intel_bo *
-allocate_buffer(drm_intel_bufmgr *bufmgr,
+static struct kms_bo *
+allocate_buffer(struct kms_driver *kms,
int width, int height, int *stride)
{
- int size;
+ struct kms_bo *bo;
+ unsigned bo_attribs[] = {
+ KMS_WIDTH, 0,
+ KMS_HEIGHT, 0,
+ KMS_BO_TYPE, KMS_BO_TYPE_SCANOUT_X8R8G8B8,
+ KMS_TERMINATE_PROP_LIST
+ };
+ int ret;
+
+ bo_attribs[1] = width;
+ bo_attribs[3] = height;
+
+ ret = kms_bo_create(kms, bo_attribs, &bo);
+ if (ret) {
+ fprintf(stderr, "failed to alloc buffer: %s\n",
+ strerror(-ret));
+ return NULL;
+ }
- /* Scan-out has a 64 byte alignment restriction */
- size = (width + 63) & -64;
- *stride = size;
- size *= height;
+ ret = kms_bo_get_prop(bo, KMS_PITCH, stride);
+ if (ret) {
+ fprintf(stderr, "failed to retreive buffer stride: %s\n",
+ strerror(-ret));
+ kms_bo_destroy(&bo);
+ return NULL;
+ }
- return drm_intel_bo_alloc(bufmgr, "frontbuffer", size, 0);
+ return bo;
}
static void
-make_pwetty(drm_intel_bo *bo, int width, int height, int stride)
+make_pwetty(void *data, int width, int height, int stride)
{
#ifdef HAVE_CAIRO
cairo_surface_t *surface;
cairo_t *cr;
int x, y;
- surface = cairo_image_surface_create_for_data(bo->virtual,
+ surface = cairo_image_surface_create_for_data(data,
CAIRO_FORMAT_ARGB32,
width, height,
stride);
@@ -415,29 +434,29 @@ make_pwetty(drm_intel_bo *bo, int width, int height, int stride)
}
static int
-create_test_buffer(drm_intel_bufmgr *bufmgr,
- int width, int height, int *stride_out, drm_intel_bo **bo_out)
+create_test_buffer(struct kms_driver *kms,
+ int width, int height, int *stride_out,
+ struct kms_bo **bo_out)
{
- drm_intel_bo *bo;
+ struct kms_bo *bo;
int ret, i, j, stride;
+ void *virtual;
- bo = allocate_buffer(bufmgr, width, height, &stride);
- if (!bo) {
- fprintf(stderr, "failed to alloc buffer: %s\n",
- strerror(errno));
+ bo = allocate_buffer(kms, width, height, &stride);
+ if (!bo)
return -1;
- }
- ret = drm_intel_gem_bo_map_gtt(bo);
+ ret = kms_bo_map(bo, &virtual);
if (ret) {
- fprintf(stderr, "failed to GTT map buffer: %s\n",
- strerror(errno));
+ fprintf(stderr, "failed to map buffer: %s\n",
+ strerror(-ret));
+ kms_bo_destroy(&bo);
return -1;
}
/* paint the buffer with colored tiles */
for (j = 0; j < height; j++) {
- uint32_t *fb_ptr = (uint32_t*)((char*)bo->virtual + j * stride);
+ uint32_t *fb_ptr = (uint32_t*)((char*)virtual + j * stride);
for (i = 0; i < width; i++) {
div_t d = div(i, width);
fb_ptr[i] =
@@ -446,9 +465,9 @@ create_test_buffer(drm_intel_bufmgr *bufmgr,
}
}
- make_pwetty(bo, width, height, stride);
+ make_pwetty(virtual, width, height, stride);
- drm_intel_gem_bo_unmap_gtt(bo);
+ kms_bo_unmap(bo);
*bo_out = bo;
*stride_out = stride;
@@ -456,32 +475,29 @@ create_test_buffer(drm_intel_bufmgr *bufmgr,
}
static int
-create_grey_buffer(drm_intel_bufmgr *bufmgr,
- int width, int height, int *stride_out, drm_intel_bo **bo_out)
+create_grey_buffer(struct kms_driver *kms,
+ int width, int height, int *stride_out,
+ struct kms_bo **bo_out)
{
- drm_intel_bo *bo;
+ struct kms_bo *bo;
int size, ret, stride;
+ void *virtual;
- /* Mode size at 32 bpp */
- stride = width * 4;
- size = stride * height;
-
- bo = drm_intel_bo_alloc(bufmgr, "frontbuffer", size, 4096);
- if (!bo) {
- fprintf(stderr, "failed to alloc buffer: %s\n",
- strerror(errno));
+ bo = allocate_buffer(kms, width, height, &stride);
+ if (!bo)
return -1;
- }
- ret = drm_intel_gem_bo_map_gtt(bo);
+ ret = kms_bo_map(bo, &virtual);
if (ret) {
- fprintf(stderr, "failed to GTT map buffer: %s\n",
- strerror(errno));
+ fprintf(stderr, "failed to map buffer: %s\n",
+ strerror(-ret));
+ kms_bo_destroy(&bo);
return -1;
}
- memset(bo->virtual, 0x77, size);
- drm_intel_gem_bo_unmap_gtt(bo);
+ size = stride * height;
+ memset(virtual, 0x77, size);
+ kms_bo_unmap(bo);
*bo_out = bo;
*stride_out = stride;
@@ -521,10 +537,11 @@ page_flip_handler(int fd, unsigned int frame,
static void
set_mode(struct connector *c, int count, int page_flip)
{
- drm_intel_bufmgr *bufmgr;
- drm_intel_bo *bo, *other_bo;
+ struct kms_driver *kms;
+ struct kms_bo *bo, *other_bo;
unsigned int fb_id, other_fb_id;
int i, ret, width, height, x, stride;
+ unsigned handle;
drmEventContext evctx;
width = 0;
@@ -538,17 +555,18 @@ set_mode(struct connector *c, int count, int page_flip)
height = c[i].mode->vdisplay;
}
- bufmgr = drm_intel_bufmgr_gem_init(fd, 2<<20);
- if (!bufmgr) {
- fprintf(stderr, "failed to init bufmgr: %s\n", strerror(errno));
+ ret = kms_create(fd, &kms);
+ if (ret) {
+ fprintf(stderr, "failed to create kms driver: %s\n",
+ strerror(-ret));
return;
}
- if (create_test_buffer(bufmgr, width, height, &stride, &bo))
+ if (create_test_buffer(kms, width, height, &stride, &bo))
return;
- ret = drmModeAddFB(fd, width, height, 32, 32, stride, bo->handle,
- &fb_id);
+ kms_bo_get_prop(bo, KMS_HANDLE, &handle);
+ ret = drmModeAddFB(fd, width, height, 32, 32, stride, handle, &fb_id);
if (ret) {
fprintf(stderr, "failed to add fb: %s\n", strerror(errno));
return;
@@ -574,11 +592,12 @@ set_mode(struct connector *c, int count, int page_flip)
if (!page_flip)
return;
-
- if (create_grey_buffer(bufmgr, width, height, &stride, &other_bo))
+
+ if (create_grey_buffer(kms, width, height, &stride, &other_bo))
return;
- ret = drmModeAddFB(fd, width, height, 32, 32, stride, other_bo->handle,
+ kms_bo_get_prop(other_bo, KMS_HANDLE, &handle);
+ ret = drmModeAddFB(fd, width, height, 32, 32, stride, handle,
&other_fb_id);
if (ret) {
fprintf(stderr, "failed to add fb: %s\n", strerror(errno));
@@ -640,6 +659,10 @@ set_mode(struct connector *c, int count, int page_flip)
drmHandleEvent(fd, &evctx);
}
+
+ kms_bo_destroy(&bo);
+ kms_bo_destroy(&other_bo);
+ kms_destroy(&kms);
}
extern char *optarg;
@@ -665,6 +688,9 @@ void usage(char *name)
static int page_flipping_supported(int fd)
{
+ /*FIXME: generic ioctl needed? */
+ return 1;
+#if 0
int ret, value;
struct drm_i915_getparam gp;
@@ -678,6 +704,7 @@ static int page_flipping_supported(int fd)
}
return *gp.value;
+#endif
}
int main(int argc, char **argv)
commit c75fe3ae738732afda3a7d4222bb3828ed9ef7a8
Author: Benjamin Franzke <benjaminfranzke@googlemail.com>
Date: Thu Feb 17 10:46:35 2011 +0100
configure.ac: ac_define HAVE_RADEON
diff --git a/configure.ac b/configure.ac
index b064665..23ccedf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -244,6 +244,9 @@ fi
AM_CONDITIONAL(HAVE_INTEL, [test "x$INTEL" != "xno"])
AM_CONDITIONAL(HAVE_RADEON, [test "x$RADEON" != "xno"])
+if test "x$RADEON" = xyes; then
+ AC_DEFINE(HAVE_RADEON, 1, [Have radeon support])
+fi
AC_ARG_WITH([kernel-source],
[AS_HELP_STRING([--with-kernel-source],
commit ed7d177f66885dfbc4e8410154559c4767fefa9f
Author: nobled <nobled@dreamwidth.org>
Date: Thu Sep 9 10:07:21 2010 +0100
libkms/radeon: Add backend
Todo: What tiling should be set on scanout buffers?
Haven't tested besides compiling it.
diff --git a/libkms/Makefile.am b/libkms/Makefile.am
index 2c75878..5c2e63f 100644
--- a/libkms/Makefile.am
+++ b/libkms/Makefile.am
@@ -26,6 +26,10 @@ if HAVE_NOUVEAU
libkms_la_SOURCES += nouveau.c
endif
+if HAVE_RADEON
+libkms_la_SOURCES += radeon.c
+endif
+
libkmsincludedir = ${includedir}/libkms
libkmsinclude_HEADERS = libkms.h
diff --git a/libkms/internal.h b/libkms/internal.h
index 63122d1..51f5e65 100644
--- a/libkms/internal.h
+++ b/libkms/internal.h
@@ -70,4 +70,6 @@ int intel_create(int fd, struct kms_driver **out);
int nouveau_create(int fd, struct kms_driver **out);
+int radeon_create(int fd, struct kms_driver **out);
+
#endif
diff --git a/libkms/linux.c b/libkms/linux.c
index 02182d3..7449abc 100644
--- a/libkms/linux.c
+++ b/libkms/linux.c
@@ -111,6 +111,10 @@ linux_from_sysfs(int fd, struct kms_driver **out)
else if (!strcmp(name, "nouveau"))
ret = nouveau_create(fd, out);
#endif
+#ifdef HAVE_RADEON
+ else if (!strcmp(name, "radeon"))
+ ret = radeon_create(fd, out);
+#endif
else
ret = -ENOSYS;
diff --git a/libkms/radeon.c b/libkms/radeon.c
new file mode 100644
index 0000000..f5e382a
--- /dev/null
+++ b/libkms/radeon.c
@@ -0,0 +1,242 @@
+/**************************************************************************
+ *
+ * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
+ * 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, sub license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS 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.
+ *
+ **************************************************************************/
+
+
+#define HAVE_STDINT_H
+#define _FILE_OFFSET_BITS 64
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "internal.h"
+
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include "xf86drm.h"
+
+#include "radeon_drm.h"
+
+
+#define ALIGNMENT 512
+
+struct radeon_bo
+{
+ struct kms_bo base;
+ unsigned map_count;
+};
+
+static int
+radeon_get_prop(struct kms_driver *kms, unsigned key, unsigned *out)
+{
+ switch (key) {
+ case KMS_BO_TYPE:
+ *out = KMS_BO_TYPE_SCANOUT_X8R8G8B8 | KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8;
+ break;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static int
+radeon_destroy(struct kms_driver *kms)
+{
+ free(kms);
+ return 0;
+}
+
+static int
+radeon_bo_create(struct kms_driver *kms,
+ const unsigned width, const unsigned height,
+ const enum kms_bo_type type, const unsigned *attr,
+ struct kms_bo **out)
+{
+ struct drm_radeon_gem_create arg;
+ unsigned size, pitch;
+ struct radeon_bo *bo;
+ int i, ret;
+
+ for (i = 0; attr[i]; i += 2) {
+ switch (attr[i]) {
+ case KMS_WIDTH:
+ case KMS_HEIGHT:
+ case KMS_BO_TYPE:
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ switch (type) {
+ case KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8:
+ pitch = 4 * 64;
+ size = 4 * 64 * 64;
+ break;
+ case KMS_BO_TYPE_SCANOUT_X8R8G8B8:
+ pitch = width * 4;
+ pitch = (pitch + ALIGNMENT - 1) & ~(ALIGNMENT - 1);
+ size = pitch * height;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ bo = calloc(1, sizeof(*bo));
+ if (!bo)
+ return -ENOMEM;
+
+ memset(&arg, 0, sizeof(arg));
+ arg.size = size;
+ arg.alignment = ALIGNMENT;
+ arg.initial_domain = RADEON_GEM_DOMAIN_CPU;
+ arg.flags = 0;
+ arg.handle = 0;
+
+ ret = drmCommandWriteRead(kms->fd, DRM_RADEON_GEM_CREATE,
+ &arg, sizeof(arg));
+ if (ret)
+ goto err_free;
+
+ bo->base.kms = kms;
+ bo->base.handle = arg.handle;
+ bo->base.size = size;
+ bo->base.pitch = pitch;
+ bo->base.offset = 0;
+ bo->map_count = 0;
+
+ *out = &bo->base;
+
+ return 0;
+
+err_free:
+ free(bo);
+ return ret;
+}
+
+static int
+radeon_bo_get_prop(struct kms_bo *bo, unsigned key, unsigned *out)
+{
+ switch (key) {
+ default:
+ return -EINVAL;
+ }
+}
+
+static int
+radeon_bo_map(struct kms_bo *_bo, void **out)
+{
+ struct radeon_bo *bo = (struct radeon_bo *)_bo;
+ struct drm_radeon_gem_mmap arg;
+ void *map = NULL;
+ int ret;
+
+ if (bo->base.ptr) {
+ bo->map_count++;
+ *out = bo->base.ptr;
+ return 0;
+ }
+
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = bo->base.handle;
+ arg.offset = bo->base.offset;
+ arg.size = (uint64_t)bo->base.size;
+
+ ret = drmCommandWriteRead(bo->base.kms->fd, DRM_RADEON_GEM_MMAP,
+ &arg, sizeof(arg));
+ if (ret)
+ return -errno;
+
+ map = mmap(0, arg.size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ bo->base.kms->fd, arg.addr_ptr);
+ if (map == MAP_FAILED)
+ return -errno;
+
+ bo->base.ptr = map;
+ bo->map_count++;
+ *out = bo->base.ptr;
+
+ return 0;
+}
+
+static int
+radeon_bo_unmap(struct kms_bo *_bo)
+{
+ struct radeon_bo *bo = (struct radeon_bo *)_bo;
+ if (--bo->map_count == 0) {
+ munmap(bo->base.ptr, bo->base.size);
+ bo->base.ptr = NULL;
+ }
+ return 0;
+}
+
+static int
+radeon_bo_destroy(struct kms_bo *_bo)
+{
+ struct radeon_bo *bo = (struct radeon_bo *)_bo;
+ struct drm_gem_close arg;
+ int ret;
+
+ if (bo->base.ptr) {
+ /* XXX Sanity check map_count */
+ munmap(bo->base.ptr, bo->base.size);
+ bo->base.ptr = NULL;
+ }
+
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = bo->base.handle;
+
+ ret = drmIoctl(bo->base.kms->fd, DRM_IOCTL_GEM_CLOSE, &arg);
+ if (ret)
+ return -errno;
+
+ free(bo);
+ return 0;
+}
+
+int
+radeon_create(int fd, struct kms_driver **out)
+{
+ struct kms_driver *kms;
+
+ kms = calloc(1, sizeof(*kms));
+ if (!kms)
+ return -ENOMEM;
+
+ kms->fd = fd;
+
+ kms->bo_create = radeon_bo_create;
+ kms->bo_map = radeon_bo_map;
+ kms->bo_unmap = radeon_bo_unmap;
+ kms->bo_get_prop = radeon_bo_get_prop;
+ kms->bo_destroy = radeon_bo_destroy;
+ kms->get_prop = radeon_get_prop;
+ kms->destroy = radeon_destroy;
+ *out = kms;
+
+ return 0;
+}
commit 36d4939343d8789d9066f7245fa2d4fe69119dd8
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Mon Feb 14 09:39:06 2011 +0000
intel: Remember named bo
... and if asked to open a bo by the same global name, return a fresh
reference to the previously allocated buffer.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 092b56a..3cdffce 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -95,6 +95,8 @@ typedef struct _drm_intel_bufmgr_gem {
int num_buckets;
time_t time;
+ drmMMListHead named;
+
uint64_t gtt_size;
int available_fences;
int pci_device;
@@ -124,6 +126,7 @@ struct _drm_intel_bo_gem {
* Kenel-assigned global name for this object
*/
unsigned int global_name;
+ drmMMListHead name_list;
/**
* Index of the buffer within the validation list while preparing a
@@ -690,6 +693,8 @@ retry:
drm_intel_gem_bo_free(&bo_gem->bo);
return NULL;
}
+
+ DRMINITLISTHEAD(&bo_gem->name_list);
}
bo_gem->name = name;
@@ -792,6 +797,23 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
int ret;
struct drm_gem_open open_arg;
struct drm_i915_gem_get_tiling get_tiling;
+ drmMMListHead *list;
+
+ /* At the moment most applications only have a few named bo.
+ * For instance, in a DRI client only the render buffers passed
+ * between X and the client are named. And since X returns the
+ * alternating names for the front/back buffer a linear search
+ * provides a sufficiently fast match.
+ */
+ for (list = bufmgr_gem->named.next;
+ list != &bufmgr_gem->named;
+ list = list->next) {
+ bo_gem = DRMLISTENTRY(drm_intel_bo_gem, list, name_list);
+ if (bo_gem->global_name == handle) {
+ drm_intel_gem_bo_reference(&bo_gem->bo);
+ return &bo_gem->bo;
+ }
+ }
bo_gem = calloc(1, sizeof(*bo_gem));
if (!bo_gem)
@@ -834,6 +856,7 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
/* XXX stride is unknown */
drm_intel_bo_gem_set_in_aperture_size(bufmgr_gem, bo_gem);
+ DRMLISTADDTAIL(&bo_gem->name_list, &bufmgr_gem->named);
DBG("bo_create_from_handle: %d (%s)\n", handle, bo_gem->name);
return &bo_gem->bo;
@@ -925,6 +948,8 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time)
bo_gem->relocs = NULL;
}
+ DRMLISTDEL(&bo_gem->name_list);
+
bucket = drm_intel_gem_bo_bucket_for_size(bufmgr_gem, bo->size);
/* Put the buffer into our internal cache for reuse if we can. */
if (bufmgr_gem->bo_reuse && bo_gem->reusable && bucket != NULL &&
@@ -1771,6 +1796,8 @@ drm_intel_gem_bo_flink(drm_intel_bo *bo, uint32_t * name)
return -errno;
bo_gem->global_name = flink.name;
bo_gem->reusable = 0;
+
+ DRMLISTADDTAIL(&bo_gem->name_list, &bufmgr_gem->named);
}
*name = bo_gem->global_name;
@@ -2217,6 +2244,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
drm_intel_gem_get_pipe_from_crtc_id;
bufmgr_gem->bufmgr.bo_references = drm_intel_gem_bo_references;
+ DRMINITLISTHEAD(&bufmgr_gem->named);
init_cache_buckets(bufmgr_gem);
return &bufmgr_gem->bufmgr;
commit 53581b6210c024044e0065527d1506e6f5657ef5
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Mon Feb 14 09:27:05 2011 +0000
intel: Set the public handle after opening by name
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 72c8731..092b56a 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -816,6 +816,7 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
atomic_set(&bo_gem->refcount, 1);
bo_gem->validate_index = -1;
bo_gem->gem_handle = open_arg.handle;
+ bo_gem->bo.handle = open_arg.handle;
bo_gem->global_name = handle;
bo_gem->reusable = 0;
commit 550fe2ca3b29ad2191eab4fdfbed9ed21e25492d
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Wed Jan 12 15:06:25 2011 +0000
intel: compile fix for previous commit after rebasing
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c
index 2546222..e949ff2 100644
--- a/intel/intel_bufmgr.c
+++ b/intel/intel_bufmgr.c
@@ -143,7 +143,7 @@ drm_intel_bo_mrb_exec(drm_intel_bo *bo, int used,
cliprects, num_cliprects, DR4,
rings);
- if (ring_flag == 0)
+ if (rings == 0)
return bo->bufmgr->bo_exec(bo, used,
cliprects, num_cliprects, DR4);
commit 6717b7579f84d05e45e7846d2b6e767760461709
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Wed Jan 12 10:57:46 2011 +0000
intel: Fallback to old exec if no mrb_exec is available
Reported-by: Torsten Hilbrich <torsten.hilbrich@secunet.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33016
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c
index b7c5c09..2546222 100644
--- a/intel/intel_bufmgr.c
+++ b/intel/intel_bufmgr.c
@@ -143,6 +143,10 @@ drm_intel_bo_mrb_exec(drm_intel_bo *bo, int used,
cliprects, num_cliprects, DR4,
rings);
+ if (ring_flag == 0)
+ return bo->bufmgr->bo_exec(bo, used,
+ cliprects, num_cliprects, DR4);
+
return -ENODEV;
}
commit bad5242a59aa8e31cf10749e2ac69b3c66ef7da0
Author: Ben Skeggs <bskeggs@redhat.com>
Date: Mon Dec 20 16:02:42 2010 +1000
nouveau: fix up reloc_emit() to accept NULL target buffer
The nvc0 gallium drivers passes NULL here to indicate to the memory manager
that a buffer is being used, but without creating an actual reloc.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
diff --git a/nouveau/nouveau_reloc.c b/nouveau/nouveau_reloc.c
index 332dfa0..cd219db 100644
--- a/nouveau/nouveau_reloc.c
+++ b/nouveau/nouveau_reloc.c
Reply to: