diff mbox

[i-g-t,3/6] i-g-t: lib/igt_kms: Run kms_plane for all supported pixel formats

Message ID 1513158652-8912-4-git-send-email-vidya.srinivas@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vidya Srinivas Dec. 13, 2017, 9:50 a.m. UTC
From: Mahesh Kumar <mahesh1.kumar@intel.com>

This patch adds a subtest related to pixel format testing. The test
create framebuffer with all supported pixel formats for primary and
sprite planes which can be drawn using cairo and commits the same on display.

Signed-off-by: Mahesh Kumar <mahesh1.kumar@intel.com>
Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
Signed-off-by: Vidya Srinivas <vidya.srinivas@intel.com>
---
 tests/kms_plane.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 123 insertions(+)

Comments

Maarten Lankhorst Jan. 9, 2018, 12:24 p.m. UTC | #1
Op 13-12-17 om 10:50 schreef Vidya Srinivas:
> From: Mahesh Kumar <mahesh1.kumar@intel.com>
>
> This patch adds a subtest related to pixel format testing. The test
> create framebuffer with all supported pixel formats for primary and
> sprite planes which can be drawn using cairo and commits the same on display.
>
> Signed-off-by: Mahesh Kumar <mahesh1.kumar@intel.com>
> Signed-off-by: Jyoti Yadav <jyoti.r.yadav@intel.com>
> Signed-off-by: Vidya Srinivas <vidya.srinivas@intel.com>
> ---
>  tests/kms_plane.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 123 insertions(+)
>
> diff --git a/tests/kms_plane.c b/tests/kms_plane.c
> index 92bf67f..5f25177 100644
> --- a/tests/kms_plane.c
> +++ b/tests/kms_plane.c
> @@ -368,6 +368,125 @@ test_plane_panning(data_t *data, enum pipe pipe, unsigned int flags)
>  	igt_skip_on(connected_outs == 0);
>  }
>  
> +static void test_format_primary(data_t *data,
> +			enum pipe pipe, igt_output_t *output)
> +{
> +	igt_plane_t *primary;
> +	struct igt_fb primary_fb;
> +	drmModeModeInfo *mode;
> +	cairo_t *cr;
> +	int primary_id;
> +	uint32_t format;
> +
> +	igt_info("Testing connector %s using pipe %s on primary plane\n",
> +		 igt_output_name(output), kmstest_pipe_name(pipe));
> +
> +	igt_output_set_pipe(output, pipe);
> +	mode = igt_output_get_mode(output);
> +
> +	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
> +
> +	for_each_format_in_plane(primary, format) {
> +		if (igt_is_cairo_supported_format(format)) {
> +			igt_info("Testing format %s on primary now\n",
> +					 igt_get_format_name(format));
> +			primary_id = igt_create_fb(data->drm_fd,
> +					  mode->hdisplay, mode->vdisplay,
> +					  format,
> +					  LOCAL_DRM_FORMAT_MOD_NONE,
> +					  &primary_fb);
> +			igt_assert(primary_id);
> +			cr = igt_get_cairo_ctx(data->drm_fd, &primary_fb);
> +			igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
> +						    0.0, 1.0, 0.0);
> +			igt_paint_color(cr, 100, 100, 64, 64, 0.0, 0.0, 0.0);
> +			igt_assert(cairo_status(cr) == 0);
> +			cairo_destroy(cr);
> +
> +			igt_plane_set_fb(primary, &primary_fb);
> +			igt_display_commit(&data->display);
> +		}
> +	}
> +
> +	igt_remove_fb(data->drm_fd, &primary_fb);
> +	igt_plane_set_fb(primary, NULL);
> +}
> +
> +static void test_format_overlay(data_t *data,
> +			enum pipe pipe, igt_output_t *output,
> +			int plane_id)
> +{
> +	igt_plane_t *primary, *overlay;
> +	struct igt_fb primary_fb, overlay_fb;
> +	drmModeModeInfo *mode;
> +	cairo_t *cr;
> +	int primary_id, overlay_id;
> +	uint32_t format;
> +
> +	igt_info("Testing connector %s using pipe %s on overlay plane %d\n",
> +		 igt_output_name(output), kmstest_pipe_name(pipe), plane_id);
> +
> +	igt_output_set_pipe(output, pipe);
> +	mode = igt_output_get_mode(output);
> +
> +	overlay = igt_output_get_plane(output, plane_id);
> +	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
> +	primary_id = igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
> +							   DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +							   &primary_fb);
> +	igt_assert(primary_id);
> +	igt_plane_set_fb(primary, &primary_fb);
> +	cr = igt_get_cairo_ctx(data->drm_fd, &primary_fb);
> +	igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay, 0.0, 0.0, 1.0);
> +	igt_assert(cairo_status(cr) == 0);
> +	cairo_destroy(cr);
> +
> +	for_each_format_in_plane(overlay, format) {
> +		if (igt_is_cairo_supported_format(format)) {
> +			igt_info("Testing format %s on plane id %d\n",
> +					  igt_get_format_name(format), plane_id);
> +			overlay_id = igt_create_fb(data->drm_fd, 300, 300, format,
> +									   LOCAL_DRM_FORMAT_MOD_NONE, &overlay_fb);
> +			igt_assert(overlay_id);
> +
> +			igt_plane_set_fb(overlay, &overlay_fb);
> +			cr = igt_get_cairo_ctx(data->drm_fd, &overlay_fb);
> +			igt_paint_color(cr, 0, 0, 300, 300, 1.0, 0.0, 0.0);
> +			igt_assert(cairo_status(cr) == 0);
> +			cairo_destroy(cr);
> +			igt_display_commit(&data->display);
Why does this test distinguish between primary and sprite? It should test all planes in the same way, including cursor.

In fact, we should also test formats not supported by cairo, and only skip the painting in that case.

~Maarten
diff mbox

Patch

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 92bf67f..5f25177 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -368,6 +368,125 @@  test_plane_panning(data_t *data, enum pipe pipe, unsigned int flags)
 	igt_skip_on(connected_outs == 0);
 }
 
+static void test_format_primary(data_t *data,
+			enum pipe pipe, igt_output_t *output)
+{
+	igt_plane_t *primary;
+	struct igt_fb primary_fb;
+	drmModeModeInfo *mode;
+	cairo_t *cr;
+	int primary_id;
+	uint32_t format;
+
+	igt_info("Testing connector %s using pipe %s on primary plane\n",
+		 igt_output_name(output), kmstest_pipe_name(pipe));
+
+	igt_output_set_pipe(output, pipe);
+	mode = igt_output_get_mode(output);
+
+	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+
+	for_each_format_in_plane(primary, format) {
+		if (igt_is_cairo_supported_format(format)) {
+			igt_info("Testing format %s on primary now\n",
+					 igt_get_format_name(format));
+			primary_id = igt_create_fb(data->drm_fd,
+					  mode->hdisplay, mode->vdisplay,
+					  format,
+					  LOCAL_DRM_FORMAT_MOD_NONE,
+					  &primary_fb);
+			igt_assert(primary_id);
+			cr = igt_get_cairo_ctx(data->drm_fd, &primary_fb);
+			igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
+						    0.0, 1.0, 0.0);
+			igt_paint_color(cr, 100, 100, 64, 64, 0.0, 0.0, 0.0);
+			igt_assert(cairo_status(cr) == 0);
+			cairo_destroy(cr);
+
+			igt_plane_set_fb(primary, &primary_fb);
+			igt_display_commit(&data->display);
+		}
+	}
+
+	igt_remove_fb(data->drm_fd, &primary_fb);
+	igt_plane_set_fb(primary, NULL);
+}
+
+static void test_format_overlay(data_t *data,
+			enum pipe pipe, igt_output_t *output,
+			int plane_id)
+{
+	igt_plane_t *primary, *overlay;
+	struct igt_fb primary_fb, overlay_fb;
+	drmModeModeInfo *mode;
+	cairo_t *cr;
+	int primary_id, overlay_id;
+	uint32_t format;
+
+	igt_info("Testing connector %s using pipe %s on overlay plane %d\n",
+		 igt_output_name(output), kmstest_pipe_name(pipe), plane_id);
+
+	igt_output_set_pipe(output, pipe);
+	mode = igt_output_get_mode(output);
+
+	overlay = igt_output_get_plane(output, plane_id);
+	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+	primary_id = igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+							   DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+							   &primary_fb);
+	igt_assert(primary_id);
+	igt_plane_set_fb(primary, &primary_fb);
+	cr = igt_get_cairo_ctx(data->drm_fd, &primary_fb);
+	igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay, 0.0, 0.0, 1.0);
+	igt_assert(cairo_status(cr) == 0);
+	cairo_destroy(cr);
+
+	for_each_format_in_plane(overlay, format) {
+		if (igt_is_cairo_supported_format(format)) {
+			igt_info("Testing format %s on plane id %d\n",
+					  igt_get_format_name(format), plane_id);
+			overlay_id = igt_create_fb(data->drm_fd, 300, 300, format,
+									   LOCAL_DRM_FORMAT_MOD_NONE, &overlay_fb);
+			igt_assert(overlay_id);
+
+			igt_plane_set_fb(overlay, &overlay_fb);
+			cr = igt_get_cairo_ctx(data->drm_fd, &overlay_fb);
+			igt_paint_color(cr, 0, 0, 300, 300, 1.0, 0.0, 0.0);
+			igt_assert(cairo_status(cr) == 0);
+			cairo_destroy(cr);
+			igt_display_commit(&data->display);
+
+			igt_remove_fb(data->drm_fd, &overlay_fb);
+			igt_plane_set_fb(overlay, NULL);
+			overlay_id = 0;
+		}
+	}
+	igt_remove_fb(data->drm_fd, &primary_fb);
+	igt_plane_set_fb(primary, NULL);
+}
+
+static void
+test_pixel_formats(data_t *data, enum pipe pipe)
+{
+	igt_output_t *output;
+	int connected_outs = 0;
+
+	for_each_valid_output_on_pipe(&data->display, pipe, output) {
+		int n_planes = data->display.pipes[pipe].n_planes;
+
+		igt_info("Testing PRIMARY on pipe %d\n", pipe);
+		test_format_primary(data, pipe, output);
+
+		/* Run only for SPRITES */
+		for (int plane_id = 1; plane_id < n_planes-1; plane_id++)
+			test_format_overlay(data, pipe, output, plane_id);
+
+		connected_outs++;
+		igt_output_set_pipe(output, PIPE_ANY);
+	}
+	igt_skip_on(connected_outs == 0);
+}
+
 static void
 run_tests_for_pipe_plane(data_t *data, enum pipe pipe)
 {
@@ -376,6 +495,10 @@  run_tests_for_pipe_plane(data_t *data, enum pipe pipe)
 		igt_require(data->display.pipes[pipe].n_planes > 0);
 	}
 
+	igt_subtest_f("pixel-format-pipe-%s-planes",
+		      kmstest_pipe_name(pipe))
+		test_pixel_formats(data, pipe);
+
 	igt_subtest_f("plane-position-covered-pipe-%s-planes",
 		      kmstest_pipe_name(pipe))
 		test_plane_position(data, pipe, TEST_POSITION_FULLY_COVERED);