diff mbox

kms_universal_plane: subtest for yuv pixel format in primary plane

Message ID 1437404441-22268-1-git-send-email-mahesh1.kumar@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kumar, Mahesh July 20, 2015, 3 p.m. UTC
This test commit YUV framebuffer in primay plane. I'm using empty FB,
because this fulfills the purpose of testing YUV.

Increase IGT_MAX_PLANES to 5 and add enum for IGT_PLANE_4, as in Broxton
we have 4Plane+1cursor plane.

Signed-off-by: Kumar, Mahesh <mahesh1.kumar@intel.com>
---
 lib/igt_fb.c                |  4 +++
 lib/igt_kms.c               |  1 +
 lib/igt_kms.h               |  3 +-
 tests/kms_universal_plane.c | 82 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 89 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 134dbd2..e570bfa 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -66,6 +66,10 @@  static struct format_desc_struct {
 	DF(XRGB8888,	RGB24,		32, 24),
 	DF(XRGB2101010,	RGB30,		32, 30),
 	DF(ARGB8888,	ARGB32,		32, 32),
+	DF(YUYV,	INVALID,	16, 16),
+	DF(YVYU,	INVALID,	16, 16),
+	DF(UYVY,	INVALID,	16, 16),
+	DF(VYUY,	INVALID,	16, 16),
 };
 #undef DF
 
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 0bb16b4..781ffa5 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -213,6 +213,7 @@  const char *kmstest_plane_name(enum igt_plane plane)
 		[IGT_PLANE_1] = "plane1",
 		[IGT_PLANE_2] = "plane2",
 		[IGT_PLANE_3] = "plane3",
+		[IGT_PLANE_4] = "plane4",
 		[IGT_PLANE_CURSOR] = "cursor",
 	};
 
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 09c08aa..14c8b28 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -53,6 +53,7 @@  enum igt_plane {
         IGT_PLANE_PRIMARY = IGT_PLANE_1,
         IGT_PLANE_2,
         IGT_PLANE_3,
+        IGT_PLANE_4,
         IGT_PLANE_CURSOR,
 };
 
@@ -205,7 +206,7 @@  struct igt_pipe {
 	igt_display_t *display;
 	enum pipe pipe;
 	bool enabled;
-#define IGT_MAX_PLANES	4
+#define IGT_MAX_PLANES	5
 	int n_planes;
 	igt_plane_t planes[IGT_MAX_PLANES];
 	uint64_t background; /* Background color MSB BGR 16bpc LSB */
diff --git a/tests/kms_universal_plane.c b/tests/kms_universal_plane.c
index 635cc79..ed4b134 100644
--- a/tests/kms_universal_plane.c
+++ b/tests/kms_universal_plane.c
@@ -57,6 +57,12 @@  typedef struct {
 	struct igt_fb red_fb, blue_fb;
 } pageflip_test_t;
 
+typedef struct {
+	data_t *data;
+	struct igt_fb fullsize_fb, undersize_fb;
+} primary_yuv_test_t;
+
+
 static void
 functional_test_init(functional_test_t *test, igt_output_t *output, enum pipe pipe)
 {
@@ -430,6 +436,77 @@  sanity_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
 }
 
 static void
+primary_yuv_test_init(primary_yuv_test_t *test, igt_output_t *output, enum pipe pipe)
+{
+	data_t *data = test->data;
+	drmModeModeInfo *mode;
+
+	igt_output_set_pipe(output, pipe);
+
+	mode = igt_output_get_mode(output);
+	igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+			    DRM_FORMAT_YUYV,
+			    LOCAL_DRM_FORMAT_MOD_NONE,
+			    &test->fullsize_fb);
+	igt_create_fb(data->drm_fd, 300, 300,
+			    DRM_FORMAT_YVYU,
+			    LOCAL_DRM_FORMAT_MOD_NONE,
+			    &test->undersize_fb);
+}
+
+static void
+primary_yuv_test_fini(primary_yuv_test_t *test, igt_output_t *output)
+{
+	igt_remove_fb(test->data->drm_fd, &test->fullsize_fb);
+	igt_remove_fb(test->data->drm_fd, &test->undersize_fb);
+
+	igt_output_set_pipe(output, PIPE_ANY);
+	igt_display_commit2(&test->data->display, COMMIT_LEGACY);
+}
+
+/*
+ * YUV pixel format test for primary plane
+ * Display Full frame in primay then 300x300 frame
+ */
+
+static void
+primary_yuv_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
+{
+	primary_yuv_test_t test = { .data = data };
+	igt_plane_t *primary;
+
+	igt_skip_on(pipe >= data->display.n_pipes);
+
+	igt_output_set_pipe(output, pipe);
+
+	primary_yuv_test_init(&test, output, pipe);
+
+	primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+
+	/* Use legacy API to set a mode with a Fullsize FB */
+	igt_plane_set_fb(primary, &test.fullsize_fb);
+	igt_display_commit2(&data->display, COMMIT_LEGACY);
+
+	/* Disable the primary plane */
+	igt_plane_set_fb(primary, NULL);
+	igt_display_commit2(&data->display, COMMIT_UNIVERSAL);
+
+	/* Use Universal API to set a mode with a Fullsize FB */
+	igt_plane_set_fb(primary, &test.fullsize_fb);
+	igt_display_commit2(&data->display, COMMIT_UNIVERSAL);
+
+	/* Use Universal API to set a mode with a Undersize FB */
+	igt_plane_set_fb(primary, &test.undersize_fb);
+	igt_display_commit2(&data->display, COMMIT_UNIVERSAL);
+
+	/* Disable the primary plane */
+	igt_plane_set_fb(primary, NULL);
+
+	primary_yuv_test_fini(&test, output);
+
+}
+
+static void
 pageflip_test_init(pageflip_test_t *test, igt_output_t *output, enum pipe pipe)
 {
 	data_t *data = test->data;
@@ -663,6 +740,11 @@  run_tests_for_pipe(data_t *data, enum pipe pipe)
 		      kmstest_pipe_name(pipe))
 		for_each_connected_output(&data->display, output)
 			cursor_leak_test_pipe(data, pipe, output);
+
+	igt_subtest_f("primary-plane-pipe-%s-yuv",
+		      kmstest_pipe_name(pipe))
+		for_each_connected_output(&data->display, output)
+			primary_yuv_test_pipe(data, pipe, output);
 }
 
 static data_t data;