[igt-dev] [PATCH i-g-t 6/6] tests/kms_flip_scaled_crc: Limit pipe output to 8bpc
Ville Syrjala
ville.syrjala at linux.intel.com
Fri Apr 16 17:53:12 UTC 2021
From: Ville Syrjälä <ville.syrjala at 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 at 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
More information about the igt-dev
mailing list