All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 6/6] tests/kms_flip_scaled_crc: Limit pipe output to 8bpc
Date: Fri, 16 Apr 2021 20:53:12 +0300	[thread overview]
Message-ID: <20210416175312.25190-7-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20210416175312.25190-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

The scaler may have lower precision than the rest of the pipe,
so in order to get the scaled vs. unscaled crc to match we need
to chop off some low bits.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/kms_flip_scaled_crc.c | 42 +++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/tests/kms_flip_scaled_crc.c b/tests/kms_flip_scaled_crc.c
index 88919de2f426..4923f1235b14 100644
--- a/tests/kms_flip_scaled_crc.c
+++ b/tests/kms_flip_scaled_crc.c
@@ -107,6 +107,45 @@ static void free_fbs(data_t *data)
 	igt_remove_fb(data->drm_fd, &data->big_fb);
 }
 
+static void set_lut(data_t *data, enum pipe pipe)
+{
+	igt_pipe_t *pipe_obj = &data->display.pipes[pipe];
+	struct drm_color_lut *lut;
+	drmModeCrtc *crtc;
+	int i, lut_size;
+
+	crtc = drmModeGetCrtc(data->drm_fd, pipe_obj->crtc_id);
+	lut_size = crtc->gamma_size;
+	drmModeFreeCrtc(crtc);
+
+	lut = malloc(sizeof(lut[0]) * lut_size);
+
+	/*
+	 * The scaler may have lower internal precision than
+	 * the rest of the pipe. Limit the output to 8bpc using
+	 * the legacy LUT.
+	 */
+	for (i = 0; i < lut_size; i++) {
+		uint16_t v  = (i * 0xffff / (lut_size - 1)) & 0xff00;
+
+		lut[i].red = v;
+		lut[i].green = v;
+		lut[i].blue = v;
+	}
+
+	igt_pipe_obj_replace_prop_blob(pipe_obj, IGT_CRTC_GAMMA_LUT,
+				       lut, sizeof(lut[0]) * lut_size);
+
+	free(lut);
+}
+
+static void clear_lut(data_t *data, enum pipe pipe)
+{
+	igt_pipe_t *pipe_obj = &data->display.pipes[pipe];
+
+	igt_pipe_obj_set_prop_value(pipe_obj, IGT_CRTC_GAMMA_LUT, 0);
+}
+
 static void test_flip_to_scaled(data_t *data, uint32_t index, enum pipe pipe,
 				igt_output_t *output)
 {
@@ -149,6 +188,7 @@ static void test_flip_to_scaled(data_t *data, uint32_t index, enum pipe pipe,
 				      data->big_fb.modifier))
 		return;
 
+	set_lut(data, pipe);
 	igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET,
 				  NULL);
 	if (data->pipe_crc) {
@@ -204,6 +244,8 @@ static void test_flip_to_scaled(data_t *data, uint32_t index, enum pipe pipe,
 	igt_pipe_crc_stop(data->pipe_crc);
 	igt_pipe_crc_free(data->pipe_crc);
 	data->pipe_crc = NULL;
+
+	clear_lut(data, pipe);
 }
 
 igt_main
-- 
2.26.3

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2021-04-16 17:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 17:53 [igt-dev] [PATCH i-g-t 0/6] tests/kms_flip_scaled_crc: Fix a bunch of fail Ville Syrjala
2021-04-16 17:53 ` [igt-dev] [PATCH i-g-t 1/6] tests/kms_flip_scaled_crc: Remove open coded igt_create_color_fb() Ville Syrjala
2021-04-16 17:53 ` [igt-dev] [PATCH i-g-t 2/6] tests/kms_flip_scaled_crc: Don't leak the fbs between subtests Ville Syrjala
2021-04-16 17:53 ` [igt-dev] [PATCH i-g-t 3/6] tests/kms_flip_scaled_crc: Use igt_assert_crc_equal() Ville Syrjala
2021-04-16 17:53 ` [igt-dev] [PATCH i-g-t 4/6] tests/kms_flip_scaled_crc: Clean up pipe crc before subtest Ville Syrjala
2021-04-16 17:53 ` [igt-dev] [PATCH i-g-t 5/6] tests/kms_flip_scaled_crc: Check that the plane supports the format+modifier Ville Syrjala
2021-04-16 17:53 ` Ville Syrjala [this message]
2021-04-16 19:17 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_flip_scaled_crc: Fix a bunch of fail Patchwork
2021-04-16 20:59 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2021-04-20 12:21 ` [igt-dev] [PATCH i-g-t 0/6] " Juha-Pekka Heikkila

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=20210416175312.25190-7-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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.