diff options
author | Tony Ye <tony.ye@intel.com> | 2018-11-13 14:36:28 +0000 |
---|---|---|
committer | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2019-02-05 12:23:09 +0000 |
commit | c4b2b2f07fe8231afb8514fab19218dec95d562d (patch) | |
tree | d3f9c878c0041baff61b2aa57506a029a4b0bfd7 /tests/i915 | |
parent | 5b31f04ae8cc4b922a7a8a6f5da639865a4cacd3 (diff) |
tests/gem_media_vme: Simple test to exercise the VME block
Simple test which exercises the VME fixed function block.
v2: (Tvrtko Ursulin)
* Small cleanups like copyright date, tabs, remove unused bits.
v3: (Tony Ye)
* Added curbe data entry for dst surface.
* Read the dst surface after the VME kernel being executed.
v4: (Tony Ye)
* Added the media_vme.gxa kernel source code and compile instructions.
v5: (Tvrtko Ursulin)
* Added hang detector.
v6: (Tvrtko Ursulin)
* Replace gem_read with gem_sync. (Chris Wilson)
Signed-off-by: Tony Ye <tony.ye@intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Tony Ye <tony.ye@intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Diffstat (limited to 'tests/i915')
-rw-r--r-- | tests/i915/gem_media_vme.c | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/tests/i915/gem_media_vme.c b/tests/i915/gem_media_vme.c new file mode 100644 index 00000000..8d9fd822 --- /dev/null +++ b/tests/i915/gem_media_vme.c @@ -0,0 +1,117 @@ +/* + * Copyright © 2018 Intel Corporation + * + * 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. + */ +#include "igt.h" +#include <stdbool.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <inttypes.h> +#include <errno.h> +#include <sys/stat.h> +#include <sys/time.h> +#include "drm.h" +#include "intel_bufmgr.h" + +IGT_TEST_DESCRIPTION("A very simple workload for the VME media block."); + +#define WIDTH 64 +#define STRIDE (WIDTH) +#define HEIGHT 64 + +#define INPUT_SIZE (WIDTH * HEIGHT * sizeof(char) * 1.5) +#define OUTPUT_SIZE (56*sizeof(int)) + +static void +scratch_buf_init(drm_intel_bufmgr *bufmgr, + struct igt_buf *buf, + unsigned int size) +{ + drm_intel_bo *bo; + + bo = drm_intel_bo_alloc(bufmgr, "", size, 4096); + igt_assert(bo); + + memset(buf, 0, sizeof(*buf)); + + buf->bo = bo; + buf->tiling = I915_TILING_NONE; + buf->size = size; +} + +static void scratch_buf_init_src(drm_intel_bufmgr *bufmgr, struct igt_buf *buf) +{ + scratch_buf_init(bufmgr, buf, INPUT_SIZE); + + /* + * Ideally we would read src surface from file "SourceFrameI.yu12". + * But even without it, we can still triger the rcs0 resetting + * with this vme kernel. + */ + + buf->stride = STRIDE; +} + +static void scratch_buf_init_dst(drm_intel_bufmgr *bufmgr, struct igt_buf *buf) +{ + scratch_buf_init(bufmgr, buf, OUTPUT_SIZE); + + buf->stride = 1; +} + +igt_simple_main +{ + int drm_fd; + uint32_t devid; + drm_intel_bufmgr *bufmgr; + igt_vme_func_t media_vme; + struct intel_batchbuffer *batch; + struct igt_buf src, dst; + + drm_fd = drm_open_driver(DRIVER_INTEL); + igt_require_gem(drm_fd); + + devid = intel_get_drm_devid(drm_fd); + + media_vme = igt_get_media_vme_func(devid); + igt_require_f(media_vme, "no media-vme function\n"); + + bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096); + igt_assert(bufmgr); + + batch = intel_batchbuffer_alloc(bufmgr, devid); + igt_assert(batch); + + scratch_buf_init_src(bufmgr, &src); + scratch_buf_init_dst(bufmgr, &dst); + + igt_fork_hang_detector(drm_fd); + + media_vme(batch, &src, WIDTH, HEIGHT, &dst); + + gem_sync(drm_fd, dst.bo->handle); + + igt_stop_hang_detector(); +} |