diff options
author | Cyril Brulebois <kibi@debian.org> | 2011-04-18 22:22:45 +0200 |
---|---|---|
committer | Cyril Brulebois <kibi@debian.org> | 2011-04-18 22:22:45 +0200 |
commit | 7e8361993321edf65b9e63303cb7bd4682c91f18 (patch) | |
tree | ee43d153ba41d5b87350e07574956321b43f71cc | |
parent | 2f0483128b47a19a91352b27abf71a820ba90f28 (diff) | |
parent | ba11501bb9f5bd98110dfe1385b4501c0a9a643a (diff) |
Merge branch 'upstream-experimental' into debian-experimental
-rw-r--r-- | Makefile.am | 2 | ||||
-rwxr-xr-x | autogen.sh | 14 | ||||
-rw-r--r-- | configure.ac | 47 | ||||
-rw-r--r-- | include/drm/drm.h | 14 | ||||
-rw-r--r-- | include/drm/drm_mode.h | 29 | ||||
-rw-r--r-- | intel/intel_bufmgr.c | 9 | ||||
-rw-r--r-- | intel/intel_bufmgr_gem.c | 7 | ||||
-rw-r--r-- | libkms/Makefile.am | 1 | ||||
-rw-r--r-- | libkms/dumb.c | 220 | ||||
-rw-r--r-- | libkms/internal.h | 2 | ||||
-rw-r--r-- | libkms/linux.c | 3 | ||||
-rw-r--r-- | m4/.gitignore | 5 | ||||
-rw-r--r-- | tests/Makefile.am | 12 | ||||
-rw-r--r-- | xf86drm.c | 12 | ||||
-rw-r--r-- | xf86drm.h | 4 |
15 files changed, 335 insertions, 46 deletions
diff --git a/Makefile.am b/Makefile.am index 25d17470..a4d07f42 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,7 @@ # 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. -AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} DISTCHECK_CONFIGURE_FLAGS = --enable-nouveau-experimental-api --enable-radeon-experimental-api @@ -1,12 +1,6 @@ #! /bin/sh -srcdir=`dirname $0` -test -z "$srcdir" && srcdir=. - -ORIGDIR=`pwd` -cd $srcdir - -autoreconf -v --install || exit 1 -cd $ORIGDIR || exit $? - -$srcdir/configure --enable-maintainer-mode "$@" +test -n "$srcdir" || srcdir=`dirname "$0"` +test -n "$srcdir" || srcdir=. +autoreconf --force --install --verbose "$srcdir" +test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" diff --git a/configure.ac b/configure.ac index 19982041..d9c826d8 100644 --- a/configure.ac +++ b/configure.ac @@ -18,24 +18,34 @@ # 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. -AC_PREREQ(2.60) -AC_INIT([libdrm], 2.4.24, [dri-devel@lists.sourceforge.net], libdrm) -AC_USE_SYSTEM_EXTENSIONS +AC_PREREQ([2.63]) +AC_INIT([libdrm], + [2.4.25], + [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI], + [libdrm]) + +AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([Makefile.am]) -AM_INIT_AUTOMAKE([dist-bzip2]) +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_AUX_DIR([build-aux]) + +AM_INIT_AUTOMAKE([1.10 foreign dist-bzip2]) +AM_MAINTAINER_MODE([enable]) -AM_CONFIG_HEADER([config.h]) +# Enable quiet compiles on automake 1.11. +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -AC_DISABLE_STATIC -AC_PROG_LIBTOOL +# Check for programs AC_PROG_CC -AC_HEADER_STDC +AC_USE_SYSTEM_EXTENSIONS AC_SYS_LARGEFILE AC_FUNC_ALLOCA -# Enable quiet compiles on automake 1.11. -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +# Initialize libtool +LT_PREREQ([2.2]) +LT_INIT([disable-static]) + PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs) AC_SUBST(PTHREADSTUBS_CFLAGS) @@ -43,9 +53,10 @@ AC_SUBST(PTHREADSTUBS_LIBS) pkgconfigdir=${libdir}/pkgconfig AC_SUBST(pkgconfigdir) -AC_ARG_ENABLE(udev, AS_HELP_STRING([--enable-udev], - [Enable support for using udev instead of mknod (default: disabled)]), - [UDEV=$enableval], [UDEV=no]) +AC_ARG_ENABLE([udev], + [AS_HELP_STRING([--enable-udev], + [Enable support for using udev instead of mknod (default: disabled)])], + [UDEV=$enableval], [UDEV=no]) AC_ARG_ENABLE(libkms, AS_HELP_STRING([--disable-libkms], @@ -188,12 +199,11 @@ if test "x$INTEL" != "xno" -o "x$RADEON" != "xno"; then [ drm_cv_atomic_primitives="none" - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ int atomic_add(int i) { return __sync_fetch_and_add (&i, 1); } int atomic_cmpxchg(int i, int j, int k) { return __sync_val_compare_and_swap (&i, j, k); } - ], [], - drm_cv_atomic_primitives="Intel" - ) + ]],[[]])], + [drm_cv_atomic_primitives="Intel"],[]) if test "x$drm_cv_atomic_primitives" = "xnone"; then AC_CHECK_HEADER([atomic_ops.h], drm_cv_atomic_primitives="libatomic-ops") @@ -255,7 +265,7 @@ AC_ARG_WITH([kernel-source], AC_SUBST(kernel_source) AC_SUBST(WARN_CFLAGS) -AC_OUTPUT([ +AC_CONFIG_FILES([ Makefile libkms/Makefile libkms/libkms.pc @@ -273,6 +283,7 @@ AC_OUTPUT([ include/Makefile include/drm/Makefile libdrm.pc]) +AC_OUTPUT echo "" echo "$PACKAGE_STRING will be compiled with:" diff --git a/include/drm/drm.h b/include/drm/drm.h index 2ba71364..5fd24fcf 100644 --- a/include/drm/drm.h +++ b/include/drm/drm.h @@ -612,6 +612,12 @@ struct drm_gem_open { __u64 size; }; +/** DRM_IOCTL_GET_CAP ioctl argument type */ +struct drm_get_cap { + __u64 capability; + __u64 value; +}; + #include "drm_mode.h" #define DRM_IOCTL_BASE 'd' @@ -632,6 +638,7 @@ struct drm_gem_open { #define DRM_IOCTL_GEM_CLOSE DRM_IOW (0x09, struct drm_gem_close) #define DRM_IOCTL_GEM_FLINK DRM_IOWR(0x0a, struct drm_gem_flink) #define DRM_IOCTL_GEM_OPEN DRM_IOWR(0x0b, struct drm_gem_open) +#define DRM_IOCTL_GET_CAP DRM_IOWR(0x0c, struct drm_get_cap) #define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, struct drm_unique) #define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, struct drm_auth) @@ -703,6 +710,10 @@ struct drm_gem_open { #define DRM_IOCTL_MODE_PAGE_FLIP DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip) #define DRM_IOCTL_MODE_DIRTYFB DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd) +#define DRM_IOCTL_MODE_CREATE_DUMB DRM_IOWR(0xB2, struct drm_mode_create_dumb) +#define DRM_IOCTL_MODE_MAP_DUMB DRM_IOWR(0xB3, struct drm_mode_map_dumb) +#define DRM_IOCTL_MODE_DESTROY_DUMB DRM_IOWR(0xB4, struct drm_mode_destroy_dumb) + /** * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x99. @@ -743,6 +754,9 @@ struct drm_event_vblank { __u32 reserved; }; +#define DRM_CAP_DUMB_BUFFER 0x1 +#define DRM_CAP_VBLANK_HIGH_CRTC 0x2 + /* typedef area */ typedef struct drm_clip_rect drm_clip_rect_t; typedef struct drm_drawable_info drm_drawable_info_t; diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h index 0fc7397c..c7c1fbe3 100644 --- a/include/drm/drm_mode.h +++ b/include/drm/drm_mode.h @@ -344,4 +344,33 @@ struct drm_mode_crtc_page_flip { __u64 user_data; }; +/* create a dumb scanout buffer */ +struct drm_mode_create_dumb { + __u32 height; + __u32 width; + __u32 bpp; + __u32 flags; + /* handle, pitch, size will be returned */ + __u32 handle; + __u32 pitch; + __u64 size; +}; + +/* set up for mmap of a dumb scanout buffer */ +struct drm_mode_map_dumb { + /** Handle for the object being mapped. */ + __u32 handle; + __u32 pad; + /** + * Fake offset to use for subsequent mmap call + * + * This is a fixed-size type for 32/64 compatibility. + */ + __u64 offset; +}; + +struct drm_mode_destroy_dumb { + __u32 handle; +}; + #endif diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c index e949ff2a..2df93a58 100644 --- a/intel/intel_bufmgr.c +++ b/intel/intel_bufmgr.c @@ -143,11 +143,14 @@ drm_intel_bo_mrb_exec(drm_intel_bo *bo, int used, cliprects, num_cliprects, DR4, rings); - if (rings == 0) + switch (rings) { + case I915_EXEC_DEFAULT: + case I915_EXEC_RENDER: return bo->bufmgr->bo_exec(bo, used, cliprects, num_cliprects, DR4); - - return -ENODEV; + default: + return -ENODEV; + } } void drm_intel_bufmgr_set_debug(drm_intel_bufmgr *bufmgr, int enable_debug) diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index f5ab0a6f..4f4de929 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -762,13 +762,12 @@ drm_intel_gem_bo_alloc_tiled(drm_intel_bufmgr *bufmgr, const char *name, aligned_y = y; height_alignment = 2; - if (tiling == I915_TILING_X) + if (IS_GEN2(bufmgr_gem) && tiling != I915_TILING_NONE) + height_alignment = 16; + else if (tiling == I915_TILING_X) height_alignment = 8; else if (tiling == I915_TILING_Y) height_alignment = 32; - /* i8xx has a interleaved 2-row tile layout */ - if (IS_GEN2(bufmgr_gem) && tiling != I915_TILING_NONE) - height_alignment *= 2; aligned_y = ALIGN(y, height_alignment); stride = x * cpp; diff --git a/libkms/Makefile.am b/libkms/Makefile.am index 5c2e63fc..fa379a4b 100644 --- a/libkms/Makefile.am +++ b/libkms/Makefile.am @@ -16,6 +16,7 @@ libkms_la_SOURCES = \ internal.h \ linux.c \ intel.c \ + dumb.c \ api.c if HAVE_VMWGFX diff --git a/libkms/dumb.c b/libkms/dumb.c new file mode 100644 index 00000000..3be5f7a2 --- /dev/null +++ b/libkms/dumb.c @@ -0,0 +1,220 @@ +/************************************************************************** + * + * 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 "i915_drm.h" + +struct dumb_bo +{ + struct kms_bo base; + unsigned map_count; +}; + +static int +dumb_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 +dumb_destroy(struct kms_driver *kms) +{ + free(kms); + return 0; +} + +static int +dumb_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_mode_create_dumb arg; + struct dumb_bo *bo; + int i, ret; + + for (i = 0; attr[i]; i += 2) { + switch (attr[i]) { + case KMS_WIDTH: + case KMS_HEIGHT: + break; + case KMS_BO_TYPE: + break; + default: + return -EINVAL; + } + } + + bo = calloc(1, sizeof(*bo)); + if (!bo) + return -ENOMEM; + + memset(&arg, 0, sizeof(arg)); + + arg.bpp = 16; + arg.width = width; + arg.height = height; + + ret = drmIoctl(kms->fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg); + if (ret) + goto err_free; + + bo->base.kms = kms; + bo->base.handle = arg.handle; + bo->base.size = arg.size; + bo->base.pitch = arg.pitch; + + *out = &bo->base; + + return 0; + +err_free: + free(bo); + return ret; +} + +static int +dumb_bo_get_prop(struct kms_bo *bo, unsigned key, unsigned *out) +{ + switch (key) { + default: + return -EINVAL; + } +} + +static int +dumb_bo_map(struct kms_bo *_bo, void **out) +{ + struct dumb_bo *bo = (struct dumb_bo *)_bo; + struct drm_mode_map_dumb 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; + + ret = drmIoctl(bo->base.kms->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg); + if (ret) + return ret; + + map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset); + if (map == MAP_FAILED) + return -errno; + + bo->base.ptr = map; + bo->map_count++; + *out = bo->base.ptr; + + return 0; +} + +static int +dumb_bo_unmap(struct kms_bo *_bo) +{ + struct dumb_bo *bo = (struct dumb_bo *)_bo; + bo->map_count--; + return 0; +} + +static int +dumb_bo_destroy(struct kms_bo *_bo) +{ + struct dumb_bo *bo = (struct dumb_bo *)_bo; + struct drm_mode_destroy_dumb 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_MODE_DESTROY_DUMB, &arg); + if (ret) + return -errno; + + free(bo); + return 0; +} + +int +dumb_create(int fd, struct kms_driver **out) +{ + struct kms_driver *kms; + int ret; + uint64_t cap = 0; + + ret = drmGetCap(fd, DRM_CAP_DUMB_BUFFER, &cap); + if (ret || cap == 0) + return -EINVAL; + + kms = calloc(1, sizeof(*kms)); + if (!kms) + return -ENOMEM; + + kms->fd = fd; + + kms->bo_create = dumb_bo_create; + kms->bo_map = dumb_bo_map; + kms->bo_unmap = dumb_bo_unmap; + kms->bo_get_prop = dumb_bo_get_prop; + kms->bo_destroy = dumb_bo_destroy; + kms->get_prop = dumb_get_prop; + kms->destroy = dumb_destroy; + *out = kms; + + return 0; +} diff --git a/libkms/internal.h b/libkms/internal.h index 51f5e65c..5e2501e4 100644 --- a/libkms/internal.h +++ b/libkms/internal.h @@ -68,6 +68,8 @@ int vmwgfx_create(int fd, struct kms_driver **out); int intel_create(int fd, struct kms_driver **out); +int dumb_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); diff --git a/libkms/linux.c b/libkms/linux.c index 7449abc1..fc4f205c 100644 --- a/libkms/linux.c +++ b/libkms/linux.c @@ -216,6 +216,9 @@ linux_from_udev(int fd, struct kms_driver **out) int linux_create(int fd, struct kms_driver **out) { + if (!dumb_create(fd, out)) + return 0; + if (!linux_from_udev(fd, out)) return 0; diff --git a/m4/.gitignore b/m4/.gitignore new file mode 100644 index 00000000..464ba5ca --- /dev/null +++ b/m4/.gitignore @@ -0,0 +1,5 @@ +libtool.m4 +lt~obsolete.m4 +ltoptions.m4 +ltsugar.m4 +ltversion.m4 diff --git a/tests/Makefile.am b/tests/Makefile.am index ebf4853a..bf1987f1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,13 +10,10 @@ check_PROGRAMS = \ dristat \ drmstat -SUBDIRS = +SUBDIRS = modeprint if HAVE_LIBKMS -SUBDIRS += kmstest -endif - -if HAVE_INTEL +SUBDIRS += kmstest modetest endif if HAVE_LIBUDEV @@ -50,11 +47,6 @@ TESTS = \ SUBDIRS += vbltest $(NULL) if HAVE_INTEL -SUBDIRS += \ - modeprint \ - modetest \ - $(NULL) - TESTS += \ gem_basic \ gem_flink \ @@ -810,6 +810,18 @@ drmVersionPtr drmGetLibVersion(int fd) return (drmVersionPtr)version; } +int drmGetCap(int fd, uint64_t capability, uint64_t *value) +{ + struct drm_get_cap cap = { capability, 0 }; + int ret; + + ret = drmIoctl(fd, DRM_IOCTL_GET_CAP, &cap); + if (ret) + return ret; + + *value = cap.value; + return 0; +} /** * Free the bus ID information. @@ -296,12 +296,15 @@ typedef struct _drmTextureRegion { typedef enum { DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */ DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */ + /* bits 1-6 are reserved for high crtcs */ + DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e, DRM_VBLANK_EVENT = 0x4000000, /**< Send event instead of blocking */ DRM_VBLANK_FLIP = 0x8000000, /**< Scheduled buffer swap should flip */ DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */ DRM_VBLANK_SECONDARY = 0x20000000, /**< Secondary display controller */ DRM_VBLANK_SIGNAL = 0x40000000 /* Send signal instead of blocking */ } drmVBlankSeqType; +#define DRM_VBLANK_HIGH_CRTC_SHIFT 1 typedef struct _drmVBlankReq { drmVBlankSeqType type; @@ -542,6 +545,7 @@ extern int drmOpenControl(int minor); extern int drmClose(int fd); extern drmVersionPtr drmGetVersion(int fd); extern drmVersionPtr drmGetLibVersion(int fd); +extern int drmGetCap(int fd, uint64_t capability, uint64_t *value); extern void drmFreeVersion(drmVersionPtr); extern int drmGetMagic(int fd, drm_magic_t * magic); extern char *drmGetBusid(int fd); |