[Intel-gfx] [PATCH i-g-t 2/2] tests/test_nv12.c: This patch adds test_nv12 test case. It is a simple test that covers testing NV12 in linear/tile-X/tile-Y tiling formats.

Vidya Srinivas vidya.srinivas at intel.com
Wed Jul 26 08:47:13 UTC 2017


From: chandra konduru <chandra.konduru at intel.com>

Previous version reference https://patchwork.freedesktop.org/patch/59067/
was posted by Chandra Konduru on Sept 9 2015 based on the
IGT framework available at that time

Current version: Rebased as per current IGT (me).
This version tests basic NV12
in linear/tile-X/tile-Y tiling formats.

Signed-off-by: Chandra Konduru <chandra.konduru at intel.com>
Signed-off-by: Vidya Srinivas <vidya.srinivas at intel.com>
---
 tests/Makefile.sources |   1 +
 tests/test_nv12.c      | 171 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 172 insertions(+)
 create mode 100644 tests/test_nv12.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 5b98a5a..5fe5ced 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -233,6 +233,7 @@ TESTS_progs = \
 	tools_test \
 	vgem_basic \
 	vgem_slow \
+	test_nv12 \
 	$(NULL)
 
 TESTS_progs_X = \
diff --git a/tests/test_nv12.c b/tests/test_nv12.c
new file mode 100644
index 0000000..976eaf5
--- /dev/null
+++ b/tests/test_nv12.c
@@ -0,0 +1,171 @@
+/*
+ * Copyright © 20137 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 <stdbool.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+#include <xf86drmMode.h>
+#include <cairo.h>
+#include "drm.h"
+#include "ioctl_wrappers.h"
+#include "drmtest.h"
+#include "igt.h"
+#include "igt_aux.h"
+#include "sw_sync.h"
+
+
+IGT_TEST_DESCRIPTION("Test page flips and tiling scenarios");
+
+uint32_t devid;
+
+typedef struct {
+	int drm_fd;
+	igt_display_t display;
+
+	struct igt_fb fb1_nv12;
+	struct igt_fb fb2;
+	int fb_id1_nv12;
+	int fb_id2;
+
+	igt_plane_t *plane1;
+	uint64_t tiled;
+	int rotation;
+} data_t;
+
+#define IMG_FILE  "1080-left.png"
+
+static void
+paint_image(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
+{
+	cairo_t *cr;
+	cr = igt_get_cairo_ctx(d->drm_fd, fb);
+	igt_paint_image(cr, IMG_FILE, 0, 0, w, h);
+	cairo_destroy(cr);
+}
+
+static void test_nv12_plane(data_t *d)
+{
+	igt_display_t *display = &d->display;
+	igt_output_t *output;
+	enum pipe pipe;
+	int valid_tests = 0;
+	int img_width;
+	int img_height;
+
+	for_each_pipe_with_valid_output(display, pipe, output) {
+		drmModeModeInfo *mode;
+		mode = igt_output_get_mode(output);
+		igt_output_set_pipe(output, pipe);
+
+		/* get planes */
+		d->plane1 = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+
+		/* set required rotation */
+		igt_plane_set_rotation(d->plane1, d->rotation);
+
+		/* allocate fb2, fb2_nv12, fb1_nv12 with image size */
+		igt_get_image_size(IMG_FILE, &img_width, &img_height);
+
+		/* fb2 is in RGB format */
+		d->fb_id2 = igt_create_fb(d->drm_fd,
+				img_width, img_height,
+				DRM_FORMAT_XRGB8888,
+				d->tiled, /* tiled */
+				&d->fb2);
+
+		d->fb_id1_nv12 = igt_create_fb(d->drm_fd,
+				img_width, img_height,
+				DRM_FORMAT_NV12,
+				d->tiled, /* tiled */
+				&d->fb1_nv12);
+
+		/* set up data for fb2: both fb1_nv12, fb2_nv12 uses this */
+		paint_image(d, &d->fb2, img_width, img_height);
+
+		igt_fb_csc_xrgb_to_nv12(d->drm_fd, &d->fb1_nv12, &d->fb2);
+
+		/* single plane mode  - nv12 & scaling */
+		igt_plane_set_fb(d->plane1, &d->fb1_nv12);
+		igt_fb_set_position(&d->fb1_nv12, d->plane1, 0, 0);
+		igt_fb_set_size(&d->fb1_nv12, d->plane1, d->fb1_nv12.width,
+				d->fb1_nv12.height);
+		igt_plane_set_position(d->plane1, 0, 0);
+		igt_plane_set_size(d->plane1, d->fb1_nv12.width, d->fb1_nv12.height);
+		igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+		valid_tests++;
+		sleep(1);
+	}
+	igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
+}
+
+igt_main
+{
+	data_t data = {};
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		data.drm_fd = drm_open_driver(DRIVER_INTEL);
+		kmstest_set_vt_graphics_mode();
+		igt_display_init(&data.display, data.drm_fd);
+		igt_require_gem(data.drm_fd);
+
+		devid = intel_get_drm_devid(data.drm_fd);
+		igt_assert(intel_gen(devid) >= 9);
+	}
+
+	data.rotation = IGT_ROTATION_0;
+
+	igt_subtest_f("nv12-plane-tile-linear") {
+		data.rotation = IGT_ROTATION_0;
+		data.tiled = LOCAL_DRM_FORMAT_MOD_NONE;
+		test_nv12_plane(&data);
+	}
+
+	igt_subtest_f("nv12-plane-tile-x") {
+		data.rotation = IGT_ROTATION_0;
+		data.tiled = LOCAL_I915_FORMAT_MOD_X_TILED;
+		test_nv12_plane(&data);
+	}
+
+	igt_subtest_f("nv12-plane-tile-y") {
+		data.rotation = IGT_ROTATION_0;
+		data.tiled = LOCAL_I915_FORMAT_MOD_Y_TILED;
+		test_nv12_plane(&data);
+	}
+
+	igt_subtest_f("nv12-plane-tile-yf") {
+		data.rotation = IGT_ROTATION_0;
+		data.tiled = LOCAL_I915_FORMAT_MOD_Yf_TILED;
+		test_nv12_plane(&data);
+	}
+
+	igt_fixture {
+		igt_display_fini(&data.display);
+	}
+}
-- 
1.9.1



More information about the Intel-gfx mailing list