configure.ac | 5 debian/changelog | 33 +++++ debian/control | 2 debian/libdrm-intel1.symbols | 2 debian/libkms1.symbols | 1 debian/rules | 2 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 ++++++++++++++---------- 26 files changed, 659 insertions(+), 146 deletions(-)
New commits: commit a11ea35f4ffb32591da33dba6e242d246d58ad7d Author: Christopher James Halse Rogers <christopher.halse.rog...@canonical.com> Date: Fri Mar 4 12:56:52 2011 +1100 Add new radeon symbols to libkms diff --git a/debian/changelog b/debian/changelog index 9f791eb..9f5f54d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ libdrm (2.4.24-1) UNRELEASED; urgency=low * New upstream release. - Contains intel cherry-picks taken in 2.4.23-3. + * Add new internal radeon symbols to libkms1.symbols -- Christopher James Halse Rogers <r...@ubuntu.com> Fri, 04 Mar 2011 11:24:07 +1100 diff --git a/debian/libkms1.symbols b/debian/libkms1.symbols index 0458f6e..bb782d1 100644 --- a/debian/libkms1.symbols +++ b/debian/libkms1.symbols @@ -11,4 +11,5 @@ libkms.so.1 libkms1 #MINVER# kms_get_prop@Base 0 linux_create@Base 0 1 nouveau_create@Base 0 1 + radeon_create@Base 2.4.24 1 vmwgfx_create@Base 0 1 commit 5be062e94c857e8c76b6e8a87ec5e0d5ceb0f9b6 Author: Christopher James Halse Rogers <christopher.halse.rog...@canonical.com> Date: Fri Mar 4 12:53:37 2011 +1100 Changelog entry for new upstream diff --git a/debian/changelog b/debian/changelog index 9e5318e..9f791eb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +libdrm (2.4.24-1) UNRELEASED; urgency=low + + * New upstream release. + - Contains intel cherry-picks taken in 2.4.23-3. + + -- Christopher James Halse Rogers <r...@ubuntu.com> Fri, 04 Mar 2011 11:24:07 +1100 + libdrm (2.4.23-3) unstable; urgency=low * Cherry-pick from upstream: commit d9f77af478d9d4b9225df97632701b18588a0bab Author: Christopher James Halse Rogers <christopher.halse.rog...@canonical.com> Date: Fri Mar 4 12:32:59 2011 +1100 Revert "intel: Fallback to old exec if no mrb_exec is available" It seems git got confused by an upstream rebase and didn't merge this cherry-pick with the original commit which causes the build to fail. This reverts commit e4aa4696a44b2bb571bf7ba56ccdff921e562205. diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c index a1d846b..e949ff2 100644 --- a/intel/intel_bufmgr.c +++ b/intel/intel_bufmgr.c @@ -147,10 +147,6 @@ drm_intel_bo_mrb_exec(drm_intel_bo *bo, int used, return bo->bufmgr->bo_exec(bo, used, cliprects, num_cliprects, DR4); - if (ring_flag == 0) - return bo->bufmgr->bo_exec(bo, used, - cliprects, num_cliprects, DR4); - return -ENODEV; } commit a926a043b8079a8e283aa231e3c2347f5ad5864f Author: Chris Wilson <ch...@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 <ch...@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-de...@lists.sourceforge.net], libdrm) +AC_INIT([libdrm], 2.4.24, [dri-de...@lists.sourceforge.net], libdrm) AC_USE_SYSTEM_EXTENSIONS AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([dist-bzip2]) commit 0209428b3918c4336018da9293cdcbf7f8fedfb6 Author: Chris Wilson <ch...@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 <ch...@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.vet...@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 <ch...@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vet...@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.vet...@ffwll.ch> Date: Tue Feb 22 18:53:56 2011 +0100 intel: fix relaxed tiling on gen2 Signed-off-by: Daniel Vetter <daniel.vet...@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 <benjaminfran...@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 <benjaminfran...@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 <benjaminfran...@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 <benjaminfran...@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 <benjaminfran...@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 <nob...@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 8dbd9c6ac6f5a5803a39b93d65cdd9a9fb7e21b2 Author: Cyril Brulebois <k...@debian.org> Date: Wed Feb 16 11:44:48 2011 +0100 Upload to unstable. diff --git a/debian/changelog b/debian/changelog index 26372aa..9e5318e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -libdrm (2.4.23-3) UNRELEASED; urgency=low +libdrm (2.4.23-3) unstable; urgency=low * Cherry-pick from upstream: - intel: Fallback to old exec if no mrb_exec is available @@ -12,7 +12,7 @@ libdrm (2.4.23-3) UNRELEASED; urgency=low (Closes: #609299). * Bump the libdrm-intel1 shlibs version for consistency. - -- Cyril Brulebois <k...@debian.org> Wed, 16 Feb 2011 11:04:43 +0100 + -- Cyril Brulebois <k...@debian.org> Wed, 16 Feb 2011 11:44:44 +0100 libdrm (2.4.23-2) unstable; urgency=low commit af6d552526b32d1b713a0fe9c4f9c1385b945a2e Author: Cyril Brulebois <k...@debian.org> Date: Wed Feb 16 11:40:39 2011 +0100 Make lintian/backporters happy… diff --git a/debian/libdrm-intel1.symbols b/debian/libdrm-intel1.symbols index 750f65b..3634492 100644 --- a/debian/libdrm-intel1.symbols +++ b/debian/libdrm-intel1.symbols @@ -16,7 +16,7 @@ libdrm_intel.so.1 libdrm-intel1 #MINVER# drm_intel_bo_is_reusable@Base 2.4.21 drm_intel_bo_madvise@Base 2.4.16 drm_intel_bo_map@Base 2.4.1 - drm_intel_bo_mrb_exec@Base 2.4.23-3 + drm_intel_bo_mrb_exec@Base 2.4.23-3~ drm_intel_bo_pin@Base 2.4.1 drm_intel_bo_reference@Base 2.4.1 drm_intel_bo_references@Base 2.4.15 diff --git a/debian/rules b/debian/rules index 69b2e89..4d838ba 100755 --- a/debian/rules +++ b/debian/rules @@ -144,7 +144,7 @@ endif dh_fixperms -s dh_makeshlibs -plibdrm2 -V'libdrm2 (>= 2.4.17)' -- -c4 ifeq ($(INTEL), yes) - dh_makeshlibs -plibdrm-intel1 -V'libdrm-intel1 (>= 2.4.23-3)' -- -c4 + dh_makeshlibs -plibdrm-intel1 -V'libdrm-intel1 (>= 2.4.23-3~)' -- -c4 endif ifeq ($(NOUVEAU), yes) dh_makeshlibs -plibdrm-nouveau1a -V'libdrm-nouveau1a (>= 2.4.23)' -- -c4 commit ff3f97e2d8f6643324361806f86379675c7d25a9 Author: Cyril Brulebois <k...@debian.org> Date: Wed Feb 16 11:39:46 2011 +0100 Bump the libdrm-intel1 shlibs version for consistency. diff --git a/debian/changelog b/debian/changelog index 51eed55..26372aa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,7 @@ libdrm (2.4.23-3) UNRELEASED; urgency=low libdrm-intel1's symbols file. While the former version is alright from a shared object point of view, runtime doesn't seem to agree (Closes: #609299). + * Bump the libdrm-intel1 shlibs version for consistency. -- Cyril Brulebois <k...@debian.org> Wed, 16 Feb 2011 11:04:43 +0100 diff --git a/debian/rules b/debian/rules index 82741af..69b2e89 100755 --- a/debian/rules +++ b/debian/rules @@ -144,7 +144,7 @@ endif dh_fixperms -s dh_makeshlibs -plibdrm2 -V'libdrm2 (>= 2.4.17)' -- -c4 ifeq ($(INTEL), yes) - dh_makeshlibs -plibdrm-intel1 -V'libdrm-intel1 (>= 2.4.21)' -- -c4 + dh_makeshlibs -plibdrm-intel1 -V'libdrm-intel1 (>= 2.4.23-3)' -- -c4 endif ifeq ($(NOUVEAU), yes) dh_makeshlibs -plibdrm-nouveau1a -V'libdrm-nouveau1a (>= 2.4.23)' -- -c4 commit 070f3a6c02359e5966a747b5aa79d2bdf21140b6 Author: Cyril Brulebois <k...@debian.org> Date: Wed Feb 16 11:32:06 2011 +0100 Bump dependency to 2.4.23-3 for the drm_intel_bo_mrb_exec symbol. Hopefully closes: #609299. diff --git a/debian/changelog b/debian/changelog index 7ff3e0c..51eed55 100644 -- To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/e1pvmzr-0004gr...@alioth.debian.org