[PATCH v1 1/1] kms_plane_props: Test to verify drm properties for planes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Sagar Kamble <sagar.a.kamble@xxxxxxxxx>

This test will set various values for drm properties exposed by planes
and check for functional accuracy in some cases using CRC check.
Currently this test is enabled for "const-alpha" drm property.

Cc: daniel.vetter@xxxxxxxx
Cc: jani.nikula@xxxxxxxxxxxxxxx
Cc: ville.syrjala@xxxxxxxxxxxxxxx
Cc: indranil.mukherjee@xxxxxxxxx
Cc: shashidhar.hiremath@xxxxxxxxx
Cc: vandita.kulkarni@xxxxxxxxx
Cc: vijay.a.purushothaman@xxxxxxxxx
Signed-off-by: Sagar Kamble <sagar.a.kamble@xxxxxxxxx>
Signed-off-by: Sharma, Ankitprasad R <ankitprasad.r.sharma@xxxxxxxxx>
---
 tests/Makefile.sources  |   1 +
 tests/kms_plane_props.c | 266 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 267 insertions(+)
 create mode 100644 tests/kms_plane_props.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index a8a091d..b0be0f4 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -63,6 +63,7 @@ TESTS_progs_M = \
 	kms_flip_tiling \
 	kms_pipe_crc_basic \
 	kms_plane \
+	kms_plane_props \
 	kms_render \
 	kms_setmode \
 	pm_lpsp \
diff --git a/tests/kms_plane_props.c b/tests/kms_plane_props.c
new file mode 100644
index 0000000..7cbc815
--- /dev/null
+++ b/tests/kms_plane_props.c
@@ -0,0 +1,266 @@
+/*
+ * Copyright © 2014 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.
+ *
+ * Authors:
+ *   Kamble, Sagar A <sagar.a.kamble@xxxxxxxxx>
+ *   Sharma, Ankitprasad R <ankitprasad.r.sharma@xxxxxxxxx>
+ */
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "drmtest.h"
+#include "igt_debugfs.h"
+#include "igt_kms.h"
+
+typedef struct {
+	int drm_fd;
+	igt_display_t display;
+} data_t;
+
+/*
+ * Plane drm properties test
+ * Constant alpha test.
+ *   - We start by grabbing a reference CRC of a full black fb being scanned
+ *     out on the primary plane
+ *   - Then we scannout sprite plane with full white fb and capture corresponding
+ *	 reference CRC.
+ *   - Then we set constant alpha property of sprite plane with value from
+ *     0 to 255 in increments of 5.
+ *   - The resulting CRC when alpha is set to 0 should be identical to the reference CRC
+ *	 captured when only primary plane is set.
+ *   - The resulting CRC when alpha is set to 255 should be identical to the reference CRC
+ *	 captured when both primary and sprite plane are set.
+ */
+
+typedef struct {
+	data_t *data;
+	igt_pipe_crc_t *pipe_crc;
+	igt_crc_t reference_crc[2];
+} test_plane_props_t;
+
+/*
+ * create a fb for primary plane
+ */
+static void
+create_fb_for_primary(data_t *data, drmModeModeInfo *mode,
+			     struct igt_fb *fb /* out */)
+{
+	unsigned int fb_id;
+	cairo_t *cr;
+
+	fb_id = igt_create_fb(data->drm_fd,
+				  mode->hdisplay, mode->vdisplay,
+				  DRM_FORMAT_XRGB8888,
+				  false /* tiling */,
+				  fb);
+	igt_assert(fb_id);
+
+	cr = igt_get_cairo_ctx(data->drm_fd, fb);
+	igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
+			    0.0, 0.0, 0.0);
+	igt_assert(cairo_status(cr) == 0);
+	cairo_destroy(cr);
+}
+
+static void
+test_plane_props_init(test_plane_props_t *test, igt_output_t *output, enum pipe pipe)
+{
+	data_t *data = test->data;
+	struct igt_fb fb;
+	drmModeModeInfo *mode;
+	igt_plane_t *primary;
+
+	test->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	igt_output_set_pipe(output, pipe);
+	primary = igt_output_get_plane(output, 0);
+
+	mode = igt_output_get_mode(output);
+	igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+				DRM_FORMAT_XRGB8888,
+				false, /* tiled */
+				0.0, 0.0, 0.0,
+				&fb);
+	igt_plane_set_fb(primary, &fb);
+
+	igt_display_commit(&data->display);
+
+	sleep(2);
+	igt_pipe_crc_collect_crc(test->pipe_crc, &test->reference_crc[0]);
+	sleep(2);
+
+	igt_plane_set_fb(primary, NULL);
+	igt_display_commit(&data->display);
+
+	igt_remove_fb(data->drm_fd, &fb);
+}
+
+static void
+test_plane_props_fini(test_plane_props_t *test, igt_output_t *output)
+{
+	igt_pipe_crc_free(test->pipe_crc);
+
+	igt_output_set_pipe(output, PIPE_ANY);
+	igt_display_commit(&test->data->display);
+}
+
+static int set_plane_property(test_plane_props_t *test, igt_plane_t *sprite, char *prop_name, int val, igt_crc_t *crc_output)
+{
+	int i = 0, ret = 0, drm_fd = test->data->drm_fd, plane_id = sprite->drm_plane->plane_id;
+	uint64_t value;
+	drmModeObjectPropertiesPtr props = NULL;
+
+	value = (uint64_t)val;
+	props = drmModeObjectGetProperties(drm_fd, plane_id, DRM_MODE_OBJECT_PLANE);
+
+	for (i = 0; i < props->count_props; i++)
+	{
+		drmModePropertyPtr prop = drmModeGetProperty(drm_fd, props->props[i]);
+		fprintf(stdout, "\nProp->name=%s ", prop->name);
+
+		if (strcmp(prop->name, prop_name) == 0)
+		{
+			ret = drmModeObjectSetProperty(drm_fd, plane_id, DRM_MODE_OBJECT_PLANE,
+								(uint32_t)prop->prop_id, value);
+			if (ret)
+			{
+				fprintf(stdout, "set_property \"%s\" to %d for plane %d is failed\n", prop_name, val, plane_id);
+				return ret;
+			}
+			else {
+				fprintf(stdout, "set_property \"%s\" to %d for plane %d is successful\n", prop_name, val, plane_id);
+				sleep(2);
+				igt_pipe_crc_collect_crc(test->pipe_crc, crc_output);
+				sleep(2);
+			}
+		}
+		drmModeFreeProperty(prop);
+	}
+	drmModeFreeObjectProperties(props);
+	return 0;
+}
+
+static void
+test_plane_const_alpha_prop_with_output(data_t *data,
+				enum pipe pipe,
+				enum igt_plane plane,
+				igt_output_t *output)
+{
+	test_plane_props_t test = { .data = data };
+	igt_plane_t *primary, *sprite;
+	struct igt_fb primary_fb, sprite_fb;
+	drmModeModeInfo *mode;
+	igt_crc_t crc_output;
+	int i = 0;
+	char prop_name[20] = "const-alpha";
+
+	fprintf(stdout, "Testing connector %s using pipe %c plane %d\n",
+		igt_output_name(output), pipe_name(pipe), plane);
+
+	test_plane_props_init(&test, output, pipe);
+
+	mode = igt_output_get_mode(output);
+	primary = igt_output_get_plane(output, 0);
+	sprite = igt_output_get_plane(output, plane);
+
+	create_fb_for_primary(data, mode, &primary_fb);
+	igt_plane_set_fb(primary, &primary_fb);
+
+	igt_create_color_fb(data->drm_fd,
+				mode->hdisplay / 2, mode->vdisplay / 2, /* width, height */
+				DRM_FORMAT_XRGB8888,
+				false, /* tiled */
+				1.0, 1.0, 1.0,
+				&sprite_fb);
+	igt_plane_set_fb(sprite, &sprite_fb);
+
+	igt_plane_set_position(sprite, mode->hdisplay / 4, mode->vdisplay / 4);
+
+	igt_display_commit(&data->display);
+
+	sleep(2);
+	igt_pipe_crc_collect_crc(test.pipe_crc, &test.reference_crc[1]);
+	sleep(2);
+
+	for (i=0; i<256; i+=5) {
+		if (set_plane_property(&test, sprite, prop_name, i, &crc_output))
+			return;
+		if (i == 0)
+			igt_assert(igt_crc_equal(&test.reference_crc[0], &crc_output));
+		else if (i == 255)
+			igt_assert(igt_crc_equal(&test.reference_crc[1], &crc_output));
+	}
+
+	igt_plane_set_fb(primary, NULL);
+	igt_plane_set_fb(sprite, NULL);
+
+	test_plane_props_fini(&test, output);
+}
+
+static void
+test_plane_props(data_t *data, enum pipe pipe, enum igt_plane plane)
+{
+	igt_output_t *output;
+
+	igt_skip_on(pipe >= data->display.n_pipes);
+	igt_skip_on(plane >= data->display.pipes[pipe].n_planes);
+
+	for_each_connected_output(&data->display, output)
+		test_plane_const_alpha_prop_with_output(data, pipe, plane, output);
+}
+
+static void
+run_tests_for_pipe(data_t *data, enum pipe pipe)
+{
+	int plane;
+
+	for (plane = 1; plane < IGT_MAX_PLANES; plane++)
+		test_plane_props(data, pipe, plane);
+}
+
+static data_t data;
+
+igt_main
+{
+
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		data.drm_fd = drm_open_any();
+
+		igt_set_vt_graphics_mode();
+
+		igt_require_pipe_crc();
+		igt_display_init(&data.display, data.drm_fd);
+	}
+
+	for (int pipe = 0; pipe < 3; pipe++)
+		run_tests_for_pipe(&data, pipe);
+
+	igt_fixture {
+		igt_display_fini(&data.display);
+	}
+}
+
-- 
1.8.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux