summaryrefslogtreecommitdiff
path: root/tests/panfrost_prime.c
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.com>2019-04-24 15:42:25 +0200
committerTomeu Vizoso <tomeu.vizoso@collabora.com>2019-05-13 06:30:50 +0200
commit2f85faf27f3f06928cd46de734958a75b79c65eb (patch)
treed0bc5eb1a64f69d9d59a76b71b89c96badf50aae /tests/panfrost_prime.c
parent910b83b7951212c1a22a37ade91844a0530d7ab4 (diff)
tests/panfrost: Add initial tests for panfrost
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Acked-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'tests/panfrost_prime.c')
-rw-r--r--tests/panfrost_prime.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/panfrost_prime.c b/tests/panfrost_prime.c
new file mode 100644
index 00000000..351d46f2
--- /dev/null
+++ b/tests/panfrost_prime.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2016 Broadcom
+ * Copyright © 2019 Collabora, Ltd.
+ *
+ * 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 "igt_panfrost.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include "panfrost_drm.h"
+
+igt_main
+{
+ int fd, kms_fd;
+
+ igt_fixture {
+ kms_fd = drm_open_driver_master(DRIVER_ANY);
+ fd = drm_open_driver(DRIVER_PANFROST);
+ }
+
+ igt_subtest("gem-prime-import") {
+ struct panfrost_bo *bo;
+ uint32_t handle, dumb_handle;
+ struct drm_panfrost_get_bo_offset get_bo_offset = {0,};
+ int dmabuf_fd;
+
+ /* Just to be sure that when we import the dumb buffer it has
+ * a non-NULL address.
+ */
+ bo = igt_panfrost_gem_new(fd, 1024);
+
+ dumb_handle = kmstest_dumb_create(kms_fd, 1024, 1024, 32, NULL, NULL);
+
+ dmabuf_fd = prime_handle_to_fd(kms_fd, dumb_handle);
+
+ handle = prime_fd_to_handle(fd, dmabuf_fd);
+
+ get_bo_offset.handle = handle;
+ do_ioctl(fd, DRM_IOCTL_PANFROST_GET_BO_OFFSET, &get_bo_offset);
+ igt_assert(get_bo_offset.offset);
+
+ gem_close(fd, handle);
+
+ kmstest_dumb_destroy(kms_fd, dumb_handle);
+
+ igt_panfrost_free_bo(fd, bo);
+ }
+
+ igt_fixture {
+ close(fd);
+ close(kms_fd);
+ }
+}