diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2021-04-16 04:49:41 +0300 |
---|---|---|
committer | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2021-04-21 01:13:20 +0300 |
commit | 0a51f49df9f5ca535fc0206a27a6780de6b52320 (patch) | |
tree | 0f3caf7e26c44bf69f80ce00e10c8ced22338e2a | |
parent | d787d5885cdceeb3a4a112a3de90b9f573c7d0a4 (diff) |
tests/kms_flip_scaled_crc: Limit pipe output to 8bpc
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>
Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
-rw-r--r-- | tests/kms_flip_scaled_crc.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/kms_flip_scaled_crc.c b/tests/kms_flip_scaled_crc.c index 88919de2..4923f123 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 |