All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
To: harry.wentland@amd.com, markyacoub@google.com,
	nicholas.choi@amd.com, hayden.goodfellow@amd.com
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/5] tests/amdgpu: Test combination of plane degamma and CRTC regamma
Date: Mon, 29 Nov 2021 14:56:56 -0500	[thread overview]
Message-ID: <20211129195659.1865321-3-Rodrigo.Siqueira@amd.com> (raw)
In-Reply-To: <20211129195659.1865321-1-Rodrigo.Siqueira@amd.com>

From: Stylon Wang <stylon.wang@amd.com>

Signed-off-by: Stylon Wang <stylon.wang@amd.com>
---
 tests/amdgpu/amd_color.c | 114 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 114 insertions(+)

diff --git a/tests/amdgpu/amd_color.c b/tests/amdgpu/amd_color.c
index 418f8934..84f0a995 100644
--- a/tests/amdgpu/amd_color.c
+++ b/tests/amdgpu/amd_color.c
@@ -146,6 +146,20 @@ static void lut_gen_max(lut_t *lut, uint16_t mask)
 	}
 }
 
+/* Generates the half curve gamma LUT. */
+static void lut_gen_half(lut_t *lut, uint16_t mask)
+{
+	uint32_t i;
+
+	for (i = 0; i < lut->size; ++i) {
+		uint32_t v = i? (0xffff & mask)/2 : 0;
+
+		lut->data[i].red = v;
+		lut->data[i].blue = v;
+		lut->data[i].green = v;
+	}
+}
+
 static void lut_free(lut_t *lut)
 {
 	if (lut->data) {
@@ -699,6 +713,20 @@ static void draw_fill_color_bar(igt_fb_t *fb, int w, int h)
 	igt_put_cairo_ctx(cr);
 }
 
+/* draw color bars with half the brightness*/
+static void draw_fill_color_bar_half(igt_fb_t *fb, int w, int h)
+{
+	cairo_t *cr;
+	int gh = h/3;
+	int rh = h-gh*2;
+
+	cr = igt_get_cairo_ctx(fb->fd, fb);
+	igt_paint_color(cr, 0, 0, w, gh, 0.5, 0.0, 0.0);
+	igt_paint_color(cr, 0, gh, w, gh, 0.0, 0.5, 0.0);
+	igt_paint_color(cr, 0, gh*2, w, rh, 0.0, 0.0, 0.5);
+	igt_put_cairo_ctx(cr);
+}
+
 /* draw color bars in gradient without all-black pixels */
 static void draw_gradient_color_bar(igt_fb_t *fb, int w, int h)
 {
@@ -753,6 +781,90 @@ static void test_plane_max_degamma(data_t *data)
 	lut_free(&lut_max);
 }
 
+static bool test_plane_crtc_gamma(data_t *data, uint32_t format, igt_crc_t ref_crc)
+{
+	igt_display_t *display = &data->display;
+	igt_fb_t afb;
+	igt_crc_t new_crc;
+	lut_t lut_max, lut_half;
+	enum igt_color_encoding e = IGT_COLOR_YCBCR_BT709;
+	enum igt_color_range r = IGT_COLOR_YCBCR_LIMITED_RANGE;
+	bool result = true;
+
+	igt_info("Testing format " IGT_FORMAT_FMT " (%s, %s) on %s.%u\n",
+		 IGT_FORMAT_ARGS(format),
+		 igt_color_encoding_to_str(e),
+		 igt_color_range_to_str(r),
+		 kmstest_pipe_name(data->pipe_id), data->primary->index);
+
+	lut_init(&lut_max, data->plane_degamma_lut_size);
+	lut_gen_max(&lut_max, 0xffff);
+	lut_init(&lut_half, data->plane_degamma_lut_size);
+	lut_gen_half(&lut_half, 0xffff);
+
+	igt_create_fb_with_bo_size(data->fd, data->w, data->h,
+				   format, 0,
+				   e, r,
+				   &afb, 0, 0);
+	draw_gradient_color_bar(&afb, data->w, data->h);
+
+	igt_plane_set_fb(data->primary, &afb);
+	set_plane_degamma_lut(data, &lut_max);
+	set_regamma_lut(data, &lut_half);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &new_crc);
+
+	if (!igt_check_crc_equal(&ref_crc, &new_crc)) {
+		result = false;
+		igt_warn("CRC mismatches with format " IGT_FORMAT_FMT "\n",
+			 IGT_FORMAT_ARGS(format));
+	}
+
+	igt_plane_set_fb(data->primary, NULL);
+	igt_remove_fb(data->fd, &afb);
+	lut_free(&lut_max);
+	return result;
+}
+
+static void test_plane_crtc_gamma_formats(data_t *data)
+{
+	int i;
+	igt_plane_t *plane;
+	igt_display_t *display = &data->display;
+	igt_fb_t rfb;
+	igt_crc_t ref_crc;
+	bool result = true;
+
+	test_init(data);
+	plane = data->primary;
+
+	/* draw test pattern and take CRC as reference */
+	igt_create_fb(data->fd, data->w, data->h, DRM_FORMAT_XRGB8888, 0, &rfb);
+	draw_fill_color_bar_half(&rfb, data->w, data->h);
+	igt_plane_set_fb(data->primary, &rfb);
+	set_plane_degamma_lut(data, NULL);
+	set_regamma_lut(data, NULL);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+	igt_plane_set_fb(data->primary, NULL);
+	igt_remove_fb(data->fd, &rfb);
+
+	/* test on all supported formats */
+	for (i = plane->format_mod_count-1; i >= 0; i--) {
+		if (!igt_fb_supported_format(plane->formats[i]))
+				continue;
+		result &= test_plane_crtc_gamma(data,  plane->formats[i], ref_crc);
+	}
+
+	set_plane_degamma_lut(data, NULL);
+	set_regamma_lut(data, NULL);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	igt_assert_f(result, "At least one CRC mismatch happened\n");
+
+	test_fini(data);
+}
+
 igt_main
 {
 	data_t data;
@@ -782,6 +894,8 @@ igt_main
 	igt_subtest("plane-ctm-mixed-mapping") test_plane_ctm_mixed_mapping(&data);
 	igt_subtest("plane-max-degamma") test_plane_max_degamma(&data);
 
+	igt_subtest("plane-crtc-degamma") test_plane_crtc_gamma_formats(&data);
+
 	igt_fixture
 	{
 		igt_display_fini(&data.display);
-- 
2.25.1

  parent reply	other threads:[~2021-11-29 19:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-29 19:56 [igt-dev] [PATCH i-g-t 0/5] tests/amdgpu: Improve amd_color Rodrigo Siqueira
2021-11-29 19:56 ` [igt-dev] [PATCH i-g-t 1/5] tests/amdgpu: Test plane level CTM and degamma Rodrigo Siqueira
2021-11-30 16:12   ` Harry Wentland
2021-11-29 19:56 ` Rodrigo Siqueira [this message]
2021-11-29 19:56 ` [igt-dev] [PATCH i-g-t 3/5] tests/amdgpu: Fix test init error on Baffin Rodrigo Siqueira
2021-11-29 19:56 ` [igt-dev] [PATCH i-g-t 4/5] test/amdgpu: Add test description to amd_max_bpc and amd_color tests Rodrigo Siqueira
2021-11-29 19:56 ` [igt-dev] [PATCH i-g-t 5/5] tests/amdgpu: fix gamma test on plane and crtc Rodrigo Siqueira
2021-11-29 21:02 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/amdgpu: Improve amd_color Patchwork
2021-11-29 22:21 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2021-11-29 22:46   ` Rodrigo Siqueira Jordao
2021-11-30  4:46     ` Vudum, Lakshminarayana
2021-11-30  0:09 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2021-11-30  2:46 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211129195659.1865321-3-Rodrigo.Siqueira@amd.com \
    --to=rodrigo.siqueira@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=hayden.goodfellow@amd.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=markyacoub@google.com \
    --cc=nicholas.choi@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.