.gitignore | 10 ChangeLog | 733 ++++++++++++++++ Makefile.am | 8 configure.ac | 76 + debian/changelog | 50 - debian/control | 5 debian/libdrm-dev.install | 2 debian/libdrm-nouveau2.symbols | 1 debian/patches/02_build_libkms_against_in_tree_drm.diff | 17 debian/patches/series | 1 debian/rules | 6 exynos/Makefile.am | 2 exynos/exynos_drm.h | 52 + exynos/exynos_fimg2d.c | 630 +++++++++++++ exynos/fimg2d.h | 325 +++++++ exynos/fimg2d_reg.h | 114 ++ freedreno/Makefile.am | 19 freedreno/README | 16 freedreno/freedreno_bo.c | 274 +++++ freedreno/freedreno_device.c | 45 freedreno/freedreno_drmif.h | 99 ++ freedreno/freedreno_pipe.c | 227 ++++ freedreno/freedreno_priv.h | 117 ++ freedreno/freedreno_ringbuffer.c | 249 +++++ freedreno/freedreno_ringbuffer.h | 87 + freedreno/kgsl_drm.h | 192 ++++ freedreno/libdrm_freedreno.pc.in | 11 freedreno/list.h | 137 ++ freedreno/msm_kgsl.h | 519 +++++++++++ intel/intel_bufmgr_gem.c | 22 intel/intel_chipset.h | 379 ++++---- intel/intel_decode.c | 4 libkms/Makefile.am | 2 libkms/intel.c | 1 libkms/linux.c | 2 libkms/nouveau.c | 1 man/Makefile.am | 63 + man/drm-kms.xml | 342 +++++++ man/drm-memory.xml | 430 +++++++++ man/drm.xml | 137 ++ man/drmAvailable.xml | 75 + man/drmHandleEvent.xml | 102 ++ man/drmModeGetResources.xml | 139 +++ nouveau/abi16.c | 28 nouveau/libdrm_nouveau.pc.in | 4 nouveau/nouveau.c | 21 nouveau/nouveau.h | 16 nouveau/private.h | 2 nouveau/pushbuf.c | 16 omap/omap_drm.c | 2 radeon/r600_pci_ids.h | 29 radeon/radeon_bo_gem.c | 16 radeon/radeon_cs_gem.c | 2 radeon/radeon_surface.c | 405 +++++++- radeon/radeon_surface.h | 2 tests/Makefile.am | 4 tests/exynos/Makefile.am | 19 tests/exynos/exynos_fimg2d_test.c | 695 +++++++++++++++ tests/kmstest/Makefile.am | 5 tests/modeprint/Makefile.am | 5 tests/modetest/Makefile.am | 16 tests/vbltest/Makefile.am | 6 xf86drmMode.c | 5 63 files changed, 6697 insertions(+), 324 deletions(-)
New commits: commit 7c88e4544a079a590a6fac05cd63f2441e9e619a Author: Maarten Lankhorst <maarten.lankho...@canonical.com> Date: Mon Apr 22 15:46:59 2013 +0200 release to quantal diff --git a/debian/changelog b/debian/changelog index d884e8e..2b54bb3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -libdrm (2.4.43-0ubuntu0.1) UNRELEASED; urgency=low +libdrm (2.4.43-0ubuntu0.1) quantal-proposed; urgency=low * Copy package from raring, and re-enable libdrm-nouveau1a. (LP: #1171340) commit 645deada451406398728c7ce524b40579cbc824d Author: Maarten Lankhorst <maarten.lankho...@canonical.com> Date: Mon Apr 22 11:09:36 2013 +0200 Copy package from raring, and re-enable libdrm-nouveau1a. (LP: #1171340) diff --git a/debian/changelog b/debian/changelog index 8ca09a8..d884e8e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libdrm (2.4.43-0ubuntu0.1) UNRELEASED; urgency=low + + * Copy package from raring, and re-enable libdrm-nouveau1a. (LP: #1171340) + + -- Maarten Lankhorst <maarten.lankho...@ubuntu.com> Mon, 22 Apr 2013 11:06:19 +0200 + libdrm (2.4.43-0ubuntu1) raring; urgency=low * Sync from unreleased debian git. diff --git a/debian/control b/debian/control index 4e3f61f..dd5805a 100644 --- a/debian/control +++ b/debian/control @@ -27,6 +27,7 @@ Depends: libdrm2 (= ${binary:Version}), libdrm-intel1 (= ${binary:Version}) [amd64 i386 kfreebsd-amd64 kfreebsd-i386], libdrm-radeon1 (= ${binary:Version}) [linux-any], + libdrm-nouveau1a (= ${binary:Version}) [linux-any], libdrm-nouveau2 (= ${binary:Version}) [linux-any], libdrm-omap1 (= ${binary:Version}) [any-arm], libkms1 (= ${binary:Version}) [linux-any], @@ -116,6 +117,36 @@ Description: Userspace interface to intel-specific kernel DRM services -- debugg . This package provides the debugging symbols for the libdrm-intel1 package. +Package: libdrm-nouveau1a +Section: libs +Architecture: linux-any +Depends: ${shlibs:Depends}, + ${misc:Depends}, +Conflicts: libdrm-nouveau1 +Pre-Depends: ${misc:Pre-Depends} +Multi-Arch: same +Description: Userspace interface to nouveau-specific kernel DRM services -- runtime + This library implements the userspace interface to the nouveau-specific kernel + DRM services. DRM stands for "Direct Rendering Manager", which is the + kernelspace portion of the "Direct Rendering Infrastructure" (DRI). The DRI is + currently used on Linux to provide hardware-accelerated OpenGL drivers. + +Package: libdrm-nouveau1a-dbg +Section: debug +Priority: extra +Architecture: linux-any +Depends: libdrm-nouveau1a (= ${binary:Version}), + ${misc:Depends}, +Conflicts: libdrm-nouveau1-dbg +Multi-Arch: same +Description: Userspace interface to nouveau-specific kernel DRM -- debugging symbols + This library implements the userspace interface to the kernel DRM services. + DRM stands for "Direct Rendering Manager", which is the kernelspace portion + of the "Direct Rendering Infrastructure" (DRI). The DRI is currently used on + Linux to provide hardware-accelerated OpenGL drivers. + . + This package provides the debugging symbols for the libdrm-nouveau1a package. + Package: libdrm-nouveau2 Section: libs Architecture: linux-any diff --git a/debian/libdrm-nouveau1a.install b/debian/libdrm-nouveau1a.install new file mode 100644 index 0000000..6c55080 --- /dev/null +++ b/debian/libdrm-nouveau1a.install @@ -0,0 +1 @@ +usr/lib/*/libdrm_nouveau.so.1* diff --git a/debian/libdrm-nouveau1a.lintian-overrides b/debian/libdrm-nouveau1a.lintian-overrides new file mode 100644 index 0000000..76c525b --- /dev/null +++ b/debian/libdrm-nouveau1a.lintian-overrides @@ -0,0 +1 @@ +libdrm-nouveau1a: package-name-doesnt-match-sonames libdrm-nouveau1 diff --git a/debian/libdrm-nouveau1a.symbols b/debian/libdrm-nouveau1a.symbols new file mode 100644 index 0000000..a2ba922 --- /dev/null +++ b/debian/libdrm-nouveau1a.symbols @@ -0,0 +1,46 @@ +libdrm_nouveau.so.1 libdrm-nouveau1a #MINVER# + nouveau_bo_busy@Base 2.4.23 + nouveau_bo_emit_buffer@Base 2.4.23 + nouveau_bo_handle_get@Base 2.4.23 + nouveau_bo_handle_ref@Base 2.4.23 + nouveau_bo_init@Base 2.4.23 + nouveau_bo_map@Base 2.4.23 + nouveau_bo_map_flush@Base 2.4.23 + nouveau_bo_map_range@Base 2.4.23 + nouveau_bo_new@Base 2.4.23 + nouveau_bo_new_tile@Base 2.4.23 + nouveau_bo_pending@Base 2.4.23 + nouveau_bo_ref@Base 2.4.23 + nouveau_bo_takedown@Base 2.4.23 + nouveau_bo_unmap@Base 2.4.23 + nouveau_bo_user@Base 2.4.23 + nouveau_bo_wrap@Base 2.4.23 + nouveau_channel_alloc@Base 2.4.23 + nouveau_channel_free@Base 2.4.23 + nouveau_device_close@Base 2.4.23 + nouveau_device_get_param@Base 2.4.23 + nouveau_device_open@Base 2.4.23 + nouveau_device_open_existing@Base 2.4.23 + nouveau_device_set_param@Base 2.4.23 + nouveau_grobj_alloc@Base 2.4.23 + nouveau_grobj_autobind@Base 2.4.23 + nouveau_grobj_free@Base 2.4.23 + nouveau_grobj_ref@Base 2.4.23 + nouveau_notifier_alloc@Base 2.4.23 + nouveau_notifier_free@Base 2.4.23 + nouveau_notifier_reset@Base 2.4.23 + nouveau_notifier_return_val@Base 2.4.23 + nouveau_notifier_status@Base 2.4.23 + nouveau_notifier_wait_status@Base 2.4.23 + nouveau_pushbuf_emit_reloc@Base 2.4.23 + nouveau_pushbuf_fini@Base 2.4.23 + nouveau_pushbuf_flush@Base 2.4.23 + nouveau_pushbuf_init@Base 2.4.23 + nouveau_pushbuf_marker_emit@Base 2.4.23 + nouveau_pushbuf_marker_undo@Base 2.4.23 + nouveau_pushbuf_submit@Base 2.4.23 + nouveau_reloc_emit@Base 2.4.23 + nouveau_resource_alloc@Base 2.4.23 + nouveau_resource_destroy@Base 2.4.23 + nouveau_resource_free@Base 2.4.23 + nouveau_resource_init@Base 2.4.23 diff --git a/debian/patches/04_libdrm-2.4.37-nouveau-1.diff b/debian/patches/04_libdrm-2.4.37-nouveau-1.diff new file mode 100644 index 0000000..10f02a9 --- /dev/null +++ b/debian/patches/04_libdrm-2.4.37-nouveau-1.diff @@ -0,0 +1,2921 @@ +diff --git a/Makefile.am b/Makefile.am +index 256a8cc..045add1 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -34,7 +34,7 @@ INTEL_SUBDIR = intel + endif + + if HAVE_NOUVEAU +-NOUVEAU_SUBDIR = nouveau ++NOUVEAU_SUBDIR = nouveau-1 nouveau + endif + + if HAVE_RADEON +diff --git a/configure.ac b/configure.ac +index a1c8c69..6439b81 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -319,6 +319,8 @@ AC_CONFIG_FILES([ + intel/libdrm_intel.pc + radeon/Makefile + radeon/libdrm_radeon.pc ++ nouveau-1/Makefile ++ nouveau-1/libdrm_nouveau1.pc + nouveau/Makefile + nouveau/libdrm_nouveau.pc + omap/Makefile +diff --git a/nouveau-1/Makefile.am b/nouveau-1/Makefile.am +new file mode 100644 +index 0000000..7e6aa13 +--- /dev/null ++++ b/nouveau-1/Makefile.am +@@ -0,0 +1,43 @@ ++AM_CFLAGS = \ ++ $(WARN_CFLAGS) \ ++ -I$(top_srcdir) \ ++ -I$(top_srcdir)/nouveau-1 \ ++ $(PTHREADSTUBS_CFLAGS) \ ++ -I$(top_srcdir)/include/drm ++ ++libdrm_nouveau_la_LTLIBRARIES = libdrm_nouveau.la ++libdrm_nouveau_ladir = $(libdir) ++libdrm_nouveau_la_LDFLAGS = -version-number 1:0:0 -no-undefined ++libdrm_nouveau_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ ++ ++libdrm_nouveau_la_SOURCES = \ ++ nouveau_device.c \ ++ nouveau_channel.c \ ++ nouveau_pushbuf.c \ ++ nouveau_grobj.c \ ++ nouveau_notifier.c \ ++ nouveau_bo.c \ ++ nouveau_resource.c \ ++ nouveau_private.h \ ++ nouveau_reloc.c ++ ++libdrm_nouveaucommonincludedir = ${includedir}/nouveau ++libdrm_nouveaucommoninclude_HEADERS = \ ++ nouveau_device.h \ ++ nouveau_channel.h \ ++ nouveau_grobj.h \ ++ nouveau_notifier.h \ ++ nouveau_pushbuf.h \ ++ nv04_pushbuf.h \ ++ nvc0_pushbuf.h \ ++ nouveau_bo.h \ ++ nouveau_resource.h \ ++ nouveau_reloc.h ++ ++ ++libdrm_nouveauincludedir = ${includedir}/libdrm ++libdrm_nouveauinclude_HEADERS = \ ++ nouveau_drmif.h ++ ++pkgconfigdir = @pkgconfigdir@ ++pkgconfig_DATA = libdrm_nouveau1.pc +diff --git a/nouveau-1/libdrm_nouveau1.pc.in b/nouveau-1/libdrm_nouveau1.pc.in +new file mode 100644 +index 0000000..8f3d40f +--- /dev/null ++++ b/nouveau-1/libdrm_nouveau1.pc.in +@@ -0,0 +1,11 @@ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++libdir=@libdir@ ++includedir=@includedir@ ++ ++Name: libdrm_nouveau ++Description: Userspace interface to nouveau kernel DRM services ++Version: 0.6 ++Libs: -L${libdir} -ldrm_nouveau1 ++Cflags: -I${includedir} -I${includedir}/libdrm -I${includedir}/nouveau ++Requires.private: libdrm +diff --git a/nouveau-1/nouveau_bo.c b/nouveau-1/nouveau_bo.c +new file mode 100644 +index 0000000..d6bb22d +--- /dev/null ++++ b/nouveau-1/nouveau_bo.c +@@ -0,0 +1,549 @@ ++/* ++ * Copyright 2007 Nouveau Project ++ * ++ * 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 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 AUTHORS 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. ++ */ ++ ++#ifdef HAVE_CONFIG_H ++#include <config.h> ++#endif ++#include <stdint.h> ++#include <stdlib.h> ++#include <errno.h> ++#include <assert.h> ++ ++#include <sys/mman.h> ++ ++#include "nouveau_private.h" ++ ++int ++nouveau_bo_init(struct nouveau_device *dev) ++{ ++ return 0; ++} ++ ++void ++nouveau_bo_takedown(struct nouveau_device *dev) ++{ ++} ++ ++static int ++nouveau_bo_info(struct nouveau_bo_priv *nvbo, struct drm_nouveau_gem_info *arg) ++{ ++ nvbo->handle = nvbo->base.handle = arg->handle; ++ nvbo->domain = arg->domain; ++ nvbo->size = arg->size; ++ nvbo->offset = arg->offset; ++ nvbo->map_handle = arg->map_handle; ++ nvbo->base.tile_mode = arg->tile_mode; ++ /* XXX - flag inverted for backwards compatibility */ ++ nvbo->base.tile_flags = arg->tile_flags ^ NOUVEAU_GEM_TILE_NONCONTIG; ++ return 0; ++} ++ ++static int ++nouveau_bo_allocated(struct nouveau_bo_priv *nvbo) ++{ ++ if (nvbo->sysmem || nvbo->handle) ++ return 1; ++ return 0; ++} ++ ++static int ++nouveau_bo_ualloc(struct nouveau_bo_priv *nvbo) ++{ ++ if (nvbo->user || nvbo->sysmem) { ++ assert(nvbo->sysmem); ++ return 0; ++ } ++ ++ nvbo->sysmem = malloc(nvbo->size); ++ if (!nvbo->sysmem) ++ return -ENOMEM; ++ ++ return 0; ++} ++ ++static void ++nouveau_bo_ufree(struct nouveau_bo_priv *nvbo) ++{ ++ if (nvbo->sysmem) { ++ if (!nvbo->user) ++ free(nvbo->sysmem); ++ nvbo->sysmem = NULL; ++ } ++} ++ ++static void ++nouveau_bo_kfree(struct nouveau_bo_priv *nvbo) ++{ ++ struct nouveau_device_priv *nvdev = nouveau_device(nvbo->base.device); ++ struct drm_gem_close req; ++ ++ if (!nvbo->handle) ++ return; ++ ++ if (nvbo->map) { ++ munmap(nvbo->map, nvbo->size); ++ nvbo->map = NULL; ++ } ++ ++ req.handle = nvbo->handle; ++ nvbo->handle = 0; ++ drmIoctl(nvdev->fd, DRM_IOCTL_GEM_CLOSE, &req); ++} ++ ++static int ++nouveau_bo_kalloc(struct nouveau_bo_priv *nvbo, struct nouveau_channel *chan) ++{ ++ struct nouveau_device_priv *nvdev = nouveau_device(nvbo->base.device); ++ struct drm_nouveau_gem_new req; ++ struct drm_nouveau_gem_info *info = &req.info; ++ int ret; ++ ++ if (nvbo->handle) ++ return 0; ++ ++ req.channel_hint = chan ? chan->id : 0; ++ req.align = nvbo->align; ++ ++ ++ info->size = nvbo->size; ++ info->domain = 0; ++ ++ if (nvbo->flags & NOUVEAU_BO_VRAM) ++ info->domain |= NOUVEAU_GEM_DOMAIN_VRAM; ++ if (nvbo->flags & NOUVEAU_BO_GART) ++ info->domain |= NOUVEAU_GEM_DOMAIN_GART; ++ if (!info->domain) { ++ info->domain |= (NOUVEAU_GEM_DOMAIN_VRAM | ++ NOUVEAU_GEM_DOMAIN_GART); ++ } ++ ++ if (nvbo->flags & NOUVEAU_BO_MAP) ++ info->domain |= NOUVEAU_GEM_DOMAIN_MAPPABLE; ++ ++ info->tile_mode = nvbo->base.tile_mode; ++ info->tile_flags = nvbo->base.tile_flags; ++ /* XXX - flag inverted for backwards compatibility */ ++ info->tile_flags ^= NOUVEAU_GEM_TILE_NONCONTIG; ++ if (!nvdev->has_bo_usage) ++ info->tile_flags &= NOUVEAU_GEM_TILE_LAYOUT_MASK; ++ ++ ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_GEM_NEW, ++ &req, sizeof(req)); ++ if (ret) ++ return ret; ++ ++ nouveau_bo_info(nvbo, &req.info); ++ return 0; ++} ++ ++static int ++nouveau_bo_kmap(struct nouveau_bo_priv *nvbo) ++{ ++ struct nouveau_device_priv *nvdev = nouveau_device(nvbo->base.device); ++ ++ if (nvbo->map) ++ return 0; ++ ++ if (!nvbo->map_handle) ++ return -EINVAL; ++ ++ nvbo->map = mmap(0, nvbo->size, PROT_READ | PROT_WRITE, ++ MAP_SHARED, nvdev->fd, nvbo->map_handle); ++ if (nvbo->map == MAP_FAILED) { ++ nvbo->map = NULL; ++ return -errno; ++ } ++ ++ return 0; ++} ++ ++int ++nouveau_bo_new_tile(struct nouveau_device *dev, uint32_t flags, int align, ++ int size, uint32_t tile_mode, uint32_t tile_flags, ++ struct nouveau_bo **bo) ++{ ++ struct nouveau_bo_priv *nvbo; ++ int ret; ++ ++ if (!dev || !bo || *bo) ++ return -EINVAL; ++ ++ nvbo = calloc(1, sizeof(struct nouveau_bo_priv)); ++ if (!nvbo) ++ return -ENOMEM; ++ nvbo->base.device = dev; ++ nvbo->base.size = size; ++ nvbo->base.tile_mode = tile_mode; ++ nvbo->base.tile_flags = tile_flags; ++ ++ nvbo->refcount = 1; ++ nvbo->flags = flags; ++ nvbo->size = size; ++ nvbo->align = align; ++ ++ if (flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)) { ++ ret = nouveau_bo_kalloc(nvbo, NULL); ++ if (ret) { ++ nouveau_bo_ref(NULL, (void *)&nvbo); ++ return ret; ++ } ++ } ++ ++ *bo = &nvbo->base; ++ return 0; ++} ++ ++int ++nouveau_bo_new(struct nouveau_device *dev, uint32_t flags, int align, ++ int size, struct nouveau_bo **bo) ++{ ++ return nouveau_bo_new_tile(dev, flags, align, size, 0, 0, bo); ++} ++ ++int ++nouveau_bo_user(struct nouveau_device *dev, void *ptr, int size, ++ struct nouveau_bo **bo) ++{ ++ struct nouveau_bo_priv *nvbo; ++ int ret; ++ ++ ret = nouveau_bo_new(dev, NOUVEAU_BO_MAP, 0, size, bo); ++ if (ret) ++ return ret; ++ nvbo = nouveau_bo(*bo); ++ ++ nvbo->sysmem = ptr; ++ nvbo->user = 1; ++ return 0; ++} ++ ++int ++nouveau_bo_wrap(struct nouveau_device *dev, uint32_t handle, ++ struct nouveau_bo **bo) ++{ ++ struct nouveau_device_priv *nvdev = nouveau_device(dev); ++ struct drm_nouveau_gem_info req; ++ struct nouveau_bo_priv *nvbo; ++ int ret; ++ ++ ret = nouveau_bo_new(dev, 0, 0, 0, bo); ++ if (ret) ++ return ret; ++ nvbo = nouveau_bo(*bo); ++ ++ req.handle = handle; ++ ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_GEM_INFO, ++ &req, sizeof(req)); ++ if (ret) { ++ nouveau_bo_ref(NULL, bo); ++ return ret; ++ } ++ ++ nouveau_bo_info(nvbo, &req); ++ nvbo->base.size = nvbo->size; ++ return 0; ++} ++ ++int ++nouveau_bo_handle_get(struct nouveau_bo *bo, uint32_t *handle) ++{ ++ struct nouveau_device_priv *nvdev = nouveau_device(bo->device); ++ struct nouveau_bo_priv *nvbo = nouveau_bo(bo); ++ int ret; ++ ++ if (!bo || !handle) ++ return -EINVAL; ++ ++ if (!nvbo->global_handle) { ++ struct drm_gem_flink req; ++ ++ ret = nouveau_bo_kalloc(nvbo, NULL); ++ if (ret) ++ return ret; ++ ++ req.handle = nvbo->handle; ++ ret = drmIoctl(nvdev->fd, DRM_IOCTL_GEM_FLINK, &req); ++ if (ret) { ++ nouveau_bo_kfree(nvbo); ++ return ret; ++ } ++ ++ nvbo->global_handle = req.name; ++ } ++ ++ *handle = nvbo->global_handle; ++ return 0; ++} ++ ++int ++nouveau_bo_handle_ref(struct nouveau_device *dev, uint32_t handle, ++ struct nouveau_bo **bo) ++{ ++ struct nouveau_device_priv *nvdev = nouveau_device(dev); ++ struct nouveau_bo_priv *nvbo; ++ struct drm_gem_open req; ++ int ret; ++ ++ req.name = handle; ++ ret = drmIoctl(nvdev->fd, DRM_IOCTL_GEM_OPEN, &req); ++ if (ret) { ++ nouveau_bo_ref(NULL, bo); ++ return ret; ++ } ++ ++ ret = nouveau_bo_wrap(dev, req.handle, bo); ++ if (ret) { ++ nouveau_bo_ref(NULL, bo); ++ return ret; ++ } ++ ++ nvbo = nouveau_bo(*bo); ++ nvbo->base.handle = nvbo->handle; ++ return 0; ++} ++ ++static void ++nouveau_bo_del(struct nouveau_bo **bo) ++{ ++ struct nouveau_bo_priv *nvbo; ++ ++ if (!bo || !*bo) ++ return; ++ nvbo = nouveau_bo(*bo); ++ *bo = NULL; ++ ++ if (--nvbo->refcount) ++ return; ++ ++ if (nvbo->pending) { ++ nvbo->pending = NULL; ++ nouveau_pushbuf_flush(nvbo->pending_channel, 0); ++ } ++ ++ nouveau_bo_ufree(nvbo); ++ nouveau_bo_kfree(nvbo); ++ free(nvbo); ++} ++ ++int ++nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pbo) ++{ ++ if (!pbo) ++ return -EINVAL; ++ ++ if (ref) ++ nouveau_bo(ref)->refcount++; ++ ++ if (*pbo) ++ nouveau_bo_del(pbo); ++ ++ *pbo = ref; ++ return 0; ++} ++ ++static int ++nouveau_bo_wait(struct nouveau_bo *bo, int cpu_write, int no_wait, int no_block) ++{ ++ struct nouveau_device_priv *nvdev = nouveau_device(bo->device); ++ struct nouveau_bo_priv *nvbo = nouveau_bo(bo); ++ struct drm_nouveau_gem_cpu_prep req; ++ int ret; ++ ++ if (!nvbo->global_handle && !nvbo->write_marker && !cpu_write) ++ return 0; ++ ++ if (nvbo->pending && ++ (nvbo->pending->write_domains || cpu_write)) { ++ nvbo->pending = NULL; ++ nouveau_pushbuf_flush(nvbo->pending_channel, 0); ++ } ++ ++ req.handle = nvbo->handle; ++ req.flags = 0; ++ if (cpu_write) ++ req.flags |= NOUVEAU_GEM_CPU_PREP_WRITE; ++ if (no_wait) ++ req.flags |= NOUVEAU_GEM_CPU_PREP_NOWAIT; ++ if (no_block) ++ req.flags |= NOUVEAU_GEM_CPU_PREP_NOBLOCK; ++ ++ do { ++ ret = drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GEM_CPU_PREP, ++ &req, sizeof(req)); ++ } while (ret == -EAGAIN); ++ if (ret) ++ return ret; ++ ++ if (ret == 0) ++ nvbo->write_marker = 0; ++ return 0; ++} ++ ++int ++nouveau_bo_map_range(struct nouveau_bo *bo, uint32_t delta, uint32_t size, ++ uint32_t flags) ++{ ++ struct nouveau_bo_priv *nvbo = nouveau_bo(bo); ++ int ret; ++ ++ if (!nvbo || bo->map) ++ return -EINVAL; ++ ++ if (!nouveau_bo_allocated(nvbo)) { ++ if (nvbo->flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)) { ++ ret = nouveau_bo_kalloc(nvbo, NULL); ++ if (ret) ++ return ret; ++ } ++ ++ if (!nouveau_bo_allocated(nvbo)) { ++ ret = nouveau_bo_ualloc(nvbo); ++ if (ret) ++ return ret; ++ } ++ } ++ ++ if (nvbo->sysmem) { ++ bo->map = (char *)nvbo->sysmem + delta; ++ } else { ++ ret = nouveau_bo_kmap(nvbo); ++ if (ret) ++ return ret; ++ ++ if (!(flags & NOUVEAU_BO_NOSYNC)) { ++ ret = nouveau_bo_wait(bo, (flags & NOUVEAU_BO_WR), ++ (flags & NOUVEAU_BO_NOWAIT), 0); ++ if (ret) ++ return ret; ++ ++ nvbo->map_refcnt++; ++ } ++ ++ bo->map = (char *)nvbo->map + delta; ++ } ++ ++ return 0; ++} ++ ++void ++nouveau_bo_map_flush(struct nouveau_bo *bo, uint32_t delta, uint32_t size) ++{ ++} ++ ++int ++nouveau_bo_map(struct nouveau_bo *bo, uint32_t flags) ++{ ++ return nouveau_bo_map_range(bo, 0, bo->size, flags); ++} ++ ++void ++nouveau_bo_unmap(struct nouveau_bo *bo) ++{ ++ struct nouveau_bo_priv *nvbo = nouveau_bo(bo); ++ ++ if (bo->map && !nvbo->sysmem && nvbo->map_refcnt) { ++ struct nouveau_device_priv *nvdev = nouveau_device(bo->device); ++ struct drm_nouveau_gem_cpu_fini req; ++ ++ req.handle = nvbo->handle; ++ drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GEM_CPU_FINI, ++ &req, sizeof(req)); ++ nvbo->map_refcnt--; ++ } ++ ++ bo->map = NULL; ++} ++ ++int ++nouveau_bo_busy(struct nouveau_bo *bo, uint32_t access) ++{ ++ return nouveau_bo_wait(bo, (access & NOUVEAU_BO_WR), 1, 1); ++} ++ ++uint32_t ++nouveau_bo_pending(struct nouveau_bo *bo) ++{ ++ struct nouveau_bo_priv *nvbo = nouveau_bo(bo); ++ uint32_t flags; ++ ++ if (!nvbo->pending) ++ return 0; ++ ++ flags = 0; ++ if (nvbo->pending->read_domains) ++ flags |= NOUVEAU_BO_RD; ++ if (nvbo->pending->write_domains) ++ flags |= NOUVEAU_BO_WR; ++ ++ return flags; ++} ++ ++struct drm_nouveau_gem_pushbuf_bo * ++nouveau_bo_emit_buffer(struct nouveau_channel *chan, struct nouveau_bo *bo) ++{ ++ struct nouveau_pushbuf_priv *nvpb = &nouveau_channel(chan)->pb; ++ struct nouveau_bo_priv *nvbo = nouveau_bo(bo); ++ struct drm_nouveau_gem_pushbuf_bo *pbbo; ++ struct nouveau_bo *ref = NULL; ++ int ret; ++ ++ if (nvbo->pending) ++ return nvbo->pending; ++ ++ if (!nvbo->handle) { ++ ret = nouveau_bo_kalloc(nvbo, chan); ++ if (ret) ++ return NULL; ++ ++ if (nvbo->sysmem) { ++ void *sysmem_tmp = nvbo->sysmem; ++ ++ nvbo->sysmem = NULL; ++ ret = nouveau_bo_map(bo, NOUVEAU_BO_WR); ++ if (ret) ++ return NULL; ++ nvbo->sysmem = sysmem_tmp; ++ ++ memcpy(bo->map, nvbo->sysmem, nvbo->base.size); ++ nouveau_bo_ufree(nvbo); ++ nouveau_bo_unmap(bo); ++ } ++ } ++ ++ if (nvpb->nr_buffers >= NOUVEAU_GEM_MAX_BUFFERS) ++ return NULL; ++ pbbo = nvpb->buffers + nvpb->nr_buffers++; ++ nvbo->pending = pbbo; ++ nvbo->pending_channel = chan; ++ nvbo->pending_refcnt = 0; ++ ++ nouveau_bo_ref(bo, &ref); ++ pbbo->user_priv = (uint64_t)(unsigned long)ref; ++ pbbo->handle = nvbo->handle; ++ pbbo->valid_domains = NOUVEAU_GEM_DOMAIN_VRAM | NOUVEAU_GEM_DOMAIN_GART; ++ pbbo->read_domains = 0; ++ pbbo->write_domains = 0; ++ pbbo->presumed.domain = nvbo->domain; ++ pbbo->presumed.offset = nvbo->offset; ++ pbbo->presumed.valid = 1; ++ return pbbo; ++} +diff --git a/nouveau-1/nouveau_bo.h b/nouveau-1/nouveau_bo.h +new file mode 100644 +index 0000000..3a1f2d4 +--- /dev/null ++++ b/nouveau-1/nouveau_bo.h +@@ -0,0 +1,104 @@ ++/* ++ * Copyright 2007 Nouveau Project ++ * ++ * 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 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 AUTHORS 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. ++ */ ++ ++#ifndef __NOUVEAU_BO_H__ ++#define __NOUVEAU_BO_H__ ++ ++/* Relocation/Buffer type flags */ ++#define NOUVEAU_BO_VRAM (1 << 0) ++#define NOUVEAU_BO_GART (1 << 1) ++#define NOUVEAU_BO_RD (1 << 2) ++#define NOUVEAU_BO_WR (1 << 3) ++#define NOUVEAU_BO_RDWR (NOUVEAU_BO_RD | NOUVEAU_BO_WR) ++#define NOUVEAU_BO_MAP (1 << 4) ++#define NOUVEAU_BO_LOW (1 << 6) ++#define NOUVEAU_BO_HIGH (1 << 7) ++#define NOUVEAU_BO_OR (1 << 8) ++#define NOUVEAU_BO_INVAL (1 << 12) ++#define NOUVEAU_BO_NOSYNC (1 << 13) ++#define NOUVEAU_BO_NOWAIT (1 << 14) ++#define NOUVEAU_BO_IFLUSH (1 << 15) ++#define NOUVEAU_BO_DUMMY (1 << 31) ++ ++#define NOUVEAU_BO_TILE_LAYOUT_MASK 0x0000ff00 ++#define NOUVEAU_BO_TILE_16BPP 0x00000001 ++#define NOUVEAU_BO_TILE_32BPP 0x00000002 ++#define NOUVEAU_BO_TILE_ZETA 0x00000004 ++#define NOUVEAU_BO_TILE_SCANOUT 0x00000008 ++ ++struct nouveau_bo { ++ struct nouveau_device *device; ++ uint32_t handle; ++ ++ uint64_t size; ++ void *map; ++ ++ uint32_t tile_mode; ++ uint32_t tile_flags; ++}; ++ ++int ++nouveau_bo_new(struct nouveau_device *, uint32_t flags, int align, int size, ++ struct nouveau_bo **); ++ ++int ++nouveau_bo_new_tile(struct nouveau_device *, uint32_t flags, int align, ++ int size, uint32_t tile_mode, uint32_t tile_flags, ++ struct nouveau_bo **); ++ ++int ++nouveau_bo_user(struct nouveau_device *, void *ptr, int size, ++ struct nouveau_bo **); ++ ++int ++nouveau_bo_wrap(struct nouveau_device *, uint32_t handle, struct nouveau_bo **); ++ ++int ++nouveau_bo_handle_get(struct nouveau_bo *, uint32_t *); ++ ++int ++nouveau_bo_handle_ref(struct nouveau_device *, uint32_t handle, ++ struct nouveau_bo **); ++ ++int ++nouveau_bo_ref(struct nouveau_bo *, struct nouveau_bo **); ++ ++int ++nouveau_bo_map_range(struct nouveau_bo *, uint32_t delta, uint32_t size, ++ uint32_t flags); ++ ++void ++nouveau_bo_map_flush(struct nouveau_bo *, uint32_t delta, uint32_t size); ++ ++int ++nouveau_bo_map(struct nouveau_bo *, uint32_t flags); ++ ++void ++nouveau_bo_unmap(struct nouveau_bo *); ++ ++int ++nouveau_bo_busy(struct nouveau_bo *, uint32_t access); ++ ++uint32_t ++nouveau_bo_pending(struct nouveau_bo *); ++ ++#endif +diff --git a/nouveau-1/nouveau_channel.c b/nouveau-1/nouveau_channel.c +new file mode 100644 +index 0000000..96fa03b +--- /dev/null ++++ b/nouveau-1/nouveau_channel.c +@@ -0,0 +1,142 @@ ++/* ++ * Copyright 2007 Nouveau Project ++ * ++ * 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 shall be included in ++ * all copies or substantial portions of the Software. ++ * -- 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/e1uuh7g-000360...@vasks.debian.org