.gitignore                              |    4 
 Makefile.am                             |    6 
 RELEASING                               |   26 
 amdgpu/amdgpu_gpu_info.c                |   20 
 configure.ac                            |   19 
 debian/changelog                        |   17 
 debian/control                          |   16 
 debian/libdrm-intel1.symbols            |    2 
 debian/libdrm2.symbols                  |    1 
 debian/rules                            |    4 
 etnaviv/Android.mk                      |   18 
 etnaviv/Makefile.am                     |   26 
 etnaviv/Makefile.sources                |   12 
 etnaviv/etnaviv-symbol-check            |   45 
 etnaviv/etnaviv_bo.c                    |  347 +++++++
 etnaviv/etnaviv_bo_cache.c              |  196 ++++
 etnaviv/etnaviv_cmd_stream.c            |  243 +++++
 etnaviv/etnaviv_device.c                |   96 ++
 etnaviv/etnaviv_drm.h                   |  233 ++++
 etnaviv/etnaviv_drmif.h                 |  188 ++++
 etnaviv/etnaviv_gpu.c                   |  175 +++
 etnaviv/etnaviv_pipe.c                  |   78 +
 etnaviv/etnaviv_priv.h                  |  199 ++++
 etnaviv/libdrm_etnaviv.pc.in            |   11 
 include/drm/amdgpu_drm.h                |   44 
 include/drm/i915_drm.h                  |    2 
 include/drm/radeon_drm.h                |   51 -
 intel/intel-symbol-check                |    2 
 intel/intel_bufmgr.h                    |    3 
 intel/intel_bufmgr_gem.c                |   30 
 radeon/radeon_surface.c                 |    8 
 tests/Makefile.am                       |    4 
 tests/amdgpu/vce_ib.h                   |    2 
 tests/etnaviv/Makefile.am               |   41 
 tests/etnaviv/cmdstream.xml.h           |  242 +++++
 tests/etnaviv/etnaviv_2d_test.c         |  240 +++++
 tests/etnaviv/etnaviv_bo_cache_test.c   |  121 ++
 tests/etnaviv/etnaviv_cmd_stream_test.c |  123 ++
 tests/etnaviv/state.xml.h               |  375 ++++++++
 tests/etnaviv/state_2d.xml.h            | 1497 ++++++++++++++++++++++++++++++++
 tests/etnaviv/write_bmp.c               |  151 +++
 tests/etnaviv/write_bmp.h               |   34 
 tests/modetest/modetest.c               |    5 
 tests/util/kms.c                        |    2 
 util_double_list.h                      |    2 
 xf86drmMode.c                           |   21 
 xf86drmMode.h                           |    7 
 47 files changed, 4917 insertions(+), 72 deletions(-)

New commits:
commit e868216a2c3fdd321ae2c61de8db6b83b942ce32
Author: Andreas Boll <andreas.boll....@gmail.com>
Date:   Wed Oct 12 14:19:21 2016 +0200

    Rebuild for jessie-backports.

diff --git a/debian/changelog b/debian/changelog
index 4b7f812..e659f77 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+libdrm (2.4.71-1~bpo8+1) jessie-backports; urgency=medium
+
+  * Rebuild for jessie-backports.
+
+ -- Andreas Boll <andreas.boll....@gmail.com>  Wed, 12 Oct 2016 14:18:58 +0200
+
 libdrm (2.4.71-1) unstable; urgency=medium
 
   * New upstream release.

commit a61442adb281ff2a021f1db19440ec1557bb47bd
Author: Andreas Boll <andreas.boll....@gmail.com>
Date:   Thu Oct 6 10:31:43 2016 +0200

    Upload to unstable.

diff --git a/debian/changelog b/debian/changelog
index 3fc04d9..5beb35b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-libdrm (2.4.71-1) UNRELEASED; urgency=medium
+libdrm (2.4.71-1) unstable; urgency=medium
 
   * New upstream release.
   * Update symbols file and bump shlibs for libdrm2.
@@ -7,7 +7,7 @@ libdrm (2.4.71-1) UNRELEASED; urgency=medium
     the past and won't be useful without the equivalent of the Linux
     Direct Rendering Manager (DRM) subsystem.
 
- -- Andreas Boll <andreas.boll....@gmail.com>  Thu, 08 Sep 2016 13:09:49 +0200
+ -- Andreas Boll <andreas.boll....@gmail.com>  Thu, 06 Oct 2016 10:31:27 +0200
 
 libdrm (2.4.70-1) unstable; urgency=medium
 

commit 3c087014f17a0f40862e3ea8b8b2a6eb3ac6606c
Author: Andreas Boll <andreas.boll....@gmail.com>
Date:   Thu Oct 6 10:10:21 2016 +0200

    Update libdrm-intel1.symbols and shlibs.

diff --git a/debian/changelog b/debian/changelog
index 85379d7..3fc04d9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ libdrm (2.4.71-1) UNRELEASED; urgency=medium
 
   * New upstream release.
   * Update symbols file and bump shlibs for libdrm2.
+  * Update libdrm-intel1.symbols and shlibs.
   * Remove Hurd from the architecture list. It FTBFS, haven't built in
     the past and won't be useful without the equivalent of the Linux
     Direct Rendering Manager (DRM) subsystem.
diff --git a/debian/libdrm-intel1.symbols b/debian/libdrm-intel1.symbols
index 23795a2..cf08516 100644
--- a/debian/libdrm-intel1.symbols
+++ b/debian/libdrm-intel1.symbols
@@ -68,7 +68,9 @@ libdrm_intel.so.1 libdrm-intel1 #MINVER#
  drm_intel_gem_context_destroy@Base 2.4.37
  drm_intel_get_aperture_sizes@Base 2.4.26
  drm_intel_get_eu_total@Base 2.4.60
+ drm_intel_get_min_eu_in_pool@Base 2.4.71
  drm_intel_get_pipe_from_crtc_id@Base 2.4.11
+ drm_intel_get_pooled_eu@Base 2.4.71
  drm_intel_get_reset_stats@Base 2.4.48
  drm_intel_get_subslice_total@Base 2.4.60
  drm_intel_reg_read@Base 2.4.38
diff --git a/debian/rules b/debian/rules
index 4acebc8..d0c6eb0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -116,7 +116,7 @@ endif
 override_dh_makeshlibs:
        dh_makeshlibs -plibdrm2 -V'libdrm2 (>= 2.4.71)' --add-udeb=libdrm2-udeb 
-- -c4
 ifeq ($(INTEL), yes)
-       dh_makeshlibs -plibdrm-intel1 -V'libdrm-intel1 (>= 2.4.66)' -- -c4
+       dh_makeshlibs -plibdrm-intel1 -V'libdrm-intel1 (>= 2.4.71)' -- -c4
 endif
 ifeq ($(NOUVEAU), yes)
        dh_makeshlibs -plibdrm-nouveau2 -V'libdrm-nouveau2 (>= 2.4.66)' -- -c4

commit 7d22f61c54da08eab31a33568573dce7d47a56d6
Author: Andreas Boll <andreas.boll....@gmail.com>
Date:   Thu Oct 6 09:58:29 2016 +0200

    Update symbols file and bump shlibs for libdrm2.

diff --git a/debian/changelog b/debian/changelog
index 240dfe6..85379d7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 libdrm (2.4.71-1) UNRELEASED; urgency=medium
 
   * New upstream release.
+  * Update symbols file and bump shlibs for libdrm2.
   * Remove Hurd from the architecture list. It FTBFS, haven't built in
     the past and won't be useful without the equivalent of the Linux
     Direct Rendering Manager (DRM) subsystem.
diff --git a/debian/libdrm2.symbols b/debian/libdrm2.symbols
index 25cf4ba..60899af 100644
--- a/debian/libdrm2.symbols
+++ b/debian/libdrm2.symbols
@@ -83,6 +83,7 @@ libdrm.so.2 libdrm2 #MINVER#
  drmMapBufs@Base 2.3.1
  drmMarkBufs@Base 2.3.1
  drmModeAddFB2@Base 2.4.30
+ drmModeAddFB2WithModifiers@Base 2.4.71
  drmModeAddFB@Base 2.4.3
  drmModeAtomicAddProperty@Base 2.4.62
  drmModeAtomicAlloc@Base 2.4.62
diff --git a/debian/rules b/debian/rules
index b107ea1..4acebc8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -114,7 +114,7 @@ endif
        dh_strip -s --remaining-packages
 
 override_dh_makeshlibs:
-       dh_makeshlibs -plibdrm2 -V'libdrm2 (>= 2.4.66)' --add-udeb=libdrm2-udeb 
-- -c4
+       dh_makeshlibs -plibdrm2 -V'libdrm2 (>= 2.4.71)' --add-udeb=libdrm2-udeb 
-- -c4
 ifeq ($(INTEL), yes)
        dh_makeshlibs -plibdrm-intel1 -V'libdrm-intel1 (>= 2.4.66)' -- -c4
 endif

commit eaa30491b00ee08794eab4a4af5ddd77560ffc94
Author: Andreas Boll <andreas.boll....@gmail.com>
Date:   Thu Oct 6 09:40:04 2016 +0200

    Bump changelog.

diff --git a/debian/changelog b/debian/changelog
index c44b82d..240dfe6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,6 @@
-libdrm (2.4.70-2) UNRELEASED; urgency=medium
+libdrm (2.4.71-1) UNRELEASED; urgency=medium
 
+  * New upstream release.
   * Remove Hurd from the architecture list. It FTBFS, haven't built in
     the past and won't be useful without the equivalent of the Linux
     Direct Rendering Manager (DRM) subsystem.

commit a44c9c31b7b38b3eedf3d26648f9e68dcc377c4c
Author: Rob Clark <robcl...@freedesktop.org>
Date:   Mon Oct 3 20:46:19 2016 -0400

    Bump version for release
    
    Signed-off-by: Rob Clark <robcl...@freedesktop.org>

diff --git a/configure.ac b/configure.ac
index 330358a..ac6b106 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@
 
 AC_PREREQ([2.63])
 AC_INIT([libdrm],
-        [2.4.70],
+        [2.4.71],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI],
         [libdrm])
 

commit 207efb16ea9465c4a38840efab1bbe65e6cf5c3d
Author: Leo Liu <leo....@amd.com>
Date:   Fri Sep 30 13:20:55 2016 -0400

    tests/amdgpu: update vce encRefPic addr mode to tiled
    
    Adapt to recent firmware update, it's also compatible with previous
    firmware version
    
    Signed-off-by: Leo Liu <leo....@amd.com>
    Reviewed-by: Christian K├Ânig <christian.koe...@amd.com>

diff --git a/tests/amdgpu/vce_ib.h b/tests/amdgpu/vce_ib.h
index bd0bf94..80ab179 100644
--- a/tests/amdgpu/vce_ib.h
+++ b/tests/amdgpu/vce_ib.h
@@ -53,7 +53,7 @@ static const uint32_t vce_create[] = {
        0x000000a0,
        0x000000a0,
        0x00000010,
-       0x00000000,
+       0x00000201,
 };
 
 static const uint32_t vce_rate_ctrl[] = {

commit abfa680dbdfa4600105d904f4903c047d453cdb5
Author: Kristian H. Kristensen <hoegsb...@chromium.org>
Date:   Thu Sep 8 13:08:59 2016 -0700

    Add drmModeAddFB2WithModifiers() which takes format modifiers
    
    The only other user of this feature open codes the ioctl. Let's add an
    entry point for this to libdrm.
    
    Signed-off-by: Kristian H. Kristensen <hoegsb...@chromium.org>
    Reviewed-by: Rob Clark <robdcl...@gmail.com>

diff --git a/xf86drmMode.c b/xf86drmMode.c
index f7b5948..228c6e4 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -270,10 +270,10 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, 
uint8_t depth,
        return 0;
 }
 
-int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
-                 uint32_t pixel_format, uint32_t bo_handles[4],
-                 uint32_t pitches[4], uint32_t offsets[4],
-                 uint32_t *buf_id, uint32_t flags)
+int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
+                               uint32_t pixel_format, uint32_t bo_handles[4],
+                               uint32_t pitches[4], uint32_t offsets[4],
+                               uint64_t modifier[4], uint32_t *buf_id, 
uint32_t flags)
 {
        struct drm_mode_fb_cmd2 f;
        int ret;
@@ -286,6 +286,8 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
        memcpy(f.handles, bo_handles, 4 * sizeof(bo_handles[0]));
        memcpy(f.pitches, pitches, 4 * sizeof(pitches[0]));
        memcpy(f.offsets, offsets, 4 * sizeof(offsets[0]));
+       if (modifier)
+               memcpy(f.modifier, modifier, 4 * sizeof(modifier[0]));
 
        if ((ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_ADDFB2, &f)))
                return ret;
@@ -294,6 +296,17 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
        return 0;
 }
 
+int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
+                  uint32_t pixel_format, uint32_t bo_handles[4],
+                  uint32_t pitches[4], uint32_t offsets[4],
+                  uint32_t *buf_id, uint32_t flags)
+{
+       return drmModeAddFB2WithModifiers(fd, width, height,
+                                         pixel_format, bo_handles,
+                                         pitches, offsets, NULL,
+                                         buf_id, flags);
+}
+
 int drmModeRmFB(int fd, uint32_t bufferId)
 {
        return DRM_IOCTL(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
diff --git a/xf86drmMode.h b/xf86drmMode.h
index 4de7bbb..1a02fed 100644
--- a/xf86drmMode.h
+++ b/xf86drmMode.h
@@ -369,6 +369,13 @@ extern int drmModeAddFB2(int fd, uint32_t width, uint32_t 
height,
                         uint32_t pixel_format, uint32_t bo_handles[4],
                         uint32_t pitches[4], uint32_t offsets[4],
                         uint32_t *buf_id, uint32_t flags);
+
+/* ...with format modifiers */
+int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
+                              uint32_t pixel_format, uint32_t bo_handles[4],
+                              uint32_t pitches[4], uint32_t offsets[4],
+                              uint64_t modifier[4], uint32_t *buf_id, uint32_t 
flags);
+
 /**
  * Destroies the given framebuffer.
  */

commit 0659558f6418693ad203b5de2f1bc4fa9f28708e
Author: The etnaviv authors <dri-de...@lists.freedesktop.org>
Date:   Tue Sep 6 18:16:02 2016 +0200

    libdrm: add etnaviv tests
    
    This adds the following basic unit tests:
    
    - etnaviv_2d_test
      Let the 2D core render a defined pattern into a bo
      and store it as bmp.
    
    - etnaviv_bo_cache_test
      Basic tests to validate the bo-cache behavior.
    
    - etnaviv_cmd_stream_test
      Tests for the etna_cmd_stream API.
    
    Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
    Signed-off-by: Lucas Stach <l.st...@pengutronix.de>

diff --git a/.gitignore b/.gitignore
index 3226b3a..d51e619 100644
--- a/.gitignore
+++ b/.gitignore
@@ -102,4 +102,7 @@ tests/radeon/radeon_ttm
 tests/exynos/exynos_fimg2d_event
 tests/exynos/exynos_fimg2d_perf
 tests/exynos/exynos_fimg2d_test
+tests/etnaviv/etnaviv_2d_test
+tests/etnaviv/etnaviv_cmd_stream_test
+tests/etnaviv/etnaviv_bo_cache_test
 man/*.3
diff --git a/configure.ac b/configure.ac
index 64f3e6c..330358a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -551,6 +551,7 @@ AC_CONFIG_FILES([
        tests/exynos/Makefile
        tests/tegra/Makefile
        tests/nouveau/Makefile
+       tests/etnaviv/Makefile
        tests/util/Makefile
        man/Makefile
        libdrm.pc])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 58feb12..4a499e4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -22,6 +22,10 @@ if HAVE_TEGRA
 SUBDIRS += tegra
 endif
 
+if HAVE_ETNAVIV
+SUBDIRS += etnaviv
+endif
+
 AM_CFLAGS = \
        $(WARN_CFLAGS)\
        -I $(top_srcdir)/include/drm \
diff --git a/tests/etnaviv/Makefile.am b/tests/etnaviv/Makefile.am
new file mode 100644
index 0000000..0631864
--- /dev/null
+++ b/tests/etnaviv/Makefile.am
@@ -0,0 +1,41 @@
+AM_CFLAGS = \
+       -I $(top_srcdir)/include/drm \
+       -I $(top_srcdir)/etnaviv \
+       -I $(top_srcdir)
+
+if HAVE_INSTALL_TESTS
+bin_PROGRAMS = \
+       etnaviv_2d_test \
+       etnaviv_cmd_stream_test \
+       etnaviv_bo_cache_test
+else
+noinst_PROGRAMS = \
+       etnaviv_2d_test \
+       etnaviv_cmd_stream_test \
+       etnaviv_bo_cache_test
+endif
+
+etnaviv_2d_test_LDADD = \
+       $(top_builddir)/libdrm.la \
+       $(top_builddir)/etnaviv/libdrm_etnaviv.la
+
+etnaviv_2d_test_SOURCES = \
+       cmdstream.xml.h \
+       etnaviv_2d_test.c \
+       state.xml.h \
+       state_2d.xml.h \
+       write_bmp.c \
+       write_bmp.h
+
+etnaviv_cmd_stream_test_LDADD = \
+       $(top_builddir)/etnaviv/libdrm_etnaviv.la
+
+etnaviv_cmd_stream_test_SOURCES = \
+       etnaviv_cmd_stream_test.c
+
+etnaviv_bo_cache_test_LDADD = \
+       $(top_builddir)/libdrm.la \
+       $(top_builddir)/etnaviv/libdrm_etnaviv.la
+
+etnaviv_bo_cache_test_SOURCES = \
+       etnaviv_bo_cache_test.c
diff --git a/tests/etnaviv/cmdstream.xml.h b/tests/etnaviv/cmdstream.xml.h
new file mode 100644
index 0000000..109285c
--- /dev/null
+++ b/tests/etnaviv/cmdstream.xml.h
@@ -0,0 +1,242 @@
+#ifndef CMDSTREAM_XML
+#define CMDSTREAM_XML
+
+/* Autogenerated file, DO NOT EDIT manually!
+
+This file was generated by the rules-ng-ng headergen tool in this git 
repository:
+http://0x04.net/cgit/index.cgi/rules-ng-ng
+git clone git://0x04.net/rules-ng-ng
+
+The rules-ng-ng source files this header was generated from are:
+- cmdstream.xml (  12621 bytes, from 2016-09-06 14:44:16)
+- copyright.xml (   1597 bytes, from 2016-09-06 14:44:16)
+- common.xml    (  20583 bytes, from 2016-09-06 14:14:12)
+
+Copyright (C) 2012-2016 by the following authors:
+- Wladimir J. van der Laan <laa...@gmail.com>
+- Christian Gmeiner <christian.gmei...@gmail.com>
+- Lucas Stach <l.st...@pengutronix.de>
+- Russell King <r...@arm.linux.org.uk>
+
+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 AUTHORS OR COPYRIGHT HOLDERS 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 FE_OPCODE_LOAD_STATE                                   0x00000001
+#define FE_OPCODE_END                                          0x00000002
+#define FE_OPCODE_NOP                                          0x00000003
+#define FE_OPCODE_DRAW_2D                                      0x00000004
+#define FE_OPCODE_DRAW_PRIMITIVES                              0x00000005
+#define FE_OPCODE_DRAW_INDEXED_PRIMITIVES                      0x00000006
+#define FE_OPCODE_WAIT                                         0x00000007
+#define FE_OPCODE_LINK                                         0x00000008
+#define FE_OPCODE_STALL                                                
0x00000009
+#define FE_OPCODE_CALL                                         0x0000000a
+#define FE_OPCODE_RETURN                                       0x0000000b
+#define FE_OPCODE_CHIP_SELECT                                  0x0000000d
+#define PRIMITIVE_TYPE_POINTS                                  0x00000001
+#define PRIMITIVE_TYPE_LINES                                   0x00000002
+#define PRIMITIVE_TYPE_LINE_STRIP                              0x00000003
+#define PRIMITIVE_TYPE_TRIANGLES                               0x00000004
+#define PRIMITIVE_TYPE_TRIANGLE_STRIP                          0x00000005
+#define PRIMITIVE_TYPE_TRIANGLE_FAN                            0x00000006
+#define PRIMITIVE_TYPE_LINE_LOOP                               0x00000007
+#define PRIMITIVE_TYPE_QUADS                                   0x00000008
+#define VIV_FE_LOAD_STATE                                      0x00000000
+
+#define VIV_FE_LOAD_STATE_HEADER                               0x00000000
+#define VIV_FE_LOAD_STATE_HEADER_OP__MASK                      0xf8000000
+#define VIV_FE_LOAD_STATE_HEADER_OP__SHIFT                     27
+#define VIV_FE_LOAD_STATE_HEADER_OP_LOAD_STATE                 0x08000000
+#define VIV_FE_LOAD_STATE_HEADER_FIXP                          0x04000000
+#define VIV_FE_LOAD_STATE_HEADER_COUNT__MASK                   0x03ff0000
+#define VIV_FE_LOAD_STATE_HEADER_COUNT__SHIFT                  16
+#define VIV_FE_LOAD_STATE_HEADER_COUNT(x)                      (((x) << 
VIV_FE_LOAD_STATE_HEADER_COUNT__SHIFT) & VIV_FE_LOAD_STATE_HEADER_COUNT__MASK)
+#define VIV_FE_LOAD_STATE_HEADER_OFFSET__MASK                  0x0000ffff
+#define VIV_FE_LOAD_STATE_HEADER_OFFSET__SHIFT                 0
+#define VIV_FE_LOAD_STATE_HEADER_OFFSET(x)                     (((x) << 
VIV_FE_LOAD_STATE_HEADER_OFFSET__SHIFT) & VIV_FE_LOAD_STATE_HEADER_OFFSET__MASK)
+#define VIV_FE_LOAD_STATE_HEADER_OFFSET__SHR                   2
+
+#define VIV_FE_END                                             0x00000000
+
+#define VIV_FE_END_HEADER                                      0x00000000
+#define VIV_FE_END_HEADER_EVENT_ID__MASK                       0x0000001f
+#define VIV_FE_END_HEADER_EVENT_ID__SHIFT                      0
+#define VIV_FE_END_HEADER_EVENT_ID(x)                          (((x) << 
VIV_FE_END_HEADER_EVENT_ID__SHIFT) & VIV_FE_END_HEADER_EVENT_ID__MASK)
+#define VIV_FE_END_HEADER_EVENT_ENABLE                         0x00000100
+#define VIV_FE_END_HEADER_OP__MASK                             0xf8000000
+#define VIV_FE_END_HEADER_OP__SHIFT                            27
+#define VIV_FE_END_HEADER_OP_END                               0x10000000
+
+#define VIV_FE_NOP                                             0x00000000
+
+#define VIV_FE_NOP_HEADER                                      0x00000000
+#define VIV_FE_NOP_HEADER_OP__MASK                             0xf8000000
+#define VIV_FE_NOP_HEADER_OP__SHIFT                            27
+#define VIV_FE_NOP_HEADER_OP_NOP                               0x18000000
+
+#define VIV_FE_DRAW_2D                                         0x00000000
+
+#define VIV_FE_DRAW_2D_HEADER                                  0x00000000
+#define VIV_FE_DRAW_2D_HEADER_COUNT__MASK                      0x0000ff00
+#define VIV_FE_DRAW_2D_HEADER_COUNT__SHIFT                     8
+#define VIV_FE_DRAW_2D_HEADER_COUNT(x)                         (((x) << 
VIV_FE_DRAW_2D_HEADER_COUNT__SHIFT) & VIV_FE_DRAW_2D_HEADER_COUNT__MASK)
+#define VIV_FE_DRAW_2D_HEADER_DATA_COUNT__MASK                 0x07ff0000
+#define VIV_FE_DRAW_2D_HEADER_DATA_COUNT__SHIFT                        16
+#define VIV_FE_DRAW_2D_HEADER_DATA_COUNT(x)                    (((x) << 
VIV_FE_DRAW_2D_HEADER_DATA_COUNT__SHIFT) & 
VIV_FE_DRAW_2D_HEADER_DATA_COUNT__MASK)
+#define VIV_FE_DRAW_2D_HEADER_OP__MASK                         0xf8000000
+#define VIV_FE_DRAW_2D_HEADER_OP__SHIFT                                27
+#define VIV_FE_DRAW_2D_HEADER_OP_DRAW_2D                       0x20000000
+
+#define VIV_FE_DRAW_2D_TOP_LEFT                                        
0x00000008
+#define VIV_FE_DRAW_2D_TOP_LEFT_X__MASK                                
0x0000ffff
+#define VIV_FE_DRAW_2D_TOP_LEFT_X__SHIFT                       0
+#define VIV_FE_DRAW_2D_TOP_LEFT_X(x)                           (((x) << 
VIV_FE_DRAW_2D_TOP_LEFT_X__SHIFT) & VIV_FE_DRAW_2D_TOP_LEFT_X__MASK)
+#define VIV_FE_DRAW_2D_TOP_LEFT_Y__MASK                                
0xffff0000
+#define VIV_FE_DRAW_2D_TOP_LEFT_Y__SHIFT                       16
+#define VIV_FE_DRAW_2D_TOP_LEFT_Y(x)                           (((x) << 
VIV_FE_DRAW_2D_TOP_LEFT_Y__SHIFT) & VIV_FE_DRAW_2D_TOP_LEFT_Y__MASK)
+
+#define VIV_FE_DRAW_2D_BOTTOM_RIGHT                            0x0000000c
+#define VIV_FE_DRAW_2D_BOTTOM_RIGHT_X__MASK                    0x0000ffff
+#define VIV_FE_DRAW_2D_BOTTOM_RIGHT_X__SHIFT                   0
+#define VIV_FE_DRAW_2D_BOTTOM_RIGHT_X(x)                       (((x) << 
VIV_FE_DRAW_2D_BOTTOM_RIGHT_X__SHIFT) & VIV_FE_DRAW_2D_BOTTOM_RIGHT_X__MASK)
+#define VIV_FE_DRAW_2D_BOTTOM_RIGHT_Y__MASK                    0xffff0000
+#define VIV_FE_DRAW_2D_BOTTOM_RIGHT_Y__SHIFT                   16
+#define VIV_FE_DRAW_2D_BOTTOM_RIGHT_Y(x)                       (((x) << 
VIV_FE_DRAW_2D_BOTTOM_RIGHT_Y__SHIFT) & VIV_FE_DRAW_2D_BOTTOM_RIGHT_Y__MASK)
+
+#define VIV_FE_DRAW_PRIMITIVES                                 0x00000000
+
+#define VIV_FE_DRAW_PRIMITIVES_HEADER                          0x00000000
+#define VIV_FE_DRAW_PRIMITIVES_HEADER_OP__MASK                 0xf8000000
+#define VIV_FE_DRAW_PRIMITIVES_HEADER_OP__SHIFT                        27
+#define VIV_FE_DRAW_PRIMITIVES_HEADER_OP_DRAW_PRIMITIVES       0x28000000
+
+#define VIV_FE_DRAW_PRIMITIVES_COMMAND                         0x00000004
+#define VIV_FE_DRAW_PRIMITIVES_COMMAND_TYPE__MASK              0x000000ff
+#define VIV_FE_DRAW_PRIMITIVES_COMMAND_TYPE__SHIFT             0
+#define VIV_FE_DRAW_PRIMITIVES_COMMAND_TYPE(x)                 (((x) << 
VIV_FE_DRAW_PRIMITIVES_COMMAND_TYPE__SHIFT) & 
VIV_FE_DRAW_PRIMITIVES_COMMAND_TYPE__MASK)
+
+#define VIV_FE_DRAW_PRIMITIVES_START                           0x00000008
+
+#define VIV_FE_DRAW_PRIMITIVES_COUNT                           0x0000000c
+
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES                         0x00000000
+
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES_HEADER                  0x00000000
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES_HEADER_OP__MASK         0xf8000000
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES_HEADER_OP__SHIFT                27
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES_HEADER_OP_DRAW_INDEXED_PRIMITIVES       
0x30000000
+
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES_COMMAND                 0x00000004
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES_COMMAND_TYPE__MASK      0x000000ff
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES_COMMAND_TYPE__SHIFT     0
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES_COMMAND_TYPE(x)         (((x) << 
VIV_FE_DRAW_INDEXED_PRIMITIVES_COMMAND_TYPE__SHIFT) & 
VIV_FE_DRAW_INDEXED_PRIMITIVES_COMMAND_TYPE__MASK)
+
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES_START                   0x00000008
+
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES_COUNT                   0x0000000c
+
+#define VIV_FE_DRAW_INDEXED_PRIMITIVES_OFFSET                  0x00000010
+
+#define VIV_FE_WAIT                                            0x00000000
+
+#define VIV_FE_WAIT_HEADER                                     0x00000000
+#define VIV_FE_WAIT_HEADER_DELAY__MASK                         0x0000ffff
+#define VIV_FE_WAIT_HEADER_DELAY__SHIFT                                0
+#define VIV_FE_WAIT_HEADER_DELAY(x)                            (((x) << 
VIV_FE_WAIT_HEADER_DELAY__SHIFT) & VIV_FE_WAIT_HEADER_DELAY__MASK)
+#define VIV_FE_WAIT_HEADER_OP__MASK                            0xf8000000
+#define VIV_FE_WAIT_HEADER_OP__SHIFT                           27
+#define VIV_FE_WAIT_HEADER_OP_WAIT                             0x38000000
+
+#define VIV_FE_LINK                                            0x00000000
+
+#define VIV_FE_LINK_HEADER                                     0x00000000
+#define VIV_FE_LINK_HEADER_PREFETCH__MASK                      0x0000ffff
+#define VIV_FE_LINK_HEADER_PREFETCH__SHIFT                     0
+#define VIV_FE_LINK_HEADER_PREFETCH(x)                         (((x) << 
VIV_FE_LINK_HEADER_PREFETCH__SHIFT) & VIV_FE_LINK_HEADER_PREFETCH__MASK)
+#define VIV_FE_LINK_HEADER_OP__MASK                            0xf8000000
+#define VIV_FE_LINK_HEADER_OP__SHIFT                           27
+#define VIV_FE_LINK_HEADER_OP_LINK                             0x40000000
+
+#define VIV_FE_LINK_ADDRESS                                    0x00000004
+
+#define VIV_FE_STALL                                           0x00000000
+
+#define VIV_FE_STALL_HEADER                                    0x00000000
+#define VIV_FE_STALL_HEADER_OP__MASK                           0xf8000000
+#define VIV_FE_STALL_HEADER_OP__SHIFT                          27
+#define VIV_FE_STALL_HEADER_OP_STALL                           0x48000000
+
+#define VIV_FE_STALL_TOKEN                                     0x00000004
+#define VIV_FE_STALL_TOKEN_FROM__MASK                          0x0000001f
+#define VIV_FE_STALL_TOKEN_FROM__SHIFT                         0
+#define VIV_FE_STALL_TOKEN_FROM(x)                             (((x) << 
VIV_FE_STALL_TOKEN_FROM__SHIFT) & VIV_FE_STALL_TOKEN_FROM__MASK)
+#define VIV_FE_STALL_TOKEN_TO__MASK                            0x00001f00
+#define VIV_FE_STALL_TOKEN_TO__SHIFT                           8
+#define VIV_FE_STALL_TOKEN_TO(x)                               (((x) << 
VIV_FE_STALL_TOKEN_TO__SHIFT) & VIV_FE_STALL_TOKEN_TO__MASK)
+
+#define VIV_FE_CALL                                            0x00000000
+
+#define VIV_FE_CALL_HEADER                                     0x00000000
+#define VIV_FE_CALL_HEADER_PREFETCH__MASK                      0x0000ffff
+#define VIV_FE_CALL_HEADER_PREFETCH__SHIFT                     0
+#define VIV_FE_CALL_HEADER_PREFETCH(x)                         (((x) << 
VIV_FE_CALL_HEADER_PREFETCH__SHIFT) & VIV_FE_CALL_HEADER_PREFETCH__MASK)
+#define VIV_FE_CALL_HEADER_OP__MASK                            0xf8000000
+#define VIV_FE_CALL_HEADER_OP__SHIFT                           27
+#define VIV_FE_CALL_HEADER_OP_CALL                             0x50000000
+
+#define VIV_FE_CALL_ADDRESS                                    0x00000004
+
+#define VIV_FE_CALL_RETURN_PREFETCH                            0x00000008
+
+#define VIV_FE_CALL_RETURN_ADDRESS                             0x0000000c
+
+#define VIV_FE_RETURN                                          0x00000000
+
+#define VIV_FE_RETURN_HEADER                                   0x00000000
+#define VIV_FE_RETURN_HEADER_OP__MASK                          0xf8000000
+#define VIV_FE_RETURN_HEADER_OP__SHIFT                         27
+#define VIV_FE_RETURN_HEADER_OP_RETURN                         0x58000000
+
+#define VIV_FE_CHIP_SELECT                                     0x00000000
+
+#define VIV_FE_CHIP_SELECT_HEADER                              0x00000000
+#define VIV_FE_CHIP_SELECT_HEADER_OP__MASK                     0xf8000000
+#define VIV_FE_CHIP_SELECT_HEADER_OP__SHIFT                    27
+#define VIV_FE_CHIP_SELECT_HEADER_OP_CHIP_SELECT               0x68000000
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP15                        
0x00008000
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP14                        
0x00004000
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP13                        
0x00002000
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP12                        
0x00001000
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP11                        
0x00000800
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP10                        
0x00000400
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP9                 0x00000200
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP8                 0x00000100
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP7                 0x00000080
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP6                 0x00000040
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP5                 0x00000020
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP4                 0x00000010
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP3                 0x00000008
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP2                 0x00000004
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP1                 0x00000002
+#define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP0                 0x00000001
+
+
+#endif /* CMDSTREAM_XML */
diff --git a/tests/etnaviv/etnaviv_2d_test.c b/tests/etnaviv/etnaviv_2d_test.c
new file mode 100644
index 0000000..10751c7
--- /dev/null
+++ b/tests/etnaviv/etnaviv_2d_test.c
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2014-2015 Etnaviv 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
+ * SOFTWARE.
+ *
+ * Authors:
+ *    Christian Gmeiner <christian.gmei...@gmail.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "xf86drm.h"
+#include "etnaviv_drmif.h"
+#include "etnaviv_drm.h"
+
+#include "state.xml.h"
+#include "state_2d.xml.h"
+#include "cmdstream.xml.h"
+
+#include "write_bmp.h"
+
+static inline void etna_emit_load_state(struct etna_cmd_stream *stream,
+               const uint16_t offset, const uint16_t count)
+{
+       uint32_t v;
+
+       v =     (VIV_FE_LOAD_STATE_HEADER_OP_LOAD_STATE | 
VIV_FE_LOAD_STATE_HEADER_OFFSET(offset) |
+                       (VIV_FE_LOAD_STATE_HEADER_COUNT(count) & 
VIV_FE_LOAD_STATE_HEADER_COUNT__MASK));
+
+       etna_cmd_stream_emit(stream, v);
+}
+
+static inline void etna_set_state(struct etna_cmd_stream *stream, uint32_t 
address, uint32_t value)
+{
+       etna_cmd_stream_reserve(stream, 2);
+       etna_emit_load_state(stream, address >> 2, 1);
+       etna_cmd_stream_emit(stream, value);
+}
+
+static inline void etna_set_state_from_bo(struct etna_cmd_stream *stream,
+               uint32_t address, struct etna_bo *bo)
+{
+       etna_cmd_stream_reserve(stream, 2);
+       etna_emit_load_state(stream, address >> 2, 1);
+
+       etna_cmd_stream_reloc(stream, &(struct etna_reloc){
+               .bo = bo,
+               .flags = ETNA_RELOC_READ,
+               .offset = 0,
+       });
+}
+
+static void gen_cmd_stream(struct etna_cmd_stream *stream, struct etna_bo 
*bmp, const int width, const int height)
+{
+       int rec;
+       static int num_rects = 256;
+
+       etna_set_state(stream, VIVS_DE_SRC_STRIDE, 0);
+       etna_set_state(stream, VIVS_DE_SRC_ROTATION_CONFIG, 0);
+       etna_set_state(stream, VIVS_DE_SRC_CONFIG, 0);
+       etna_set_state(stream, VIVS_DE_SRC_ORIGIN, 0);
+       etna_set_state(stream, VIVS_DE_SRC_SIZE, 0);
+       etna_set_state(stream, VIVS_DE_SRC_COLOR_BG, 0);
+       etna_set_state(stream, VIVS_DE_SRC_COLOR_FG, 0);
+       etna_set_state(stream, VIVS_DE_STRETCH_FACTOR_LOW, 0);
+       etna_set_state(stream, VIVS_DE_STRETCH_FACTOR_HIGH, 0);
+       etna_set_state_from_bo(stream, VIVS_DE_DEST_ADDRESS, bmp);
+       etna_set_state(stream, VIVS_DE_DEST_STRIDE, width*4);
+       etna_set_state(stream, VIVS_DE_DEST_ROTATION_CONFIG, 0);
+       etna_set_state(stream, VIVS_DE_DEST_CONFIG,
+                       VIVS_DE_DEST_CONFIG_FORMAT(DE_FORMAT_A8R8G8B8) |
+                       VIVS_DE_DEST_CONFIG_COMMAND_CLEAR |
+                       VIVS_DE_DEST_CONFIG_SWIZZLE(DE_SWIZZLE_ARGB) |
+                       VIVS_DE_DEST_CONFIG_TILED_DISABLE |
+                       VIVS_DE_DEST_CONFIG_MINOR_TILED_DISABLE
+                       );
+       etna_set_state(stream, VIVS_DE_ROP,
+                       VIVS_DE_ROP_ROP_FG(0xcc) | VIVS_DE_ROP_ROP_BG(0xcc) | 
VIVS_DE_ROP_TYPE_ROP4);
+       etna_set_state(stream, VIVS_DE_CLIP_TOP_LEFT,
+                       VIVS_DE_CLIP_TOP_LEFT_X(0) |
+                       VIVS_DE_CLIP_TOP_LEFT_Y(0)
+                       );
+       etna_set_state(stream, VIVS_DE_CLIP_BOTTOM_RIGHT,
+                       VIVS_DE_CLIP_BOTTOM_RIGHT_X(width) |
+                       VIVS_DE_CLIP_BOTTOM_RIGHT_Y(height)
+                       );
+       etna_set_state(stream, VIVS_DE_CONFIG, 0); /* TODO */
+       etna_set_state(stream, VIVS_DE_SRC_ORIGIN_FRACTION, 0);
+       etna_set_state(stream, VIVS_DE_ALPHA_CONTROL, 0);
+       etna_set_state(stream, VIVS_DE_ALPHA_MODES, 0);
+       etna_set_state(stream, VIVS_DE_DEST_ROTATION_HEIGHT, 0);
+       etna_set_state(stream, VIVS_DE_SRC_ROTATION_HEIGHT, 0);
+       etna_set_state(stream, VIVS_DE_ROT_ANGLE, 0);
+
+       /* Clear color PE20 */
+       etna_set_state(stream, VIVS_DE_CLEAR_PIXEL_VALUE32, 0xff40ff40);
+       /* Clear color PE10 */
+       etna_set_state(stream, VIVS_DE_CLEAR_BYTE_MASK, 0xff);
+       etna_set_state(stream, VIVS_DE_CLEAR_PIXEL_VALUE_LOW, 0xff40ff40);
+       etna_set_state(stream, VIVS_DE_CLEAR_PIXEL_VALUE_HIGH, 0xff40ff40);
+
+       etna_set_state(stream, VIVS_DE_DEST_COLOR_KEY, 0);
+       etna_set_state(stream, VIVS_DE_GLOBAL_SRC_COLOR, 0);
+       etna_set_state(stream, VIVS_DE_GLOBAL_DEST_COLOR, 0);
+       etna_set_state(stream, VIVS_DE_COLOR_MULTIPLY_MODES, 0);
+       etna_set_state(stream, VIVS_DE_PE_TRANSPARENCY, 0);
+       etna_set_state(stream, VIVS_DE_PE_CONTROL, 0);
+       etna_set_state(stream, VIVS_DE_PE_DITHER_LOW, 0xffffffff);
+       etna_set_state(stream, VIVS_DE_PE_DITHER_HIGH, 0xffffffff);
+
+       /* Queue DE command */
+       etna_cmd_stream_emit(stream,
+                       VIV_FE_DRAW_2D_HEADER_OP_DRAW_2D | 
VIV_FE_DRAW_2D_HEADER_COUNT(num_rects) /* render one rectangle */
+               );
+       etna_cmd_stream_emit(stream, 0x0); /* rectangles start aligned */
+
+       for(rec=0; rec < num_rects; ++rec) {
+               int x = rec%16;
+               int y = rec/16;
+               etna_cmd_stream_emit(stream, VIV_FE_DRAW_2D_TOP_LEFT_X(x*8) | 
VIV_FE_DRAW_2D_TOP_LEFT_Y(y*8));
+               etna_cmd_stream_emit(stream, 
VIV_FE_DRAW_2D_BOTTOM_RIGHT_X(x*8+4) | VIV_FE_DRAW_2D_BOTTOM_RIGHT_Y(y*8+4));
+       }
+       etna_set_state(stream, 1, 0);
+       etna_set_state(stream, 1, 0);
+       etna_set_state(stream, 1, 0);
+
+       etna_set_state(stream, VIVS_GL_FLUSH_CACHE, VIVS_GL_FLUSH_CACHE_PE2D);
+}
+
+int main(int argc, char *argv[])
+{
+       const int width = 256;
+       const int height = 256;
+       const size_t bmp_size = width * height * 4;
+
+       struct etna_device *dev;
+       struct etna_gpu *gpu;
+       struct etna_pipe *pipe;
+       struct etna_bo *bmp;
+       struct etna_cmd_stream *stream;
+
+       drmVersionPtr version;
+       int fd, ret = 0;
+
+       fd = open(argv[1], O_RDWR);
+       if (fd < 0)
+               return 1;
+
+       version = drmGetVersion(fd);
+       if (version) {
+               printf("Version: %d.%d.%d\n", version->version_major,
+                      version->version_minor, version->version_patchlevel);
+               printf("  Name: %s\n", version->name);
+               printf("  Date: %s\n", version->date);
+               printf("  Description: %s\n", version->desc);
+               drmFreeVersion(version);
+       }
+
+       dev = etna_device_new(fd);
+       if (!dev) {
+               ret = 2;
+               goto out;
+       }
+
+       /* TODO: we assume that core 0 is a 2D capable one */
+       gpu = etna_gpu_new(dev, 0);
+       if (!gpu) {
+               ret = 3;
+               goto out_device;
+       }
+
+       pipe = etna_pipe_new(gpu, ETNA_PIPE_2D);
+       if (!pipe) {
+               ret = 4;
+               goto out_gpu;
+       }
+
+       bmp = etna_bo_new(dev, bmp_size, ETNA_BO_UNCACHED);
+       if (!bmp) {
+               ret = 5;
+               goto out_pipe;
+       }
+       memset(etna_bo_map(bmp), 0, bmp_size);
+
+       stream = etna_cmd_stream_new(pipe, 0x300, NULL, NULL);
+       if (!stream) {
+               ret = 6;
+               goto out_bo;
+       }
+
+       /* generate command sequence */
+       gen_cmd_stream(stream, bmp, width, height);
+
+       etna_cmd_stream_finish(stream);
+
+       bmp_dump32(etna_bo_map(bmp), width, height, false, "/tmp/etna.bmp");
+
+       etna_cmd_stream_del(stream);
+
+out_bo:
+    etna_bo_del(bmp);
+
+out_pipe:
+       etna_pipe_del(pipe);
+
+out_gpu:
+       etna_gpu_del(gpu);
+
+out_device:
+       etna_device_del(dev);
+
+out:
+       close(fd);
+
+       return ret;
+}
diff --git a/tests/etnaviv/etnaviv_bo_cache_test.c 
b/tests/etnaviv/etnaviv_bo_cache_test.c
new file mode 100644
index 0000000..fb01f8d
--- /dev/null
+++ b/tests/etnaviv/etnaviv_bo_cache_test.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2016 Etnaviv 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
+ * SOFTWARE.
+ *
+ * Authors:
+ *    Christian Gmeiner <christian.gmei...@gmail.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#undef NDEBUG
+#include <assert.h>
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "xf86drm.h"
+#include "etnaviv_drmif.h"
+#include "etnaviv_drm.h"
+
+static void test_cache(struct etna_device *dev)
+{
+       struct etna_bo *bo, *tmp;
+
+       /* allocate and free some bo's with same size - we must
+        * get the same bo over and over. */
+       printf("testing bo cache ... ");
+
+       bo = tmp = etna_bo_new(dev, 0x100, ETNA_BO_UNCACHED);
+       assert(bo);
+       etna_bo_del(bo);
+
+       for (unsigned i = 0; i < 100; i++) {
+               tmp = etna_bo_new(dev, 0x100, ETNA_BO_UNCACHED);
+               etna_bo_del(tmp);
+               assert(tmp == bo);
+       }
+
+       printf("ok\n");
+}

Reply via email to